summaryrefslogtreecommitdiffstats
path: root/lib/generators/redmine_plugin
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-04-25 17:17:49 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-04-25 17:17:49 +0000
commit5e57a1a9d9478162ac4f27ae96b2ccaf55a1aba7 (patch)
tree93e57765139714bd82dede475725516c448c0d55 /lib/generators/redmine_plugin
parent34e20c4373b7f5a20ab3a132feae3f70f21ec477 (diff)
downloadredmine-5e57a1a9d9478162ac4f27ae96b2ccaf55a1aba7.tar.gz
redmine-5e57a1a9d9478162ac4f27ae96b2ccaf55a1aba7.zip
Merged rails-3.2 branch.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9528 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/generators/redmine_plugin')
-rw-r--r--lib/generators/redmine_plugin/USAGE21
-rw-r--r--lib/generators/redmine_plugin/redmine_plugin_generator.rb47
-rw-r--r--lib/generators/redmine_plugin/templates/init.rb.erb2
-rw-r--r--lib/generators/redmine_plugin/templates/routes.rb2
4 files changed, 31 insertions, 41 deletions
diff --git a/lib/generators/redmine_plugin/USAGE b/lib/generators/redmine_plugin/USAGE
index 1ed0dd591..01486f0d8 100644
--- a/lib/generators/redmine_plugin/USAGE
+++ b/lib/generators/redmine_plugin/USAGE
@@ -3,19 +3,8 @@ Description:
Example:
./script/generate redmine_plugin meetings
- create vendor/plugins/redmine_meetings/app/controllers
- create vendor/plugins/redmine_meetings/app/helpers
- create vendor/plugins/redmine_meetings/app/models
- create vendor/plugins/redmine_meetings/app/views
- create vendor/plugins/redmine_meetings/db/migrate
- create vendor/plugins/redmine_meetings/lib/tasks
- create vendor/plugins/redmine_meetings/assets/images
- create vendor/plugins/redmine_meetings/assets/javascripts
- create vendor/plugins/redmine_meetings/assets/stylesheets
- create vendor/plugins/redmine_meetings/lang
- create vendor/plugins/redmine_meetings/config/locales
- create vendor/plugins/redmine_meetings/test
- create vendor/plugins/redmine_meetings/README.rdoc
- create vendor/plugins/redmine_meetings/init.rb
- create vendor/plugins/redmine_meetings/config/locales/en.yml
- create vendor/plugins/redmine_meetings/test/test_helper.rb
+ create plugins/meetings/README.rdoc
+ create plugins/meetings/init.rb
+ create plugins/meetings/config/routes.rb
+ create plugins/meetings/config/locales/en.yml
+ create plugins/meetings/test/test_helper.rb
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
diff --git a/lib/generators/redmine_plugin/templates/init.rb.erb b/lib/generators/redmine_plugin/templates/init.rb.erb
index e6feded22..763ba7d22 100644
--- a/lib/generators/redmine_plugin/templates/init.rb.erb
+++ b/lib/generators/redmine_plugin/templates/init.rb.erb
@@ -1,5 +1,3 @@
-require 'redmine'
-
Redmine::Plugin.register :<%= plugin_name %> do
name '<%= plugin_pretty_name %> plugin'
author 'Author name'
diff --git a/lib/generators/redmine_plugin/templates/routes.rb b/lib/generators/redmine_plugin/templates/routes.rb
new file mode 100644
index 000000000..1803173d0
--- /dev/null
+++ b/lib/generators/redmine_plugin/templates/routes.rb
@@ -0,0 +1,2 @@
+# Plugin's routes
+# See: http://guides.rubyonrails.org/routing.html