Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Sake: System-wide Rake Tasks

By Hendy Irawan / June 26, 2007

Sake is a RubyGem by Chris Wanstrath which executes and manages system-wide Rake tasks. Whereas Rake is project-specific, Sake allows the developer to examine, install, run, and uninstall Rake files and tasks globally, much like the way Rubygems does this for Ruby libraries.

Sake files are for the most part just regular Rake files:

namespace :db do
desc "Returns the current schema version"
task :version => :environment do
puts "Current version: " +
ActiveRecord::Migrator.current_version.to_s
end
end

desc "Show specs when testing"
task :spec do
ENV['TESTOPTS'] = '--runner=s'
Rake::Task[:test].invoke
end

Installing a task is easy:

$ sake -i err.rake spec
# Installing task `spec'
$ sake -T
sake spec   # Show specs when testing

You can combine Sake global tasks and project-specific Rake tasks, as Sake picks them up automatically.

Before reading Err's article on Sake, you might want to install it first:

gem install sake

About Hendy Irawan

Ruby programmer from Indonesia. View all posts by Hendy Irawan →

Other Posts to Enjoy

Twitter Mentions