Rake (software)
Encyclopedia
Rake is a software task management tool. It allows you to specify tasks and describe dependencies as well as to group tasks in a namespace.
It is similar to SCons
and make, but has a number of differences. The tool is written in the Ruby programming language
, and the Rakefiles (equivalent of Makefiles in make) use Ruby syntax. It was originated by Jim Weirich.
Rake uses Ruby's anonymous function
blocks to define various tasks, allowing the use of the 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.
HelloWorld program.
file 'hello.o' => ['hello.c'] do
sh 'cc -c -o hello.o hello.c'
end
file 'hello' => ['hello.o'] do
sh 'cc -o hello hello.o'
end
Below is an example of a simple Rake recipe
namespace :cake do
desc 'make pancakes'
task :pancake => [:flour,:milk,:egg,:baking_powder] do
puts "sizzle"
end
task :butter do
puts "cut 3 tablespoons of butter into tiny squares"
end
task :flour => :butter do
puts "use hands to knead butter squares into 1 cup flour"
end
task :milk do
puts "add 1 cup milk"
end
task :egg do
puts "add 1 egg"
end
task :baking_powder do
puts "add 3 teaspoons baking powder"
end
end
Ruby on Rails Rake tutorial at railsenvy.com Custom Rake Tasks at railscasts.com Rake Tutorial at lukaszwrobel.pl
It is similar to SCons
SCons
SCons is a computer software construction tool that automatically analyzes source code file dependencies and operating system adaptation requirements from a software project description and generates final binary executables for installation on the target operating system platform...
and make, but has a number of differences. The tool is written in the Ruby programming language
Ruby (programming language)
Ruby is a dynamic, reflective, general-purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features. Ruby originated in Japan during the mid-1990s and was first developed and designed by Yukihiro "Matz" Matsumoto...
, and the Rakefiles (equivalent of Makefiles in make) use Ruby syntax. It was originated by Jim Weirich.
Rake uses Ruby's anonymous function
Anonymous function
In programming language theory, an anonymous function is a function defined, and possibly called, without being bound to an identifier. Anonymous functions are convenient to pass as an argument to a higher-order function and are ubiquitous in languages with first-class functions such as Haskell...
blocks to define various tasks, allowing the use of the 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.
Example
Below is an example of a simple Rake script to build a CC (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....
HelloWorld program.
file 'hello.o' => ['hello.c'] do
sh 'cc -c -o hello.o hello.c'
end
file 'hello' => ['hello.o'] do
sh 'cc -o hello hello.o'
end
Below is an example of a simple Rake recipe
namespace :cake do
desc 'make pancakes'
task :pancake => [:flour,:milk,:egg,:baking_powder] do
puts "sizzle"
end
task :butter do
puts "cut 3 tablespoons of butter into tiny squares"
end
task :flour => :butter do
puts "use hands to knead butter squares into 1 cup flour"
end
task :milk do
puts "add 1 cup milk"
end
task :egg do
puts "add 1 egg"
end
task :baking_powder do
puts "add 3 teaspoons baking powder"
end
end
External links
Rake documentation RubyForge project page for Rake Using the Rake build language by Martin FowlerMartin Fowler
-Online presentations:* at RailsConf 2006* at JAOO 2006* at QCon London 2007 * at QCon London 2008 * at ThoughtWorks Quarterly Technology Briefing, October 2008...
Ruby on Rails Rake tutorial at railsenvy.com Custom Rake Tasks at railscasts.com Rake Tutorial at lukaszwrobel.pl