Class: Deano::ModelGenerator
- Inherits:
-
NameCommand
- Object
- Command
- NameCommand
- Deano::ModelGenerator
- Defined in:
- lib/deano/commands/model_generator_command.rb
Instance Attribute Summary
Attributes inherited from NameCommand
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from NameCommand
#classified, #clean_string, inherited, #initialize, #underscored
Methods inherited from Command
#app_path, #cmd, commands, inherited, #rm, #rm_r, #template_path
Constructor Details
This class inherits a constructor from Deano::NameCommand
Class Method Details
.command ⇒ Object
4 5 6 |
# File 'lib/deano/commands/model_generator_command.rb', line 4 def self.command "generate:model" end |
.help ⇒ Object
8 9 10 |
# File 'lib/deano/commands/model_generator_command.rb', line 8 def self.help "model_name" end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/deano/commands/model_generator_command.rb', line 12 def call path = app_path("models", "#{self.underscored}.rb") FileUtils.mkdir_p File.dirname(path), verbose: true File.open(path, 'w') do |file| file.puts " class \#{self.classified}\ninclude Mongoid::Document\ninclude Mongoid::Timestamps\n\n end\n EOF\n end\n\n path = app_path(\"spec\", \"models\", \"\#{self.underscored}_spec.rb\")\n FileUtils.mkdir_p File.dirname(path), verbose: true\n File.open(path, 'w') do |file|\n file.puts <<-EOF\n require 'spec_helper'\n\n describe \#{self.classified} do\n\nit \"does something\"\n\n end\n EOF\n end\nend\n" |