class ProjectGenerater
Public Class Methods
copyUpdateFile(oldPath,newPath,oldName,newName)
click to toggle source
# File lib/furion/project_generate.rb, line 26 def self.copyUpdateFile(oldPath,newPath,oldName,newName) File.open(newPath, "w") do |out| File.foreach(oldPath) do |line| content = self.updateCopyRight(line,newName) content = self.updateCreatedInfo(content) if content.include?oldName newLine = content.gsub(oldName,newName) out.puts newLine else out.puts content end end end end
fetchExampleCode()
click to toggle source
# File lib/furion/project_generate.rb, line 8 def self.fetchExampleCode end
setupProject(projPath,newName)
click to toggle source
# File lib/furion/project_generate.rb, line 12 def self.setupProject(projPath,newName) Find.find(projPath) do |path| puts "[o]"+path newPath = path.gsub($placeHolderStr,newName) puts "[*]"+newPath if File.file?(path) copyUpdateFile(path,newPath,$placeHolderStr,newName) else Dir.mkdir(newPath) end end end
updateCopyRight(content,projName)
click to toggle source
# File lib/furion/project_generate.rb, line 42 def self.updateCopyRight(content,projName) if content.include? $copyrightInfo current_year = Time.new.year year_content = content.sub("$YEAR",String(current_year)) result = year_content.sub("$PROJECT",projName) return result end return content end
updateCreatedInfo(content)
click to toggle source
# File lib/furion/project_generate.rb, line 52 def self.updateCreatedInfo(content) if content.include? $createInfo curTime = Time.now.strftime("%Y/%m/%d") time_content = content.sub("$DATE",curTime) author = Etc.getpwuid(Process.uid).name result = time_content.sub("$AUTHOR",author) return result end return content end