]> source.dussan.org Git - redmine.git/commitdiff
Renames template ruby files to erb.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 25 Oct 2008 09:35:51 +0000 (09:35 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 25 Oct 2008 09:35:51 +0000 (09:35 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@1951 e93f8b46-1217-0410-a6f0-8f06a7374b81

14 files changed:
lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb
lib/generators/redmine_plugin_controller/templates/controller.rb [deleted file]
lib/generators/redmine_plugin_controller/templates/controller.rb.erb [new file with mode: 0644]
lib/generators/redmine_plugin_controller/templates/functional_test.rb [deleted file]
lib/generators/redmine_plugin_controller/templates/functional_test.rb.erb [new file with mode: 0644]
lib/generators/redmine_plugin_controller/templates/helper.rb [deleted file]
lib/generators/redmine_plugin_controller/templates/helper.rb.erb [new file with mode: 0644]
lib/generators/redmine_plugin_model/redmine_plugin_model_generator.rb
lib/generators/redmine_plugin_model/templates/migration.rb [deleted file]
lib/generators/redmine_plugin_model/templates/migration.rb.erb [new file with mode: 0644]
lib/generators/redmine_plugin_model/templates/model.rb [deleted file]
lib/generators/redmine_plugin_model/templates/model.rb.erb [new file with mode: 0644]
lib/generators/redmine_plugin_model/templates/unit_test.rb [deleted file]
lib/generators/redmine_plugin_model/templates/unit_test.rb.erb [new file with mode: 0644]

index 533d65ce890172fafbdf6b8692e0efdf2a1646d7..efe28c5da0d794edd8a835d6940da1e1e7e2fc13 100644 (file)
@@ -15,4 +15,40 @@ class RedminePluginControllerGenerator < ControllerGenerator
   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
diff --git a/lib/generators/redmine_plugin_controller/templates/controller.rb b/lib/generators/redmine_plugin_controller/templates/controller.rb
deleted file mode 100644 (file)
index 615986d..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-class <%= class_name %>Controller < ApplicationController
-<% actions.each do |action| -%>
-
-  def <%= action %>
-  end
-<% end -%>
-end
diff --git a/lib/generators/redmine_plugin_controller/templates/controller.rb.erb b/lib/generators/redmine_plugin_controller/templates/controller.rb.erb
new file mode 100644 (file)
index 0000000..615986d
--- /dev/null
@@ -0,0 +1,7 @@
+class <%= class_name %>Controller < ApplicationController
+<% actions.each do |action| -%>
+
+  def <%= action %>
+  end
+<% end -%>
+end
diff --git a/lib/generators/redmine_plugin_controller/templates/functional_test.rb b/lib/generators/redmine_plugin_controller/templates/functional_test.rb
deleted file mode 100644 (file)
index 876bd79..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-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
diff --git a/lib/generators/redmine_plugin_controller/templates/functional_test.rb.erb b/lib/generators/redmine_plugin_controller/templates/functional_test.rb.erb
new file mode 100644 (file)
index 0000000..876bd79
--- /dev/null
@@ -0,0 +1,8 @@
+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
diff --git a/lib/generators/redmine_plugin_controller/templates/helper.rb b/lib/generators/redmine_plugin_controller/templates/helper.rb
deleted file mode 100644 (file)
index 3fe2ecd..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-module <%= class_name %>Helper
-end
diff --git a/lib/generators/redmine_plugin_controller/templates/helper.rb.erb b/lib/generators/redmine_plugin_controller/templates/helper.rb.erb
new file mode 100644 (file)
index 0000000..3fe2ecd
--- /dev/null
@@ -0,0 +1,2 @@
+module <%= class_name %>Helper
+end
index b712d9b0750eb9992977fd4612979335534a6334..059a028d60755eea9c90a9eb64c77d899630a9a0 100644 (file)
@@ -15,4 +15,30 @@ class RedminePluginModelGenerator < ModelGenerator
   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
diff --git a/lib/generators/redmine_plugin_model/templates/migration.rb b/lib/generators/redmine_plugin_model/templates/migration.rb
deleted file mode 100644 (file)
index 2a305a6..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-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
diff --git a/lib/generators/redmine_plugin_model/templates/migration.rb.erb b/lib/generators/redmine_plugin_model/templates/migration.rb.erb
new file mode 100644 (file)
index 0000000..2a305a6
--- /dev/null
@@ -0,0 +1,13 @@
+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
diff --git a/lib/generators/redmine_plugin_model/templates/model.rb b/lib/generators/redmine_plugin_model/templates/model.rb
deleted file mode 100644 (file)
index 8d4c89e..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-class <%= class_name %> < ActiveRecord::Base
-end
diff --git a/lib/generators/redmine_plugin_model/templates/model.rb.erb b/lib/generators/redmine_plugin_model/templates/model.rb.erb
new file mode 100644 (file)
index 0000000..8d4c89e
--- /dev/null
@@ -0,0 +1,2 @@
+class <%= class_name %> < ActiveRecord::Base
+end
diff --git a/lib/generators/redmine_plugin_model/templates/unit_test.rb b/lib/generators/redmine_plugin_model/templates/unit_test.rb
deleted file mode 100644 (file)
index cc8b2e5..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-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
diff --git a/lib/generators/redmine_plugin_model/templates/unit_test.rb.erb b/lib/generators/redmine_plugin_model/templates/unit_test.rb.erb
new file mode 100644 (file)
index 0000000..cc8b2e5
--- /dev/null
@@ -0,0 +1,10 @@
+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