diff options
author | José Valim <jose.valim@gmail.com> | 2010-01-18 13:44:32 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-01-18 16:21:11 +0100 |
commit | 9fffdc5cdb80b1824473a6d7ae1fedf9e74aa748 (patch) | |
tree | 88f429511bf65f1104efeab10d6310b68ab24837 /railties/lib/generators/rails/plugin/plugin_generator.rb | |
parent | e75ea474346e74e36d92febd47985c3571b1472b (diff) | |
download | rails-9fffdc5cdb80b1824473a6d7ae1fedf9e74aa748.tar.gz rails-9fffdc5cdb80b1824473a6d7ae1fedf9e74aa748.tar.bz2 rails-9fffdc5cdb80b1824473a6d7ae1fedf9e74aa748.zip |
Generators load path now will be Ruby load path. If you want to use rspec:install generator, you need generators/rspec/install_generator in your load path.
Diffstat (limited to 'railties/lib/generators/rails/plugin/plugin_generator.rb')
-rw-r--r-- | railties/lib/generators/rails/plugin/plugin_generator.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/railties/lib/generators/rails/plugin/plugin_generator.rb b/railties/lib/generators/rails/plugin/plugin_generator.rb new file mode 100644 index 0000000000..ee785caf7d --- /dev/null +++ b/railties/lib/generators/rails/plugin/plugin_generator.rb @@ -0,0 +1,47 @@ +require 'generators/rails/generator/generator_generator' + +module Rails + module Generators + class PluginGenerator < NamedBase + class_option :tasks, :desc => "When supplied creates tasks base files." + + check_class_collision + + def create_root_files + directory '.', plugin_dir, :recursive => false + end + + def create_lib_files + directory 'lib', plugin_dir('lib'), :recursive => false + end + + def create_tasks_files + return unless options[:tasks] + directory 'tasks', plugin_dir('tasks') + end + + hook_for :generator do |instance, generator| + instance.inside instance.send(:plugin_dir), :verbose => true do + instance.invoke generator, [ instance.name ], :namespace => false + end + end + + hook_for :test_framework do |instance, test_framework| + instance.inside instance.send(:plugin_dir), :verbose => true do + instance.invoke test_framework + end + end + + protected + + def plugin_dir(join=nil) + if join + File.join(plugin_dir, join) + else + "vendor/plugins/#{file_name}" + end + end + + end + end +end |