mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Added that plugins can carry generators and that generator stub files can be created along with new plugins using script/generate plugin <name> --with-generator [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2797 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
7376da4a2c
commit
25410d53cf
6 changed files with 46 additions and 2 deletions
|
@ -1,5 +1,7 @@
|
|||
*SVN*
|
||||
|
||||
* Added that plugins can carry generators and that generator stub files can be created along with new plugins using script/generate plugin <name> --with-generator [DHH]
|
||||
|
||||
* Removed app/apis as a default empty dir since its automatically created when using script/generate web_service [DHH]
|
||||
|
||||
* Added script/plugin to manage plugins (install, remove, list, etc) [Ryan Tomayko]
|
||||
|
|
|
@ -7,6 +7,9 @@ Description:
|
|||
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.
|
||||
|
||||
It's also possible to generate stub files for a generator to go with the
|
||||
plugin by using --with-generator
|
||||
|
||||
Example:
|
||||
./script/generate plugin BrowserFilters
|
||||
|
||||
|
@ -15,4 +18,16 @@ Example:
|
|||
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
|
||||
vendor/plugins/browser_filters/tasks/browser_filters_tasks.rake
|
||||
|
||||
./script/generate plugin BrowserFilters --with-generator
|
||||
|
||||
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
|
||||
vendor/plugins/browser_filters/generators/browser_filters/browser_filters_generator.rb
|
||||
vendor/plugins/browser_filters/generators/browser_filters/USAGE
|
||||
vendor/plugins/browser_filters/generators/browser_filters/templates/
|
|
@ -1,7 +1,8 @@
|
|||
class PluginGenerator < Rails::Generator::NamedBase
|
||||
attr_reader :plugin_path
|
||||
|
||||
def initialize(*args)
|
||||
def initialize(runtime_args, runtime_options = {})
|
||||
@with_generator = runtime_args.delete("--with-generator")
|
||||
super
|
||||
@plugin_path = "vendor/plugins/#{file_name}"
|
||||
end
|
||||
|
@ -18,6 +19,15 @@ class PluginGenerator < Rails::Generator::NamedBase
|
|||
m.template 'plugin.rb', "#{plugin_path}/lib/#{file_name}.rb"
|
||||
m.template 'tasks.rake', "#{plugin_path}/tasks/#{file_name}_tasks.rake"
|
||||
m.template 'unit_test.rb', "#{plugin_path}/test/#{file_name}_test.rb"
|
||||
|
||||
if @with_generator
|
||||
m.directory "#{plugin_path}/generators"
|
||||
m.directory "#{plugin_path}/generators/#{file_name}"
|
||||
m.directory "#{plugin_path}/generators/#{file_name}/templates"
|
||||
|
||||
m.template 'generator.rb', "#{plugin_path}/generators/#{file_name}/#{file_name}_generator.rb"
|
||||
m.template 'USAGE', "#{plugin_path}/generators/#{file_name}/USAGE"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
Description:
|
||||
Explain the generator
|
||||
|
||||
Example:
|
||||
./script/generate <%= file_name %> Thing
|
||||
|
||||
This will create:
|
||||
what/will/it/create
|
|
@ -0,0 +1,8 @@
|
|||
class <%= class_name %>Generator < Rails::Generator::NamedBase
|
||||
def manifest
|
||||
record do |m|
|
||||
# m.directory "lib"
|
||||
# m.template 'README', "README"
|
||||
end
|
||||
end
|
||||
end
|
|
@ -99,6 +99,7 @@ module Rails
|
|||
def use_component_sources!
|
||||
reset_sources
|
||||
sources << PathSource.new(:app, "#{::RAILS_ROOT}/lib/generators") if defined? ::RAILS_ROOT
|
||||
sources << PathSource.new(:plugins, "#{::RAILS_ROOT}/vendor/plugins/**/generators") if defined? ::RAILS_ROOT
|
||||
sources << PathSource.new(:user, "#{Dir.user_home}/.rails/generators")
|
||||
sources << GemSource.new if Object.const_defined?(:Gem)
|
||||
sources << PathSource.new(:builtin, "#{File.dirname(__FILE__)}/generators/components")
|
||||
|
|
Loading…
Reference in a new issue