To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / .svn / pristine / 3e / 3e339092f343524c6085cf1a81f2c664a0ae64ee.svn-base @ 1298:4f746d8966dd
History | View | Annotate | Download (1.03 KB)
| 1 |
class RedminePluginControllerGenerator < Rails::Generators::NamedBase |
|---|---|
| 2 |
source_root File.expand_path("../templates", __FILE__)
|
| 3 |
argument :controller, :type => :string |
| 4 |
argument :actions, :type => :array, :default => [], :banner => "ACTION ACTION ..." |
| 5 |
|
| 6 |
attr_reader :plugin_path, :plugin_name, :plugin_pretty_name |
| 7 |
|
| 8 |
def initialize(*args) |
| 9 |
super |
| 10 |
@plugin_name = file_name.underscore |
| 11 |
@plugin_pretty_name = plugin_name.titleize |
| 12 |
@plugin_path = "plugins/#{plugin_name}"
|
| 13 |
@controller_class = controller.camelize |
| 14 |
end |
| 15 |
|
| 16 |
def copy_templates |
| 17 |
template 'controller.rb.erb', "#{plugin_path}/app/controllers/#{controller}_controller.rb"
|
| 18 |
template 'helper.rb.erb', "#{plugin_path}/app/helpers/#{controller}_helper.rb"
|
| 19 |
template 'functional_test.rb.erb', "#{plugin_path}/test/functional/#{controller}_controller_test.rb"
|
| 20 |
# View template for each action. |
| 21 |
actions.each do |action| |
| 22 |
path = "#{plugin_path}/app/views/#{controller}/#{action}.html.erb"
|
| 23 |
@action_name = action |
| 24 |
template 'view.html.erb', path |
| 25 |
end |
| 26 |
end |
| 27 |
end |