diff options
Diffstat (limited to 'railties/lib/generators/rails/plugin/plugin_generator.rb')
-rw-r--r-- | railties/lib/generators/rails/plugin/plugin_generator.rb | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/railties/lib/generators/rails/plugin/plugin_generator.rb b/railties/lib/generators/rails/plugin/plugin_generator.rb index 903f720e12..49fe409ea8 100644 --- a/railties/lib/generators/rails/plugin/plugin_generator.rb +++ b/railties/lib/generators/rails/plugin/plugin_generator.rb @@ -1,12 +1,11 @@ +require 'generators/rails/generator/generator_generator' + module Rails module Generators class PluginGenerator < NamedBase class_option :tasks, :type => :boolean, :aliases => "-t", :default => false, :desc => "When supplied creates tasks base files." - class_option :generator, :type => :boolean, :aliases => "-g", :default => false, - :desc => "When supplied creates generator base files." - check_class_collision def create_root_files @@ -17,16 +16,21 @@ module Rails directory 'lib', plugin_dir('lib'), false # non-recursive end - hook_for :test_framework - def create_tasks_files return unless options[:tasks] directory 'tasks', plugin_dir('tasks') end - def create_generator_files - return unless options[:generator] - directory 'lib/generators', plugin_dir('lib/generators') + hook_for :generator, :aliases => "-g", :type => :boolean do |instance, generator| + instance.inside_with_padding instance.send(:plugin_dir) do + instance.invoke generator, [ instance.name ], :namespace => false + end + end + + hook_for :test_framework do |instance, test_framework| + instance.inside_with_padding instance.send(:plugin_dir) do + instance.invoke test_framework + end end protected |