UtilsDrawer

Helper for drawing utils on CLI.

Description

UtilsDrawer will help to draw utils such as a table or graph.

Supporting the simple drawing by using Ruby's Block syntax.

Installation

Add this line to your application's Gemfile:

gem 'utils_drawer'

Usage

Table Drawer

Adjeust the column width at first row. The column width is 10 by the default. It is also possible to specify the column width in UtilsDrawer.column second argument.

require 'utils_drawer'

include UtilsDrawer

table do
  row do
    column('NAME')
    column('SCORE', 20)
    column('AGE')
  end
  row do
    column('kaihara')
    column('100,000,000')
    column('22')
  end
  row do
    column('hogefugahara')
    column('200,000,000')
    column('33')
  end
end

If the number of characters exceeds the column width, it is omitted.

table

If you want to change the column width of the default:

...

table(20) do
...
end

Graph Drawer

UtilsDrawer.data accepts the data label in the first argument, the value in the second argument. The value is the bar length. The color of the bar is determined by the bar length.

require 'utils_drawer'

include UtilsDrawer

graph do
  data('foo', 10)
  data('hoge', 17)
  data('nullpo', 0)
  data('nullnull', 0)
  data('nuller', 0)
  data('nullest', 0)
  data('bar', 7)
  data('fuga', 24)
end

Be omitted value is 0 to continue.

graph1

If you don't want to omit:

...

graph({ omission: false }) do
...
end

graph2