Ruby build utility similar to make with build commands defined in pure Ruby.
Rake uses Rakefiles (cf. Makefiles) defined in pure Ruby, the build utility created by the late Jim Weirich. Rule patterns to synthesize implicit tasks are supported and developers can easily specify pre- and post-task dependency chains. Rake includes a library of pre-packaged tasks to make creating Rakefiles easier.
Rake uses Ruby's anonymous function blocks to define various tasks, allowing the use of Ruby syntax. It has a library of common tasks: for example, functions to do common file-manipulation tasks and a library to remove compiled files (the "clean" task). Like Make, Rake can also synthesize tasks based on patterns: for example, automatically building a file compilation task based on filename patterns. Rake is now part of the standard library from Ruby version 1.9 onward.
Sample Rake file
namespace :pick do
desc "Pick a random user as the winner"
task :winner => :environment do
puts "Winner: #{pick(User).name}"
end
desc "Pick a random product as the prize"
task :prize => :environment do
puts "Prize: #{pick(Product).name}"
end
desc "Pick a random prize and winner"
task :all => [:prize, :winner]
def pick(model_class)
model_class.find(:first, :order => 'RAND()')
end
end
Useful links
- Official Rake documentation
- Lukasz Wrobel's Rake tutorial
- Jason Seifer's Rake tutorial
- Github Link for Rake
Implementation specific tags
You can specify your question by adding the implementation you used as a tag.