Class: MotorheadGenerator
- Inherits:
-
Rails::Generators::PluginGenerator
- Object
- Rails::Generators::PluginGenerator
- MotorheadGenerator
- Defined in:
- lib/generators/motorhead_generator.rb
Defined Under Namespace
Classes: EngineBuilder
Class Method Summary collapse
Instance Method Summary collapse
- #bundle_to_parent ⇒ Object
-
#create_bin_files ⇒ Object
override.
- #generate_controller ⇒ Object
- #get_builder_class ⇒ Object
-
#initialize(*args) ⇒ MotorheadGenerator
constructor
A new instance of MotorheadGenerator.
- #put_litter_in_its_place ⇒ Object
- #untodo_gemspec ⇒ Object
Constructor Details
#initialize(*args) ⇒ MotorheadGenerator
Returns a new instance of MotorheadGenerator.
19 20 21 22 23 24 25 26 |
# File 'lib/generators/motorhead_generator.rb', line 19 def initialize(*args) = args. [:destination_root] = 'app/engines' super(*args, ) = @options.dup [:mountable] = [:skip_bundle] = [:skip_test_unit] = [:skip_git] = [:skip_gemfile] = true @options = .freeze end |
Class Method Details
.source_paths ⇒ Object
14 15 16 |
# File 'lib/generators/motorhead_generator.rb', line 14 def source_paths [File.('../motorhead/templates', __FILE__), *super] end |
Instance Method Details
#bundle_to_parent ⇒ Object
47 48 49 50 |
# File 'lib/generators/motorhead_generator.rb', line 47 def bundle_to_parent gemfile = Rails.root + 'Gemfile' append_to_file gemfile, "gem '#{name}', path: '#{destination_root.sub(%r(^#{Rails.root}/), '')}'\n" if gemfile.exist? end |
#create_bin_files ⇒ Object
override
33 34 |
# File 'lib/generators/motorhead_generator.rb', line 33 def create_bin_files end |
#generate_controller ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/generators/motorhead_generator.rb', line 52 def generate_controller if base_controller Dir.chdir destination_root do #FIXME call the controller generator directly puts `rails g motorhead:controller #{name}/#{base_controller} #{actions * ' '}` end end end |
#get_builder_class ⇒ Object
28 29 30 |
# File 'lib/generators/motorhead_generator.rb', line 28 def get_builder_class EngineBuilder end |
#put_litter_in_its_place ⇒ Object
36 37 38 39 40 |
# File 'lib/generators/motorhead_generator.rb', line 36 def put_litter_in_its_place remove_file 'MIT-LICENSE' remove_file "app/controllers/#{name}/application_controller.rb" remove_file "lib/tasks" end |
#untodo_gemspec ⇒ Object
42 43 44 45 |
# File 'lib/generators/motorhead_generator.rb', line 42 def untodo_gemspec gemspec = "#{name}.gemspec" gsub_file gemspec, /"TODO.*?"/, '""' end |