summaryrefslogtreecommitdiffstats
path: root/lib/generators/redmine_plugin/redmine_plugin_generator.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/generators/redmine_plugin/redmine_plugin_generator.rb')
-rw-r--r--lib/generators/redmine_plugin/redmine_plugin_generator.rb47
1 files changed, 24 insertions, 23 deletions
diff --git a/lib/generators/redmine_plugin/redmine_plugin_generator.rb b/lib/generators/redmine_plugin/redmine_plugin_generator.rb
index 0946d3ba0..8e1e4f822 100644
--- a/lib/generators/redmine_plugin/redmine_plugin_generator.rb
+++ b/lib/generators/redmine_plugin/redmine_plugin_generator.rb
@@ -1,32 +1,33 @@
-class RedminePluginGenerator < Rails::Generator::NamedBase
+class RedminePluginGenerator < Rails::Generators::NamedBase
+ source_root File.expand_path("../templates", __FILE__)
+
attr_reader :plugin_path, :plugin_name, :plugin_pretty_name
- def initialize(runtime_args, runtime_options = {})
+ def initialize(*args)
super
- @plugin_name = "redmine_#{file_name.underscore}"
+ @plugin_name = file_name.underscore
@plugin_pretty_name = plugin_name.titleize
- @plugin_path = "vendor/plugins/#{plugin_name}"
+ @plugin_path = "plugins/#{plugin_name}"
end
- def manifest
- record do |m|
- m.directory "#{plugin_path}/app/controllers"
- m.directory "#{plugin_path}/app/helpers"
- m.directory "#{plugin_path}/app/models"
- m.directory "#{plugin_path}/app/views"
- m.directory "#{plugin_path}/db/migrate"
- m.directory "#{plugin_path}/lib/tasks"
- m.directory "#{plugin_path}/assets/images"
- m.directory "#{plugin_path}/assets/javascripts"
- m.directory "#{plugin_path}/assets/stylesheets"
- m.directory "#{plugin_path}/lang"
- m.directory "#{plugin_path}/config/locales"
- m.directory "#{plugin_path}/test"
+ def copy_templates
+ empty_directory "#{plugin_path}/app"
+ empty_directory "#{plugin_path}/app/controllers"
+ empty_directory "#{plugin_path}/app/helpers"
+ empty_directory "#{plugin_path}/app/models"
+ empty_directory "#{plugin_path}/app/views"
+ empty_directory "#{plugin_path}/db/migrate"
+ empty_directory "#{plugin_path}/lib/tasks"
+ empty_directory "#{plugin_path}/assets/images"
+ empty_directory "#{plugin_path}/assets/javascripts"
+ empty_directory "#{plugin_path}/assets/stylesheets"
+ empty_directory "#{plugin_path}/config/locales"
+ empty_directory "#{plugin_path}/test"
- m.template 'README.rdoc', "#{plugin_path}/README.rdoc"
- m.template 'init.rb.erb', "#{plugin_path}/init.rb"
- m.template 'en_rails_i18n.yml', "#{plugin_path}/config/locales/en.yml"
- m.template 'test_helper.rb.erb', "#{plugin_path}/test/test_helper.rb"
- end
+ template 'README.rdoc', "#{plugin_path}/README.rdoc"
+ template 'init.rb.erb', "#{plugin_path}/init.rb"
+ template 'routes.rb', "#{plugin_path}/config/routes.rb"
+ template 'en_rails_i18n.yml', "#{plugin_path}/config/locales/en.yml"
+ template 'test_helper.rb.erb', "#{plugin_path}/test/test_helper.rb"
end
end