Class: Cli::Generate
- Inherits:
-
Thor
- Object
- Thor
- Cli::Generate
- Defined in:
- lib/hotchkiss/cli/generate.rb
Instance Method Summary collapse
Instance Method Details
#controller(name) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/hotchkiss/cli/generate.rb', line 19 def controller(name) init file = Dir.pwd + "/code/app/controllers/#{name}_controller.rb" open(file, File::CREAT|File::TRUNC|File::RDWR) do |f| f << "class #{name.capitalize}Controller < HK::Controller\nend\n" end puts "Creation: #{file}" end |
#migration(name) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/hotchkiss/cli/generate.rb', line 29 def migration(name) init = Time.now.to_i final_name = "#{}_#{name}" file = Dir.pwd + "/db/migrations/#{final_name}.rb" FileUtils.cp_r(Cli::TEMPLATE_DIR + "generate/migration/migration", file) puts "Creation: #{file}" end |
#model(name) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/hotchkiss/cli/generate.rb', line 6 def model(name) init file = Dir.pwd + "/code/app/models/#{name}.rb" unless Dir.exists?(Cli::MODEL_DIR) Dir.mkdir(Cli::MODEL_DIR) end open(file, File::CREAT|File::TRUNC|File::RDWR) do |f| f << "class #{name.capitalize} < Sequel::Model\nend\n" end puts "Creation: #{file}" end |