Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added plugin generator to create a stub structure for a new plugin in…

… vendor/plugins (see "script/generate plugin" for help) [DHH]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2784 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 66bbc4f4e61a384a0bdb6aa0ba48f5641278db30 1 parent d5e48ae
@dhh dhh authored
View
2  railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Added plugin generator to create a stub structure for a new plugin in vendor/plugins (see "script/generate plugin" for help) [DHH]
+
* Added app/services as a default dir in the Rails skeleton and to the load path. Use it to keep classes like MaintenanceService and PaymentGateway [DHH]
* Fixed scaffold generator when started with only 1 parameter #2609 [self@mattmower.com]
View
1  railties/lib/rails_generator/generators/applications/app/app_generator.rb
@@ -26,7 +26,6 @@ def manifest
# Root
m.file "fresh_rakefile", "Rakefile"
m.file "README", "README"
- m.file "CHANGELOG", "CHANGELOG"
# Application
m.template "helpers/application.rb", "app/controllers/application.rb"
View
18 railties/lib/rails_generator/generators/components/plugin/USAGE
@@ -0,0 +1,18 @@
+Description:
+ The plugin generator creates stubs for a new plugin.
+
+ The generator takes a plugin name as its argument. The plugin name may be
+ given in CamelCase or under_score and should not be suffixed with 'Plugin'.
+
+ The generator creates a plugin directory in vendor/plugins that includes
+ both init.rb and README files as well as lib, task, and test directories.
+
+Example:
+ ./script/generate plugin BrowserFilters
+
+ This will create:
+ vendor/plugins/browser_filters/README
+ vendor/plugins/browser_filters/init.rb
+ vendor/plugins/browser_filters/lib/browser_filters.rb
+ vendor/plugins/browser_filters/test/browser_filters_test.rb
+ vendor/plugins/browser_filters/tasks/browser_filters_tasks.rake
View
17 railties/lib/rails_generator/generators/components/plugin/plugin_generator.rb
@@ -0,0 +1,17 @@
+class PluginGenerator < Rails::Generator::NamedBase
+ def manifest
+ record do |m|
+ m.directory File.join('vendor', 'plugins', file_name)
+ m.directory File.join('vendor', 'plugins', file_name, 'lib')
+ m.directory File.join('vendor', 'plugins', file_name, 'test')
+ m.directory File.join('vendor', 'plugins', file_name, 'tasks')
+
+ m.template 'plugin.rb', File.join('vendor', 'plugins', file_name, 'lib', "#{file_name}.rb")
+ m.template 'unit_test.rb', File.join('vendor', 'plugins', file_name, 'test', "#{file_name}_test.rb")
+
+ m.template 'init.rb', File.join('vendor', 'plugins', file_name, 'init.rb')
+ m.template 'tasks.rake', File.join('vendor', 'plugins', file_name, 'tasks', "#{file_name}_tasks.rake")
+ m.template 'README', File.join('vendor', 'plugins', file_name, 'README')
+ end
+ end
+end
View
4 railties/lib/rails_generator/generators/components/plugin/templates/README
@@ -0,0 +1,4 @@
+<%= class_name %>
+<%= "=" * class_name.size %>
+
+Description goes here
View
1  railties/lib/rails_generator/generators/components/plugin/templates/init.rb
@@ -0,0 +1 @@
+# Include hook code here
View
1  railties/lib/rails_generator/generators/components/plugin/templates/plugin.rb
@@ -0,0 +1 @@
+# <%= class_name %>
View
4 railties/lib/rails_generator/generators/components/plugin/templates/tasks.rake
@@ -0,0 +1,4 @@
+# desc "Explaining what the task does"
+# task :<%= file_name %> do
+# # Task goes here
+# end
View
6 railties/lib/rails_generator/generators/components/plugin/templates/unit_test.rb
@@ -0,0 +1,6 @@
+class <%= class_name %>Test < Test::Unit::TestCase
+ # Replace this with your real tests.
+ def test_truth
+ assert true
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.