Skip to content
Browse files

Removing the refactor scripts as they are way outdate and no-longer n…

…eeded

git-svn-id: https://pushbuttonengine.googlecode.com/svn/trunk@1077 6b8e678a-0755-11de-b5bf-434079a3519f
  • Loading branch information...
1 parent 32c8fda commit cb46b56918bf3a4eeb3a71c1dda6deeac2f6513d nate@zaalabs.com committed
Showing with 0 additions and 246 deletions.
  1. +0 −12 script/refactor/config.yml
  2. +0 −119 script/refactor/refactorLevel.rb
  3. +0 −115 script/refactor/refactorPackages.rb
View
12 script/refactor/config.yml
@@ -1,12 +0,0 @@
----
-srcPath: "/pbe/branches/CodeStyleCleanup/src/PBLabs"
-outPath: "/pbe/branches/CodeStyleCleanup/src"
-newPackage: "com.pblabs"
-moveCommand: "svn move $source $dest"
-
-exceptions:
- - source: MXML
- dest: mxml
-
- - source: UI
- dest: ui
View
119 script/refactor/refactorLevel.rb
@@ -1,119 +0,0 @@
-require 'ftools'
-require 'yaml'
-
-def checkArgs()
- if(ARGV[0])
- validatePath(ARGV[0], true)
- File.copy(ARGV[0], "#{ARGV[0]}.old")
- @input = "#{ARGV[0]}.old"
- @output = ARGV[0]
- else
- puts "Usage: ruby refactorLevel.rb input.pbelevel"
- exit
- end
-end
-
-def validatePath (path, do_exit=false)
- if !File.exists? path
- puts "[ERROR] \"#{path}\" is not a valid file"
- if(do_exit)
- #puts "Exiting Script"
- exit
- end
- end
-end
-
-def readFile()
- File.open(@input, "r") do |infile|
- while (line = infile.gets)
- writeLine(line)
- end
- end
-end
-
-def writeLine(line)
- line = fixPackages(line)
- line = fixTags(line)
- writeFile(line, 'a')
- #puts "#{line}"
-end
-
-def writeFile(line, writeMode)
- File.open(@output, writeMode) {|f| f.write(line) }
-end
-
-def fixTags(line)
- rx = /\<\/?([A-Z])/
-
- while((line =~ rx) != nil)
- index = line =~ rx
- if(line[index+1..index+1] == "/")
- downcaseLetter(line, index+2)
- else
- downcaseLetter(line, index+1)
- end
- end
-
- return line
-end
-
-def fixPackages(line)
-
- rx = /PBLabs\.[^"]+/
-
- while((line =~ rx) != nil)
- line = $` + convertPackage($&).to_s + $'
- end
-
- return line
-end
-
-def convertPackage(oldPackage)
- print oldPackage, " -> "
- oldPackage.slice!("PBLabs.")
- arr = oldPackage.split(".")
- arr[0..arr.length-2].each {|p| downcaseLetter(p,0)}
- newPackage = @newPackage + "." + arr.join(".")
- puts newPackage
- return newPackage
-end
-
-def downcaseLetter(str, index)
- @exceptions.each do |e|
- if(str == e['source'])
- return e['dest']
- end
- end
-
- if(str.length > 0)
- str[index]=str[index..index].downcase
- end
-
- return str
-end
-
-begin
- scriptDir = File.expand_path(File.dirname(__FILE__))
- # Load Configuration
- if(File.exists?("#{scriptDir}/config.yml"))
- @conf = open("#{scriptDir}/config.yml") {|f| YAML.load(f) }
- else
- puts "[ERROR] \"#{scriptDir}/config.yml\" could not be loaded."
- exit
- end
-
- @exceptions = @conf['exceptions']
-
- @input = ''
- @output = ''
- @newPackage = 'com.pblabs'
-
- checkArgs()
- writeFile('','w') # Clear Output file
- readFile()
-
- puts "Converted \"#{File.basename(@output)}\" successfully!"
-
-rescue
- print "Something blew up: ",$!, "\n"
-end
View
115 script/refactor/refactorPackages.rb
@@ -1,115 +0,0 @@
-require 'ftools'
-require 'yaml'
-require 'pp'
-
-def moveFile (source, dest)
- cmd = @moveCommand.gsub("$source", source)
- cmd = cmd.gsub("$dest", dest)
- puts cmd
- system(cmd)
-end
-
-def validatePath (path, do_exit=false)
- if !File.exists? path
- puts "[ERROR] \"#{path}\" is not valid"
- if(do_exit)
- puts "Exiting Script"
- exit
- end
- end
-end
-
-def parsePackage(file)
- str = file
- str[@rootPath+"/"] = ""
- return str
-end
-
-def parseOutput(file)
- str = file
- str[@outPath+"/"] = ""
- return str
-end
-
-def createPackage (dir)
- arr = dir.split("/")
- arr.each {|p| downcaseFirstLetter(p)}
- @newPackage + "." + arr.join(".")
-end
-
-def packageToPath (package)
- package.split(".").join("/")
-end
-
-def makeDirFromPackage (package)
- dir = @outPath+"/"+packageToPath(package)
- create_if_missing dir
- addToRepo dir
-end
-
-def addToRepo dir
- arr = parseOutput(dir).split("/")
- arr.each_index do |i|
- newDir = @outPath + "/" + arr[0..i].join("/")
- system("svn add #{newDir}")
- end
-end
-
-def create_if_missing dirs
- puts "Creating #{dirs}"
- File.makedirs dirs unless File.directory?(dirs)
-end
-
-def downcaseFirstLetter(str)
- @exceptions.each do |e|
- if(str == e['source'])
- return e['dest']
- end
- end
-
- if(str.length > 0)
- str[0]=str[0..0].downcase
- end
-
- return str
-end
-
-def loopThroughDirectory( dirname )
- Dir["#{dirname}/**/**"].each do | thisfile |
-
- if(File.directory? thisfile) # If it's a directory
- parsedDir = parsePackage(thisfile)
- newPackage = createPackage(parsedDir)
- print "Directory: ",parsedDir," => ",newPackage,"\n"
- makeDirFromPackage(newPackage)
- else
- parsedDir = parsePackage(File.dirname(thisfile))
- dest = @outPath + "/" + packageToPath(createPackage(parsedDir)) + "/" + File.basename(thisfile)
- print "File: ",parsedDir+"/"+File.basename(thisfile)," => ",dest,"\n"
- moveFile(thisfile,dest)
- end
- end
-end
-
-begin
- # Load Configuration
- @conf = open("./config.yml") {|f| YAML.load(f) }
- #pp @conf
-
- @rootPath = @conf['srcPath']
- @outPath = @conf['outPath']
- @newPackage = @conf['newPackage']
- @moveCommand = @conf['moveCommand']
- @exceptions = @conf['exceptions']
-
- puts "Root Path => #{@rootPath}"
-
- validatePath(@rootPath,true)
-
- loopThroughDirectory(@rootPath)
-
- system("svn delete #{@rootPath}")
-
-#rescue
-# print "Something blew up: ",$!, "\n"
-end

0 comments on commit cb46b56

Please sign in to comment.
Something went wrong with that request. Please try again.