Class: RedminePluginModelGenerator
- Inherits:
-
ModelGenerator
- Object
- ModelGenerator
- RedminePluginModelGenerator
- Defined in:
- lib/generators/redmine_plugin_model/redmine_plugin_model_generator.rb
Instance Attribute Summary collapse
-
#plugin_name ⇒ Object
Returns the value of attribute plugin_name.
-
#plugin_path ⇒ Object
Returns the value of attribute plugin_path.
-
#plugin_pretty_name ⇒ Object
Returns the value of attribute plugin_pretty_name.
Instance Method Summary collapse
- #destination_root ⇒ Object
-
#initialize(runtime_args, runtime_options = {}) ⇒ RedminePluginModelGenerator
constructor
A new instance of RedminePluginModelGenerator.
- #manifest ⇒ Object
Constructor Details
#initialize(runtime_args, runtime_options = {}) ⇒ RedminePluginModelGenerator
Returns a new instance of RedminePluginModelGenerator.
7 8 9 10 11 12 13 14 |
# File 'lib/generators/redmine_plugin_model/redmine_plugin_model_generator.rb', line 7 def initialize(runtime_args, = {}) runtime_args = runtime_args.dup usage if runtime_args.empty? @plugin_name = "redmine_" + runtime_args.shift.underscore @plugin_pretty_name = plugin_name.titleize @plugin_path = "vendor/plugins/#{plugin_name}" super(runtime_args, ) end |
Instance Attribute Details
#plugin_name ⇒ Object
Returns the value of attribute plugin_name.
5 6 7 |
# File 'lib/generators/redmine_plugin_model/redmine_plugin_model_generator.rb', line 5 def plugin_name @plugin_name end |
#plugin_path ⇒ Object
Returns the value of attribute plugin_path.
5 6 7 |
# File 'lib/generators/redmine_plugin_model/redmine_plugin_model_generator.rb', line 5 def plugin_path @plugin_path end |
#plugin_pretty_name ⇒ Object
Returns the value of attribute plugin_pretty_name.
5 6 7 |
# File 'lib/generators/redmine_plugin_model/redmine_plugin_model_generator.rb', line 5 def plugin_pretty_name @plugin_pretty_name end |
Instance Method Details
#destination_root ⇒ Object
16 17 18 |
# File 'lib/generators/redmine_plugin_model/redmine_plugin_model_generator.rb', line 16 def destination_root File.join(RAILS_ROOT, plugin_path) end |
#manifest ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/generators/redmine_plugin_model/redmine_plugin_model_generator.rb', line 20 def manifest record do |m| # Check for class naming collisions. m.class_collisions class_path, class_name, "#{class_name}Test" # Model, test, and fixture directories. m.directory File.join('app/models', class_path) m.directory File.join('test/unit', class_path) m.directory File.join('test/fixtures', class_path) # Model class, unit test, and fixtures. m.template 'model.rb.erb', File.join('app/models', class_path, "#{file_name}.rb") m.template 'unit_test.rb.erb', File.join('test/unit', class_path, "#{file_name}_test.rb") unless [:skip_fixture] m.template 'fixtures.yml', File.join('test/fixtures', "#{table_name}.yml") end unless [:skip_migration] m.migration_template 'migration.rb.erb', 'db/migrate', :assigns => { :migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}" }, :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}" end end end |