Class: Webapp::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/webapp.rb

Class Method Summary collapse

Class Method Details

.generate(application) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/webapp.rb', line 7

def self.generate(application)

  %w[lib test config views lib/migrations].each { |dir| mkdir_p "#{application}/#{dir}" }
  
  files = %w[
    lib/project.rb lib/server.rb Rakefile config.ru config/nginx.conf
    config/geminstaller.yml test/test_helper.rb test/server_test.rb
  ]

  files.each do |tmpl|
    template = ERB.new(File.read(File.join(File.dirname(__FILE__), 'templates', tmpl)))
    File.open("#{application}/#{tmpl}", 'w') { |f| f << template.result(binding) }
  end

  puts "Generated #{application}. Respeck teh web!!1"
  puts 'Next you might want to:'
  puts %Q{`cd #{application} && rake`}
  puts '... or'
  puts %Q{`cd #{application} && ruby lib/server.rb`}
end