Wirb Interactive Ruby

Wirb colorizes your inspected Ruby objects. It is based on Wirble, but only provides and improves result highlighting. It also provides a colorization engine abstraction layer and offers flexible schemas using yaml. Wirb is part of the irbtools suite.

Supported Rubies: 2.1, 2.0, 1.9, 1.8, jruby, rubinius

Install

Install the gem with:

gem install wirb

Usage

Add to your ~/.irbrc

require 'wirb'
Wirb.start

Features

  • Syntax highlighting for Ruby objects

  • Does not change the inspect method

  • Support for generic objects, especially sets and enumerators and nesting more generic objects

  • Funny looking test suite

  • Can be used without irb

  • Limited stdlib/gem objects support (e.g. Set, Gem::Requirement)

  • Usable with any supported terminal colors engine

  • Color schemas in yaml files

wp

You can colorize any object with wp (wavy_print):

require 'wirb/wp'
wp some_object

Colors

To only tweak some colors, take a look at the Wirb.schema hash. To use a custom schema, inspect the yaml files in the data/wirb/ directory. You can create your own schema and load it using Wirb.load_schema(path_to_yaml_file). Alternatively, you can use one of the bundled ones by passing a symbol instead of a path.

Colorizer

Wirb supports multiple colorization engines. Available engines can be found in lib/wirb/colorizer/*. Some of them require external gems as dependencies (e.g. HighLine). The current default engine is Paint. You can change the colorizer using:

Wirb.load_colorizer :Paint # or :HighLine or whatever

Be careful, though! You also need to select a color schema that supports your colorizer (Schemas define supported colorizers using the :colorizer key). Load a schema with:

Wirb.load_schema! :classic_paint # make sure your colorizer is paint

You can automatically use the first colorizer of the schema by using the non-exclamation mark version:

Wirb.load_schema :classic_paint # will fail if paint is not installed

Color schemas wanted! You've got a good looking alternative color schema? Please fork and add it to data/wirb/* :)

Colorizers wanted! Your favorite terminal colors gem is not supported yet? Please fork and add it to lib/wirb/colorizer/* :D

Bundled schemas

The following schemas are bundled (load with Wirb.load_schema :name and make sure the used colorizer is available).

  • :classic_paint (paint implementation of default)

  • :colorless (only uses :bright, :underline and :inverse effect)

  • :classic_wirb0 (default implemented with wirb0)

Also see

  • Configure views for specific objects: hirb

  • Wirb is part of: irbtools

  • ripl is an irb alternative, syntax highlighting plugin (uses wirb by default): ripl-color_result

  • Advanced terminal color gems: Paint, HighLine

Credits

Copyright © 2011-2014 Jan Lelis <janlelis.de>, see COPYING for details.

Influenced by code from and thanks to: Copyright (C) 2006-2009 Paul Duncan <pabs@pablotron.org>

Contributions by and thanks to: Richard LeBer