Class: MegaBar::MegaBarModelsGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- MegaBar::MegaBarModelsGenerator
- Defined in:
- lib/generators/mega_bar/mega_bar_models/mega_bar_models_generator.rb
Constant Summary collapse
- @@notices =
[]
Instance Method Summary collapse
-
#create_controller_file ⇒ Object
in generators, all public methods are run.
- #create_controller_spec_file ⇒ Object
- #create_factory ⇒ Object
- #create_model_file ⇒ Object
- #generate_migration ⇒ Object
- #write_notices ⇒ Object
Instance Method Details
#create_controller_file ⇒ Object
in generators, all public methods are run. Weird, huh?
11 12 13 14 |
# File 'lib/generators/mega_bar/mega_bar_models/mega_bar_models_generator.rb', line 11 def create_controller_file @@notices << "You will have to copy your controller manually over to the megabar gem" if gem_path == '' && modyule == 'MegaBar' template 'generic_controller.rb', "#{gem_path}#{the_controller_file_path}#{the_controller_file_name}.rb" end |
#create_controller_spec_file ⇒ Object
30 31 32 33 |
# File 'lib/generators/mega_bar/mega_bar_models/mega_bar_models_generator.rb', line 30 def create_controller_spec_file template 'generic_controller_spec.rb', "#{gem_path}#{the_controller_spec_file_path}#{the_controller_spec_file_name}.rb" @@notices << "You will have to copy the spec file yourself manually to the megabar repo's spec/controllers directory" if gem_path == '' && modyule == 'MegaBar' end |
#create_factory ⇒ Object
35 36 37 38 |
# File 'lib/generators/mega_bar/mega_bar_models/mega_bar_models_generator.rb', line 35 def create_factory @@notices << "You will have to copy the factory file yourself manually to the megabar repo's spec/internal/factories directory" if gem_path == '' && modyule == 'MegaBar' template 'generic_factory.rb', "#{gem_path}#{the_factory_file_path}#{the_model_file_name}.rb" end |
#create_model_file ⇒ Object
15 16 17 18 19 |
# File 'lib/generators/mega_bar/mega_bar_models/mega_bar_models_generator.rb', line 15 def create_model_file template 'generic_model.rb', "#{gem_path}#{the_model_file_path}#{the_model_file_name}.rb" @@notices << "You will have to copy your model files manually over to the megabar gem" if gem_path == '' && modyule == 'MegaBar' template "generic_tmp_model.rb", "#{gem_path}#{the_model_file_path}tmp_#{the_model_file_name}.rb" if modyule == 'MegaBar' end |
#generate_migration ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/generators/mega_bar/mega_bar_models/mega_bar_models_generator.rb', line 20 def generate_migration if the_module_name generate 'migration create_' + the_table_name + ' created_at:datetime updated_at:datetime' generate 'migration create_' + 'mega_bar_tmp_' + classname.underscore.downcase.pluralize + ' created_at:datetime updated_at:datetime' if modyule == 'MegaBar' @@notices << "You will have to copy your Migrations manually over to the megabar gem" else generate 'migration create_' + the_table_name + ' created_at:datetime updated_at:datetime' end end |
#write_notices ⇒ Object
40 41 42 |
# File 'lib/generators/mega_bar/mega_bar_models/mega_bar_models_generator.rb', line 40 def write_notices # todo .. take @@notices and write it to a db? or a file? hmm.. end |