Announcing Tabulo v1.2.1: terminal table generation gem



Tabulo is a gem for generating terminal tables (aka ASCII tables).

Key features differentiating it from many/most other terminal table generators:

  • The initialization interface is structured around building up the table column-by-column, rather than row-by-row. This makes for DRYer initialization code, since the ordering of the columns is expressed only once, rather than being duplicated within each row (and, in particular, between the header row and the body rows).
  • You can “shrinkwrap” the table so that it automatically sizes each column, but stops at a certain overall maximum width (which you usually want to be the width of your terminal). This is especially useful when outputting wide data sets that would otherwise become unreadable in virtue of wrapping around the terminal.
  • You can repeat the header row every N rows, which is handy when outputting a very large table.
  • A Tabulo::Table is an Enumerable object, so you can make an enumerator for it and then step through it “lazily” a row at a time. This can be useful when tabulating large, open-ended data sets such as some ActiveRecord queries, where you don’t want to load the entire underlying collection up front.
  • Column alignments have helpful type-based defaults: strings are left-aligned by default, numbers right.