Friday, December 14, 2007

All About Rake

A build tool helps you build, compile, or other wise process files, sometimes large numbers of them. Rake is a build tool like make (http://www.gnu.org/software/make) and Apache ant (http://ant.apache.org), but it is written in Ruby. It is used by Ruby many applications, not just Rails. Rails operations use Rake frequently.

Rake uses a Rake file to figureout what to do . A Rake file contains named tasks.When you create a Rails project, a Rake- file is automatically created to help you deal with a variety of jobs, such as running tests and looking at project statistics. (After creating a Rails project, while in the main Rails project directory,run rake --tasks or rails stats to get a flavor of what Rake does.)

Rake was written by JimWeirich (http://onestepback.org). You’ll find documentation on Rake at http://rake.rubyforge.org. Additionally, you’ll find a good introduction to Rake, by Martin Fowler, at http://www.martinfowler.com/articles/rake.html.

Check to see whether Rake is present:
$ rake --version

rake, version 0.7.2

If this command fails, use RubyGems to install Rake, as shown in the previous section.

To run Rake help, type:
$ rake --help


Usage:

rake [-f rakefile] {options} targets...

Options:

--classic-namespace (-C)
Put Task and File Task in the top-level namespace.

--dry-run (-n)
Do a dry run without executing actions.

--help (-H)
Display this help message.

--libdir=LIBDIR (-I)
Include LIBDIR in the search path for required modules.

--nosearch (-N)
Do not search parent directories for the Rakefile.

--prereqs (-P)
Display the tasks and dependencies, then exit.

--quiet (-q)
Do not log messages to standard output.

--rakefile (-f)
UseFILE as the Rakefile.

--rakelibdir=RAKELIBDIR (-R)
Auto-import any .rake files in RAKELIBDIR (default is rakelib).

--require=MODULE (-r)
Require MODULE before executing Rakefile.

--silent (-s)
Like --quiet, but also suppresses the in directory announcement.

--tasks (-T)
Display the tasks (matching optional PATTERN) with descriptions, then exit.

--trace (-t)
Turn on invoke/execute tracing; enable full backtrace.

--usage (-h)
Display usage.

--verbose (-v)
Log message to standard output (default).

--version (-V)
Display the program version.


No comments: