Class: HotPotato::Generate
- Inherits:
-
Object
- Object
- HotPotato::Generate
- Defined in:
- lib/hot_potato/generate.rb
Instance Method Summary collapse
- #copy_file(src, dest = "", perm = 0644) ⇒ Object
-
#initialize(app_path) ⇒ Generate
constructor
A new instance of Generate.
- #log(message) ⇒ Object
- #mkdir(path) ⇒ Object
Constructor Details
#initialize(app_path) ⇒ Generate
Returns a new instance of Generate.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/hot_potato/generate.rb', line 7 def initialize(app_path) @app_path = app_path log "Generating application #{@app_path}..." mkdir app_path copy_file "Gemfile" copy_file "Rakefile" mkdir "app" mkdir "bin" copy_file "admin", 'bin', 0755 copy_file "app_task", 'bin', 0755 copy_file "generate", 'bin', 0755 copy_file "supervisor", 'bin', 0755 mkdir "config" mkdir "config/environments" copy_file "development.rb", 'config/environments' copy_file "test.rb", 'config/environments' copy_file "production.rb", 'config/environments' copy_file "boot.rb", 'config' copy_file "config.yml", 'config' copy_file "routes.rb", 'config' mkdir "docs" mkdir "logs" mkdir "test" mkdir "tmp" end |
Instance Method Details
#copy_file(src, dest = "", perm = 0644) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/hot_potato/generate.rb', line 43 def copy_file(src, dest = "", perm = 0644) dest = "#{dest}/" unless dest == "" log " add #{@app_path}/#{dest}#{src}" FileUtils.cp "#{File.('..', __FILE__)}/templates/#{src}", "#{@app_path}/#{dest}#{src}" File.chmod perm, "#{@app_path}/#{dest}#{src}" end |
#log(message) ⇒ Object
50 51 52 |
# File 'lib/hot_potato/generate.rb', line 50 def log() puts "#{}" end |
#mkdir(path) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/hot_potato/generate.rb', line 33 def mkdir(path) dir = path == @app_path ? @app_path : "#{@app_path}/#{path}" if Dir.exists?(dir) log " exist #{dir}" else Dir.mkdir(dir) log " create #{dir}" end end |