In Files

  • rake/alt_system.rb
  • rake/application.rb
  • rake/backtrace.rb
  • rake/cloneable.rb
  • rake/contrib/compositepublisher.rb
  • rake/contrib/ftptools.rb
  • rake/contrib/rubyforgepublisher.rb
  • rake/contrib/sshpublisher.rb
  • rake/default_loader.rb
  • rake/dsl_definition.rb
  • rake/early_time.rb
  • rake/ext/module.rb
  • rake/ext/time.rb
  • rake/file_creation_task.rb
  • rake/file_list.rb
  • rake/file_task.rb
  • rake/file_utils.rb
  • rake/file_utils_ext.rb
  • rake/gempackagetask.rb
  • rake/invocation_chain.rb
  • rake/invocation_exception_mixin.rb
  • rake/loaders/makefile.rb
  • rake/multi_task.rb
  • rake/name_space.rb
  • rake/packagetask.rb
  • rake/phony.rb
  • rake/private_reader.rb
  • rake/promise.rb
  • rake/pseudo_status.rb
  • rake/rake_module.rb
  • rake/rdoctask.rb
  • rake/rule_recursion_overflow_error.rb
  • rake/runtest.rb
  • rake/task.rb
  • rake/task_argument_error.rb
  • rake/task_arguments.rb
  • rake/task_manager.rb
  • rake/tasklib.rb
  • rake/testtask.rb
  • rake/thread_history_display.rb
  • rake/thread_pool.rb
  • rake/trace_output.rb
  • rake/version.rb
  • rake/win32.rb

Rake

RAKE – Ruby Make

This package contains Rake, a simple ruby build program with capabilities similar to make.

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 => [: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.

More Information

Development

Source Repository

Rake is currently hosted at github. The github web page is github.com/jimweirich/rake. The public git clone URL is

  • git://github.com/jimweirich/rake.git

Running the Rake Test Suite

If you wish to run the unit and functional tests that come with Rake:

  • Install the ‘flexmock’ gem

  • Install the ‘session’ gem in order to run the functional tests.

  • CD into the top project directory of rake.

  • Type one of the following:

    rake                  # If you have a version of rake installed
    ruby -Ilib bin/rake   # If you do not have a version of rake installed.

Issues and Bug Reports

Feature requests and bug reports can be made here

Issues and bug reports can also be tracked here:

Online Resources

Rake References

Presentations and Articles about Rake

Other Make Reinvisionings …

Rake is a late entry in the make replacement field. Here are links to other projects with similar (and not so similar) goals.

Credits

Ryan Dlugosz

For the initial conversation that sparked Rake.

nobu.nokada@softhome.net

For the initial patch for rule support.

Tilman Sauerbeck <tilman@code-monkey.de>

For the recursive rule patch.

Eric Hodel

For aid in maintaining rake.

License

Rake is available under an MIT-style license.

See MIT-LICENSE for permissions.

Support

The Rake homepage is rake.rubyforge.org. You can find the Rake RubyForge page at rubyforge.org/projects/rake.

Feel free to submit commits or feature requests. If you send a patch, remember to update the corresponding unit tests. In fact, I prefer new feature to be submitted in the form of new unit tests.

For other information, feel free to ask on the ruby-talk mailing list (which is mirrored to comp.lang.ruby) or contact jim dot weirich at gmail.com.


Other stuff

Author

Jim Weirich <jim.weirich@gmail.com>

Requires

Ruby 1.8.6 or later

License

Copyright 2003-2011 by 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 merchantibility and fitness for a particular purpose.

Public Class Methods

add_rakelib(*files) click to toggle source

Add files to the rakelib list

 
               # File rake/rake_module.rb, line 29
def add_rakelib(*files)
  application.options.rakelib ||= []
  files.each do |file|
    application.options.rakelib << file
  end
end
            
application() click to toggle source

Current Rake Application

 
               # File rake/rake_module.rb, line 9
def application
  @application ||= Rake::Application.new
end
            
application=(app) click to toggle source

Set the current Rake application object.

 
               # File rake/rake_module.rb, line 14
def application=(app)
  @application = app
end
            
load_rakefile(path) click to toggle source

Load a rakefile.

 
               # File rake/rake_module.rb, line 24
def load_rakefile(path)
  load(path)
end
            
original_dir() click to toggle source

Return the original directory where the Rake application was started.

 
               # File rake/rake_module.rb, line 19
def original_dir
  application.original_dir
end
            

Public Instance Methods

run_tests(pattern='test/test*.rb', log_enabled=false) click to toggle source
 
               # File rake/runtest.rb, line 8
def run_tests(pattern='test/test*.rb', log_enabled=false)
  FileList.glob(pattern).each { |fn|
    $stderr.puts fn if log_enabled
    begin
      require fn
    rescue Exception => ex
      $stderr.puts "Error in #{fn}: #{ex.message}"
      $stderr.puts ex.backtrace
      assert false
    end
  }
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please see Improve the docs, or visit Documenting-ruby.org.

blog comments powered by Disqus