diff options
Diffstat (limited to 'railties/lib/generators/rails/plugin')
4 files changed, 12 insertions, 21 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 diff --git a/railties/lib/generators/rails/plugin/templates/lib/generators/%file_name%_generator.rb.tt b/railties/lib/generators/rails/plugin/templates/lib/generators/%file_name%_generator.rb.tt deleted file mode 100644 index 675f00043f..0000000000 --- a/railties/lib/generators/rails/plugin/templates/lib/generators/%file_name%_generator.rb.tt +++ /dev/null @@ -1,5 +0,0 @@ -class <%= class_name %>Generator < Rails::Generators::NamedBase - def self.source_root - @source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates')) - end -end diff --git a/railties/lib/generators/rails/plugin/templates/lib/generators/USAGE.tt b/railties/lib/generators/rails/plugin/templates/lib/generators/USAGE.tt deleted file mode 100644 index ea9f4f12cc..0000000000 --- a/railties/lib/generators/rails/plugin/templates/lib/generators/USAGE.tt +++ /dev/null @@ -1,8 +0,0 @@ -Description: - Explain the generator - -Example: - ./script/generate <%= file_name %> Thing - - This will create: - what/will/it/create diff --git a/railties/lib/generators/rails/plugin/templates/lib/generators/templates/.empty_directory b/railties/lib/generators/rails/plugin/templates/lib/generators/templates/.empty_directory deleted file mode 100644 index e69de29bb2..0000000000 --- a/railties/lib/generators/rails/plugin/templates/lib/generators/templates/.empty_directory +++ /dev/null |