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 / ae / aece43382595a414583466234e19e24279ff6883.svn-base @ 1297:0a574315af3e
History | View | Annotate | Download (1.98 KB)
| 1 |
require 'rails_generator/base' |
|---|---|
| 2 |
require 'rails_generator/generators/components/controller/controller_generator' |
| 3 |
|
| 4 |
class RedminePluginControllerGenerator < ControllerGenerator |
| 5 |
attr_reader :plugin_path, :plugin_name, :plugin_pretty_name |
| 6 |
|
| 7 |
def initialize(runtime_args, runtime_options = {})
|
| 8 |
runtime_args = runtime_args.dup |
| 9 |
usage if runtime_args.empty? |
| 10 |
@plugin_name = "redmine_" + runtime_args.shift.underscore |
| 11 |
@plugin_pretty_name = plugin_name.titleize |
| 12 |
@plugin_path = "vendor/plugins/#{plugin_name}"
|
| 13 |
super(runtime_args, runtime_options) |
| 14 |
end |
| 15 |
|
| 16 |
def destination_root |
| 17 |
File.join(Rails.root, plugin_path) |
| 18 |
end |
| 19 |
|
| 20 |
def manifest |
| 21 |
record do |m| |
| 22 |
# Check for class naming collisions. |
| 23 |
m.class_collisions class_path, "#{class_name}Controller", "#{class_name}ControllerTest", "#{class_name}Helper"
|
| 24 |
|
| 25 |
# Controller, helper, views, and test directories. |
| 26 |
m.directory File.join('app/controllers', class_path)
|
| 27 |
m.directory File.join('app/helpers', class_path)
|
| 28 |
m.directory File.join('app/views', class_path, file_name)
|
| 29 |
m.directory File.join('test/functional', class_path)
|
| 30 |
|
| 31 |
# Controller class, functional test, and helper class. |
| 32 |
m.template 'controller.rb.erb', |
| 33 |
File.join('app/controllers',
|
| 34 |
class_path, |
| 35 |
"#{file_name}_controller.rb")
|
| 36 |
|
| 37 |
m.template 'functional_test.rb.erb', |
| 38 |
File.join('test/functional',
|
| 39 |
class_path, |
| 40 |
"#{file_name}_controller_test.rb")
|
| 41 |
|
| 42 |
m.template 'helper.rb.erb', |
| 43 |
File.join('app/helpers',
|
| 44 |
class_path, |
| 45 |
"#{file_name}_helper.rb")
|
| 46 |
|
| 47 |
# View template for each action. |
| 48 |
actions.each do |action| |
| 49 |
path = File.join('app/views', class_path, file_name, "#{action}.html.erb")
|
| 50 |
m.template 'view.html.erb', path, |
| 51 |
:assigns => { :action => action, :path => path }
|
| 52 |
end |
| 53 |
end |
| 54 |
end |
| 55 |
end |