Project

dashes

0.0
No commit activity in last 3 years
No release in over 3 years
Format data into a dashboard of charts/tables on the command line.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

Description

Dashes formats data into a dashboard of charts/tables on the command line.

Installation

$ gem install dashes

Usage

Making a table:

> table = Dashes::Table.new
> table.align :left, :right, :right  # :center is available too
> table.row 'Label', 'Num', 'Pct'
> table.separator
> table.row 'First', 1, 2
> table.row 'Second', 3, 4
> puts table.to_s
+--------+-----+-----+
| Label  | Num | Pct |
+--------+-----+-----+
| First  |   1 |   2 |
| Second |   3 |   4 |
+--------+-----+-----+

Some display options for tables:

table.width(integer)
table.max_width(integer) # width takes priority
table.align(*alignments) # :left, :center, or :right
table.spacing(*spaces)   # :min or :max, :min means never pad the cell

Making a chart:

> chart = Dashes::Chart.new
> chart.title 'Title'
> chart.row 'First', 7
> chart.row 'Second', 12
> chart.row 'Third', 2
> puts chart.to_s
+---------------------+
| Title               |
+---------------------+
|  First =======      |
| Second ============ |
|  Third ==           |
+---------------------+

Some display options for charts:

chart.width(integer)
chart.max_width(integer) # width takes priority

Combine tables and charts into a grid:

> grid = Dashes::Grid.new
> grid.width(30) # 80 is the default , use `tput cols`.to_i for max width
> grid.add table1
> grid.add chart1
> grid.add table2
> grid.add table3
> puts grid.to_s
+---+---+---+ +-----------+
| 1 | 1 | 1 | |   a ===== |
| 1 | 1 | 1 | |  bb ===   |
| 1 | 1 | 1 | +-----------+
+---+---+---+ +-----------+
| 3 | 3 | 3 | | 2 | 2 | 2 |
+---+---+---+ +---+---+---+

Nodes (tables or charts) are added in a left-to-right, top-to-down order. The Grid class will fill in nodes as space allows.

Development

Tests are setup to run via ruby test/*_test.rb or via rake.

License

Copyright Hugh Bien - http://hughbien.com. Released under BSD License, see LICENSE.md for more info.