Sha256: f8463a991dd57267f08f6d2294f35a333e9bc8857ebe882051588bcb3a8ea0a4
Contents?: true
Size: 1.62 KB
Versions: 4
Compression:
Stored size: 1.62 KB
Contents
require 'rails/generators/rails/plugin/plugin_generator' class MotorheadGenerator < ::Rails::Generators::PluginGenerator class EngineBuilder < ::Rails::PluginBuilder def readme() end def rakefile() end end argument :base_controller, type: :string, optional: true, banner: 'base controller' argument :actions, type: :array, default: [], banner: "action action" source_root ::Rails::Generators::PluginGenerator.source_root class << self def source_paths [File.expand_path('../motorhead/templates', __FILE__), *super] end end def initialize(*args) options = args.extract_options! options[:destination_root] = 'app/engines' super(*args, options) options = @options.dup options[:mountable] = options[:skip_bundle] = options[:skip_test_unit] = options[:skip_git] = options[:skip_gemfile] = true @options = options.freeze end def get_builder_class EngineBuilder end # override def create_bin_files end def put_litter_in_its_place remove_file 'MIT-LICENSE' remove_file "app/controllers/#{name}/application_controller.rb" remove_file "lib/tasks" end def untodo_gemspec gemspec = "#{name}.gemspec" gsub_file gemspec, /"TODO.*?"/, '""' end def bundle_to_parent gemfile = Rails.root + 'Gemfile' append_to_file gemfile, "gem '#{name}', path: '#{destination_root}'\n" if gemfile.exist? end 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 end
Version data entries
4 entries across 4 versions & 1 rubygems