def destination_root
File.join(RAILS_ROOT, plugin_path)
end
+
+ def manifest
+ record do |m|
+ # Check for class naming collisions.
+ m.class_collisions class_path, "#{class_name}Controller", "#{class_name}ControllerTest", "#{class_name}Helper"
+
+ # Controller, helper, views, and test directories.
+ m.directory File.join('app/controllers', class_path)
+ m.directory File.join('app/helpers', class_path)
+ m.directory File.join('app/views', class_path, file_name)
+ m.directory File.join('test/functional', class_path)
+
+ # Controller class, functional test, and helper class.
+ m.template 'controller.rb.erb',
+ File.join('app/controllers',
+ class_path,
+ "#{file_name}_controller.rb")
+
+ m.template 'functional_test.rb.erb',
+ File.join('test/functional',
+ class_path,
+ "#{file_name}_controller_test.rb")
+
+ m.template 'helper.rb.erb',
+ File.join('app/helpers',
+ class_path,
+ "#{file_name}_helper.rb")
+
+ # View template for each action.
+ actions.each do |action|
+ path = File.join('app/views', class_path, file_name, "#{action}.html.erb")
+ m.template 'view.html.erb', path,
+ :assigns => { :action => action, :path => path }
+ end
+ end
+ end
end
+++ /dev/null
-class <%= class_name %>Controller < ApplicationController
-<% actions.each do |action| -%>
-
- def <%= action %>
- end
-<% end -%>
-end
--- /dev/null
+class <%= class_name %>Controller < ApplicationController
+<% actions.each do |action| -%>
+
+ def <%= action %>
+ end
+<% end -%>
+end
+++ /dev/null
-require File.dirname(__FILE__) + '/../test_helper'
-
-class <%= class_name %>ControllerTest < ActionController::TestCase
- # Replace this with your real tests.
- def test_truth
- assert true
- end
-end
--- /dev/null
+require File.dirname(__FILE__) + '/../test_helper'
+
+class <%= class_name %>ControllerTest < ActionController::TestCase
+ # Replace this with your real tests.
+ def test_truth
+ assert true
+ end
+end
+++ /dev/null
-module <%= class_name %>Helper
-end
--- /dev/null
+module <%= class_name %>Helper
+end
def destination_root
File.join(RAILS_ROOT, plugin_path)
end
+
+ 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 options[:skip_fixture]
+ m.template 'fixtures.yml', File.join('test/fixtures', "#{table_name}.yml")
+ end
+
+ unless options[: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
end
+++ /dev/null
-class <%= migration_name %> < ActiveRecord::Migration
- def self.up
- create_table :<%= table_name %> do |t|
-<% for attribute in attributes -%>
- t.column :<%= attribute.name %>, :<%= attribute.type %>
-<% end -%>
- end
- end
-
- def self.down
- drop_table :<%= table_name %>
- end
-end
--- /dev/null
+class <%= migration_name %> < ActiveRecord::Migration
+ def self.up
+ create_table :<%= table_name %> do |t|
+<% for attribute in attributes -%>
+ t.column :<%= attribute.name %>, :<%= attribute.type %>
+<% end -%>
+ end
+ end
+
+ def self.down
+ drop_table :<%= table_name %>
+ end
+end
+++ /dev/null
-class <%= class_name %> < ActiveRecord::Base
-end
--- /dev/null
+class <%= class_name %> < ActiveRecord::Base
+end
+++ /dev/null
-require File.dirname(__FILE__) + '/../test_helper'
-
-class <%= class_name %>Test < Test::Unit::TestCase
- fixtures :<%= table_name %>
-
- # Replace this with your real tests.
- def test_truth
- assert true
- end
-end
--- /dev/null
+require File.dirname(__FILE__) + '/../test_helper'
+
+class <%= class_name %>Test < Test::Unit::TestCase
+ fixtures :<%= table_name %>
+
+ # Replace this with your real tests.
+ def test_truth
+ assert true
+ end
+end