Rails plugin that allows to override exisitng rake tasks
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
README
init.rb
install.rb

README

OverrideRakeTask plugin by Eugene Bolshakov, eugene.bolshakov@gmail.com, http://www.taknado.com

This plugin is based on the Matthew Bass's idea described here:
http://matthewbass.com/2007/03/07/overriding-existing-rake-tasks/

The installation script is based on the one found in the app_config plugin
by Daniel Owsianski, http://jarmark.org/projects/app-config/

When using rake with rails it loads tasks in the following order:

1. Default rails tasks (like db:migrate)
2. The tasks in your app's lib/tasks directory
3. The tasks in your vendor/plugins directory

This plugin allows to override and/or extend rake tasks that have been defined earlier. It means that 
you're able to override default rails tasks by putting new ones in lib/tasks and override tasks
defined in lib/tasks by new ones from plugins.

In order to override a task you need to define it using the "override_task" 
method instead of "task". You can also call the original (aliased) task inside the new one:

namespace :db do
  override_task :migrate do
    ...
    # To invoke the original task add ":original" to its name
    Rake::Task["db:migrate:original"].execute
    ...
  end
end

In order to make this work the plugin must be loaded before the tasks and the install script
supplied with the plugin adds a line to load itself to the Rakefile. If can't modify your Rakefile, 
it will let you know and you'll need to modify it manually.

Tested with: Rake 0.8.7, Rails 2.3.5
Doesn't seem to work with Rails 3

Contributors:

* John Wood http://github.com/jwood
* Mark Foster http://github.com/markwfoster