提交 66bbc4f4 编写于 作者: D David Heinemeier Hansson

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

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
上级 d5e48ae7
*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]
......
......@@ -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"
......
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
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
<%= class_name %>
<%= "=" * class_name.size %>
Description goes here
\ No newline at end of file
# desc "Explaining what the task does"
# task :<%= file_name %> do
# # Task goes here
# end
\ No newline at end of file
class <%= class_name %>Test < Test::Unit::TestCase
# Replace this with your real tests.
def test_truth
assert true
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册