diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-10-28 16:33:25 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-10-28 16:33:25 +0000 |
commit | 66bbc4f4e61a384a0bdb6aa0ba48f5641278db30 (patch) | |
tree | 7860f8baae114f34715ff382694f060d0a9bb0d2 | |
parent | d5e48ae7d278cb6e03bef104eac23ac5cad46c5a (diff) | |
download | rails-66bbc4f4e61a384a0bdb6aa0ba48f5641278db30.tar.gz rails-66bbc4f4e61a384a0bdb6aa0ba48f5641278db30.tar.bz2 rails-66bbc4f4e61a384a0bdb6aa0ba48f5641278db30.zip |
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
9 files changed, 53 insertions, 1 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG index b56a78f254..c3618cda0b 100644 --- a/railties/CHANGELOG +++ b/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] diff --git a/railties/lib/rails_generator/generators/applications/app/app_generator.rb b/railties/lib/rails_generator/generators/applications/app/app_generator.rb index 220262bf09..79bb808d7b 100644 --- a/railties/lib/rails_generator/generators/applications/app/app_generator.rb +++ b/railties/lib/rails_generator/generators/applications/app/app_generator.rb @@ -26,7 +26,6 @@ class AppGenerator < Rails::Generator::Base # Root m.file "fresh_rakefile", "Rakefile" m.file "README", "README" - m.file "CHANGELOG", "CHANGELOG" # Application m.template "helpers/application.rb", "app/controllers/application.rb" diff --git a/railties/lib/rails_generator/generators/components/plugin/USAGE b/railties/lib/rails_generator/generators/components/plugin/USAGE new file mode 100644 index 0000000000..55e35be595 --- /dev/null +++ b/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
\ No newline at end of file diff --git a/railties/lib/rails_generator/generators/components/plugin/plugin_generator.rb b/railties/lib/rails_generator/generators/components/plugin/plugin_generator.rb new file mode 100644 index 0000000000..2db7f98f8d --- /dev/null +++ b/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 diff --git a/railties/lib/rails_generator/generators/components/plugin/templates/README b/railties/lib/rails_generator/generators/components/plugin/templates/README new file mode 100644 index 0000000000..d727641340 --- /dev/null +++ b/railties/lib/rails_generator/generators/components/plugin/templates/README @@ -0,0 +1,4 @@ +<%= class_name %> +<%= "=" * class_name.size %> + +Description goes here
\ No newline at end of file diff --git a/railties/lib/rails_generator/generators/components/plugin/templates/init.rb b/railties/lib/rails_generator/generators/components/plugin/templates/init.rb new file mode 100644 index 0000000000..ada2eece96 --- /dev/null +++ b/railties/lib/rails_generator/generators/components/plugin/templates/init.rb @@ -0,0 +1 @@ +# Include hook code here
\ No newline at end of file diff --git a/railties/lib/rails_generator/generators/components/plugin/templates/plugin.rb b/railties/lib/rails_generator/generators/components/plugin/templates/plugin.rb new file mode 100644 index 0000000000..1fa5b9028f --- /dev/null +++ b/railties/lib/rails_generator/generators/components/plugin/templates/plugin.rb @@ -0,0 +1 @@ +# <%= class_name %>
\ No newline at end of file diff --git a/railties/lib/rails_generator/generators/components/plugin/templates/tasks.rake b/railties/lib/rails_generator/generators/components/plugin/templates/tasks.rake new file mode 100644 index 0000000000..5222b22c27 --- /dev/null +++ b/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
\ No newline at end of file diff --git a/railties/lib/rails_generator/generators/components/plugin/templates/unit_test.rb b/railties/lib/rails_generator/generators/components/plugin/templates/unit_test.rb new file mode 100644 index 0000000000..44e4b54c2e --- /dev/null +++ b/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 |