Class: ProjectGenerater
- Inherits:
-
Object
- Object
- ProjectGenerater
- Defined in:
- lib/furion/project_generate.rb
Class Method Summary collapse
- .copyUpdateFile(oldPath, newPath, oldName, newName) ⇒ Object
- .fetchExampleCode ⇒ Object
- .setupProject(projPath, newName) ⇒ Object
- .updateCopyRight(content, projName) ⇒ Object
- .updateCreatedInfo(content) ⇒ Object
Class Method Details
.copyUpdateFile(oldPath, newPath, oldName, newName) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# 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 ⇒ Object
8 9 10 |
# File 'lib/furion/project_generate.rb', line 8 def self.fetchExampleCode end |
.setupProject(projPath, newName) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# 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) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# 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) ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# 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) = Etc.getpwuid(Process.uid).name result = time_content.sub("$AUTHOR",) return result end return content end |