Rap (Rakish App)

rap v. a quick, sharp knock or blow
rak.ish adj. having a dashing, jaunty, or slightly disreputable quality or appearance

A rakish extension to Tap.


Rap supercharges the syntax of Rake by adding configurations, extended documentation, and class-based tasks that are easy to test.

Rap is a part of the Tap-Suite. Check out these links for documentation, development, and bug tracking.


Usage is much like Rake:


# :: your basic goodnight moon task
# Says goodnight with a configurable message.
Rap.task(:goodnight, :obj, :message => 'goodnight') do |task, args|
  puts "#{task.message} #{args.obj}\n"

Now from the command line:

% rap goodnight moon
goodnight moon

% rap goodnight world --message hello
hello world

% rap goodnight --help
Goodnight -- your basic goodnight moon task
  Says goodnight with a configurable message.
usage: tap run -- goodnight OBJ

        --message MESSAGE

        --help                       Print this help
        --name NAME                  Specifies the task name
        --config FILE                Specifies a config file

For testing, load the Rapfile and access the task as a constant.

require 'rap'
load 'Rapfile'
require 'test/unit'
require 'stringio'

class RapfileTest < Test::Unit::TestCase
  def test_the_goodnight_task
    $stdout = StringIO.new

    task = Goodnight.new
    assert_equal 'goodnight', task.message

    assert_equal "goodnight moon", $stdout.string

The test passes:

% ruby test.rb
Loaded suite test
Finished in 0.004921 seconds.

1 tests, 2 assertions, 0 failures, 0 errors

Generally speaking, the rap executable is a shorthand for 'tap run –' so you can use rap to launch workflows as well.


Rap is not a pure replacement of Rake, nor do the Rap tasks behave exactly like standard Tap tasks.

Regarding Rake:

  • Rap does not support builds by default

  • Classes like FileList are not available

  • Namespace lookup is slightly different (see the Syntax Reference)

That said, many rakefiles can be renamed as rapfiles and they'll work with minor and sometimes no changes.

Regarding Tap

Rap tasks (ie subclasses of Rap::Task) are designed to behave like Rake tasks. As such Rap tasks:

  • return nil and pass nil in workflows

  • only execute once

  • are effectively singletons

This makes rap tasks useful in dependency-based workflows but fairly useless in imperative workflows. However, other tasks behave as normal and any workflow you can run with 'tap run' can be run without alteration by rap.


Rap is available as a gem on Gemcutter.

% gem install rap



Simon Chiang