RAKE – Ruby Make
Description
Rake is a Make-like program implemented in Ruby. Tasks and dependencies are specified in standard Ruby syntax.
Rake has the following features:
-
Rakefiles (rake’s version of Makefiles) are completely defined in standard Ruby syntax. No XML files to edit. No quirky Makefile syntax to worry about (is that a tab or a space?)
-
Users can specify tasks with prerequisites.
-
Rake supports rule patterns to synthesize implicit tasks.
-
Flexible FileLists that act like arrays but know about manipulating file names and paths.
-
A library of prepackaged tasks to make building rakefiles easier. For example, tasks for building tarballs and publishing to FTP or SSH sites. (Formerly tasks for building RDoc and Gems were included in rake but they’re now available in RDoc and RubyGems respectively.)
-
Supports parallel execution of tasks.
Installation
Gem Installation
Download and install rake with the following.
gem install rake
Usage
Simple Example
First, you must write a “Rakefile” file which contains the build rules. Here’s a simple example:
task default: %w[test]
task :test do
ruby "test/unittest.rb"
end
This Rakefile has two tasks:
-
A task named “test”, which – upon invocation – will run a unit test file in Ruby.
-
A task named “default”. This task does nothing by itself, but it has exactly one dependency, namely the “test” task. Invoking the “default” task will cause Rake to invoke the “test” task as well.
Running the “rake” command without any options will cause it to run the “default” task in the Rakefile:
% ls
Rakefile test/
% rake
(in /home/some_user/Projects/rake)
ruby test/unittest.rb
....unit test output here...
Type “rake –help” for all available options.
Resources
Rake Information
-
The original Rake announcement
-
Rake glossary
Presentations and Articles about Rake
-
Avdi Grimm’s rake series:
-
Jim Weirich’s 2003 RubyConf presentation: onestepback.org/articles/buildingwithrake/
-
Martin Fowler’s article on Rake: martinfowler.com/articles/rake.html
Other Make Re-envisionings …
Rake is a late entry in the make replacement field. Here are links to other projects with similar (and not so similar) goals.
-
directory.fsf.org/bras.html – Bras, one of earliest implementations of “make in a scripting language”.
-
www.a-a-p.org – Make in Python
-
www.aromatic.com/tools/jam.txt – JAM, Java Automated Make
-
ant.apache.org – The Ant project
-
search.cpan.org/search?query=PerlBuildSystem – The Perl Build System
-
rubydoc.info/gems/rant/0.5.7/frames – Rant, another Ruby make tool.
Credits
- Ryan Dlugosz
-
For the initial conversation that sparked Rake.
- [email protected]
-
For the initial patch for rule support.
- Tilman Sauerbeck <[email protected]>
-
For the recursive rule patch.
- Eric Hodel
-
For aid in maintaining rake.
License
Rake is available under an MIT-style license.
:include: MIT-LICENSE
Other stuff
- Author
-
Jim Weirich <[email protected]>
- Requires
-
Ruby 1.8.7 or later
- License
-
Copyright Jim Weirich. Released under an MIT-style license. See the MIT-LICENSE file included in the distribution.
Warranty
This software is provided “as is” and without any express or implied warranties, including, without limitation, the implied warranties of merchantability and fitness for a particular purpose.