/wirb

wavy interactive ruby (because colors are great)

Primary LanguageRubyMIT LicenseMIT

Wavy 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.

Travis:

Install

Install the gem with:

gem install wirb

Usage

Add to your ~/.irbrc

require 'rubygems' unless defined? Gem
require 'wirb'
Wirb.start

Features

  • Syntax highlighting for Ruby objects

  • Does not change the inspect value

  • Support for generic objects, especially sets and enumerators

  • Comes with tests

  • Can be used without irb

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

  • Supports 1.8, 1.9, jruby, rbx, head

  • Usable with any supported terminal colors engine

  • Color schemas in yaml files

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 Wirb0 (the one of previous Wirb versions, inherited from the original Wirble). It will be dropped as default engine in 1.0 (later this year), because it uses wrong color names. It will be replaced by Paint or a simple colorizer engine with proper color names. 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).

Wirb0

  • :classic_wirb0 (current default)

Paint

  • :classic_paint (paint implementation of default)

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

You can colorize any object with wp (wavy_print):

require 'wirb/wp'
wp some_object

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

Todo

  • Tests for schema stuff

  • More colorizers and themes

  • More support for stdlib (most important: Complex)

Credits

  • Copyright © 2011 Jan Lelis <rbjl.net>, see COPYING for details.

Contributions by and thanks to:

Influenced by code from and thanks to:

  • Copyright © 2006-2009 Paul Duncan <pabs@pablotron.org>

J-_-L