README.rdoc

README.rdoc

Last Update:
Wed Apr 14 13:55:21 -0400 2010

Description

Hirb provides a mini view framework for
console applications and uses it to improve irb’s default inspect
output. Given an object or array of objects, hirb renders a view based on
the object’s class and/or ancestry. Hirb offers reusable views in the form of
helper classes. The two main helpers, Hirb::Helpers::Table and Hirb::Helpers::Tree, provide
several options for generating ascii tables and trees. Using Hirb::Helpers::AutoTable,
hirb has useful default views for at least ten popular database gems i.e.
Rails’ ActiveRecord::Base. Other than views, hirb offers a smart
pager and a console menu. The smart pager only pages when the output
exceeds the current screen size. The menu is used in conjunction with
tables to offer two
dimensional menus.

From above you can see there are no views configured for a String or a
Symbol so Hirb defaults to irb’s
echo mode. On the other hand, Tag has a view thanks to being a descendant
of ActiveRecord::Base and there being an :ancestor option.

Having seen hirb display views based on an output object’s class,
let’s see it handle an array of objects:

Pager

Hirb has both pager and formatter
functionality enabled by default. If you want to turn off the functionality
of either you can pass that in at startup:

Hirb.enable :pager=>false
Hirb.enable :formatter=>false

or toggle their state at runtime:

Hirb::View.toggle_pager
Hirb::View.toggle_formatter

Sharing Helpers and Views

If you have tested helpers you’d like to share, fork Hirb and put them under lib/hirb/helpers.
To share views for certain classes, put them under lib/hirb/views. Please
submit views for gems that have a nontrivial number of users.

Limitations

If using Wirble, you should call Hirb
after it since they both override irb’s default output.