module Rails::Generators::Actions

def plugin(name, options)


plugin 'restful-authentication', :svn => 'svn://svnhub.com/technoweenie/restful-authentication/trunk', :revision => 1234
plugin 'restful-authentication', :svn => 'svn://svnhub.com/technoweenie/restful-authentication/trunk'
plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git', :submodule => true
plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git', :branch => 'stable'
plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git'

==== Examples

For a Subversion-hosted plugin you can specify a revision.

whether it should be added as a submodule instead of cloned.
For a Git-hosted plugin, you can specify a branch and

Install a plugin. You must provide either a Subversion url or Git url.
def plugin(name, options)
  log :plugin, name
  if options[:git] && options[:submodule]
    options[:git] = "-b #{options[:branch]} #{options[:git]}" if options[:branch]
    in_root do
      run "git submodule add #{options[:git]} vendor/plugins/#{name}", :verbose => false
    end
  elsif options[:git] || options[:svn]
    options[:git] = "-b #{options[:branch]} #{options[:git]}"   if options[:branch]
    options[:svn] = "-r #{options[:revision]} #{options[:svn]}" if options[:revision]
    in_root do
      run_ruby_script "script/rails plugin install #{options[:svn] || options[:git]}", :verbose => false
    end
  else
    log "! no git or svn provided for #{name}. Skipping..."
  end
end