jakubholynet edited this page Sep 20, 2011 · 5 revisions

How Runnables work

Teaching Redcar about every build system in existence would take a long time. Instead, Redcar can read simple json definitions of tasks, build targets and commands. In this way, Redcar can execute any command that can be executed in a console, excluding commands that require continuous input (coming soon!).

Running some Specs

The syntax of the command schemas looks like this:

      "name":        "gem",
      "command":     "/Users/danlucraft/Programs/jruby/bin/rake gem",
      "description": "Build the gem file redcar-0.3.8dev.gem",
      "type":        "task/ruby/rake",
      "output":      "none"
      "name":        "redcar/runnables",
      "command":     "/Users/danlucraft/Programs/jruby/bin/rake redcar:runnables",
      "description": "Redcar Integration: output runnable info",
      "type":        "task/ruby/rake"
      "regex":   ".*_spec.rb",
      "name":    "Run as spec",
      "command": "jruby -J-XstartOnFirstThread spec __PATH__",
      "type":    "test/ruby/spec"
      "regex":   ".*.feature",
      "name":    "Run as feature",
      "command": "cucumber __PATH__",
      "type":    "test/ruby/feature"
      "regex":   ".*.feature",
      "name":    "Run as feature",
      "command": "cucumber __PATH__:__LINE__",
      "type":    "test/ruby/feature"
      "regex":   ".*.rb",
      "name":    "Run as ruby",
      "command": "ruby __PATH__",
      "type":    "script/ruby"


  • output can be one of "tab" (default – opens in a new tab), "none", or "window"


Commands are predefined command line commands that Redcar will run in the default OS shell.

If you want to teach Redcar about your languages task or build system, you should write a program to emit json like this and put it into your-project-root/.redcar/runnables/whatever.json.

File Runners

File runners are mappings between file name types and command schemas, that allow you to tell Redcar to “Run a tab” and it will find the first matching file runner and execute based on it. To run the second matching file runner, use the “Alternate Run Tab” command. Two commands for running cucumber features are illustrated above


Runnables has a predefined variable for modifying command output:

__PARAMS__ : displays a prompt for the user to input text at the current position in a command.

Similarly, file runners can use the Runnables parameter, as well as variables specific to running files:

__PATH__ : replaced with the file path in the command
__NAME__ : replaced by the name of the current file in the command
__LINE__ : replaced by the cursor line number in the current file

Custom Commands

Arbitrary commands can be executed as a Runnable by choosing “Custom Command” from the Runnables tree.

Example Usage: How to run rake tasks in Redcar

In order to run rake tasks in Redcar you have to generate the appropriate runnables json for the rake tasks.

Copy this rake task into your project’s Rakefile (which should be in the root of your project’s tree) and run rake redcar:runnables. This should generate .redcar/runnables/*.json and then your rake tasks will appear in the Runnables tree of your project.

You will need to close the Runnables tree and reopen it for Redcar to pick up the changes.

namespace :redcar do
  def hash_with_hash_default {|h,k| h[k] = hash_with_hash_default }

  require 'json'

  desc "Redcar Integration: output runnable info"
  task :runnables do
    mkdir_p(".redcar/runnables")".redcar/runnables/sync_stdout.rb", "w") do |fout|
      fout.puts <<-RUBY
        $stdout.sync = true
        $stderr.sync = true

    tasks = Rake::Task.tasks
    runnables = []
    ruby_bin = Config::CONFIG["bindir"] + "/ruby -r#{File.dirname(__FILE__)}/.redcar/runnables/sync_stdout.rb "
    tasks.each do |task|
      name =":", "/")
      command = ruby_bin + $0 + " " +
      runnables << {
        "name"        => name,
        "command"     => command,
        "description" => task.comment,
        "type"        => "task/ruby/rake"
    end".redcar/runnables/rake.json", "w") do |f|
      data = {"commands" => runnables}
    end".redcar/runnables/ruby.json", "w") do |f|
      data = {"file_runners" =>
            "regex" =>    ".*.rb$",
            "name" =>     "Run as ruby",
            "command" =>  ruby_bin + "__PATH__",
            "type" =>     "script/ruby"


‹‹ Back to User's Guide

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.