Sha256: 2d6654a7b1ebc9a50161d1d0b37cee0e42c7a46d98c5db39cdf18035b5ec1ba9
Contents?: true
Size: 1.86 KB
Versions: 1
Compression:
Stored size: 1.86 KB
Contents
require 'rails/generators/rails/plugin/plugin_generator' module Wanko class ExtensionBuilder < ::Rails::PluginBuilder def readme() end def rakefile() end end module Generators class ExtensionGenerator < ::Rails::Generators::PluginGenerator 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('../templates', __FILE__), *super] end end def initialize(*args) options = args.extract_options! options[:destination_root] = 'app/extensions' 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 Wanko::ExtensionBuilder 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/#{name}_tasks.rake" 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 wanko:controller #{name}/#{base_controller} #{actions * ' '}` end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wanko-0.0.1 | lib/generators/wanko/extension_generator.rb |