Description

Ruby Interactive Print Loop - A light, modular alternative to irb

Install

Install the gem with:

sudo gem install ripl

Features

  • Same as irb

    • Reads ~/.irbrc on startup

    • Appends to ~/.irb_history on exit

    • Autocompletion (from bond)

    • _ for last result

    • Type ‘exit’ or Ctrl-D to exit

    • Commandline options: -r, -I, -v

  • Enhancements over irb

    • ~/.irbrc errors caught

    • Provides hooks for plugins

    • Method argument and customizable autocompletion (from bond)

    • Less than 150 loc vs irb’s 5000+ loc

    • Simple configuration i.e. one hash

  • Different from irb

    • No multi-line evaluation

    • No irb subsessions or workspaces

    • No IRB.conf features i.e. dynamic prompts and auto indent

    • Most commandline options not supported

Philosophy

ripl is a light, flexible repl(shell) meant to lay the foundation for customizable ruby shells. It provides an environment for plugins to share and reuse best practices for shells. ripl can be easily customized for gems, applications and is even usable on the web (examples forthcoming).

Usage

$ ripl
>> ...

Create Custom Shells

Creating a custom shell is as simple as:

#!/usr/bin/env ruby

require 'ripl'
# Do whatever setup you want ...
Ripl.start

Ripl.start takes options to customize your shell. For example if you wanted to start on a specific binding:

Ripl.start :binding => my_desired_binding

Create Commands

If you want to invoke your custom shell with ripl, make it a ripl command. To create one, create an executable in the format ripl-<command> and make sure it’s in your shell’s $PATH. For example, the file ‘ripl-my_gem’ would be invoked with ‘ripl my_gem`. Note that with your command you can take arguments and parse your options as you please. For an example command, see ripl-rails.

Credits

  • janlelis for bug fix and tweaks

irb alternatives

Some other irb alternatives which I encourage you to check out:

  • ir: nice and light

  • irb2: yehuda katz’s partial attempt at rewriting irb

  • dietrb: mac and ruby 1.9 specific

Todo

  • Everything (tests especially)!