##// END OF EJS Templates
remove trailing white-spaces from lib/generators/redmine_plugin_model/redmine_plugin_model_generator.rb...
Toshi MARUYAMA -
r9163:3b6be9ca4ee4
parent child
Show More
@@ -1,45 +1,45
1 1 require 'rails_generator/base'
2 2 require 'rails_generator/generators/components/model/model_generator'
3 3
4 4 class RedminePluginModelGenerator < ModelGenerator
5 5 attr_accessor :plugin_path, :plugin_name, :plugin_pretty_name
6
6
7 7 def initialize(runtime_args, runtime_options = {})
8 8 runtime_args = runtime_args.dup
9 9 usage if runtime_args.empty?
10 10 @plugin_name = "redmine_" + runtime_args.shift.underscore
11 11 @plugin_pretty_name = plugin_name.titleize
12 12 @plugin_path = "vendor/plugins/#{plugin_name}"
13 13 super(runtime_args, runtime_options)
14 14 end
15
15
16 16 def destination_root
17 17 File.join(Rails.root, plugin_path)
18 18 end
19
19
20 20 def manifest
21 21 record do |m|
22 22 # Check for class naming collisions.
23 23 m.class_collisions class_path, class_name, "#{class_name}Test"
24 24
25 25 # Model, test, and fixture directories.
26 26 m.directory File.join('app/models', class_path)
27 27 m.directory File.join('test/unit', class_path)
28 28 m.directory File.join('test/fixtures', class_path)
29 29
30 30 # Model class, unit test, and fixtures.
31 31 m.template 'model.rb.erb', File.join('app/models', class_path, "#{file_name}.rb")
32 32 m.template 'unit_test.rb.erb', File.join('test/unit', class_path, "#{file_name}_test.rb")
33 33
34 unless options[:skip_fixture]
34 unless options[:skip_fixture]
35 35 m.template 'fixtures.yml', File.join('test/fixtures', "#{table_name}.yml")
36 36 end
37 37
38 38 unless options[:skip_migration]
39 39 m.migration_template 'migration.rb.erb', 'db/migrate', :assigns => {
40 40 :migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}"
41 41 }, :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}"
42 42 end
43 43 end
44 44 end
45 45 end
General Comments 0
You need to be logged in to leave comments. Login now