/ gem

View formatted table columns using table_print gem

table_print Gem

It's an efficient way to view a list of structured data, making it easy to scan and compare across large swaths of records. It even lets you nest other tables of related objects, contextualizing data across tables. It’s incredibly flexible, yet simple, making it easy to see exactly the data you care about.

INSTALLATION:

To install the gem:

Add the following to your gemfile-

gem "table_print", "~> 1.0.0"

Then run:

$ bundle install 

USAGE:

Go to rails console:

$ rails c

Eg.

1) To view the entire table:

 tp Size.all

Will give the output:

ID | DESCRIPTION          | SHIPPING_MULTIPLIER                     | SIZE     
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
1  | 750ml                | 1.0                                     | 750ml    
2  | 375ml                | 1.0                                     | 375ml    
3  | 1L                   | 1.0                                     | 1L       
4  | 1.5L                 | 1.0                                     | 1.5L     
5  | 6L                   | 1.0                                     | 6L       
6  | 12L                  | 1.0                                     | 12L      
7  | 15L                  | 1.0                                     | 15L      
8  | 9L                   | 1.0                                     | 9L       
9  | 3L                   | 1.0                                     | 3L       
10 | 700ml                | 1.0                                     | 700ml    

2) To view few records:

 > tp Size.limit(5)

Output:

ID | DESCRIPTION          | SHIPPING_MULTIPLIER                     | SIZE 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
1  | 750ml                | 1.0                                     | 750ml 
2  | 375ml                | 1.0                                     | 375ml 
3  | 1L                   | 1.0                                     | 1L   
4  | 1.5L                 | 1.0                                     | 1.5L 
5  | 6L                   | 1.0                                     | 6L   

3) To view particular columns:

 > tp Size.limit(5), :description, :size

OUTPUT:

DESCRIPTION         | SIZE 
- - - - - - - - - - - - - - - - -
750ml               | 750ml 
375ml               | 375ml 
1L                  | 1L   
1.5L                | 1.5L 
6L                  | 6L   

4) Contextualization:

The most powerful feature of table_print is the ability to see your data in the context of other objects it relates to. You can reference nested objects with the method chain required to reach them. This example is showing data from different tables:

For eg.

 > tp Size.limit(5), :description, "bottles.name"
DESCRIPTION            | BOTTLES.NAME
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
1.5L                   | Krug Brut Grande Cuvee        
6L                     | Perrier Jouet Brut            
1.5L                   | Korbel Brut                   
1.5L                   | Kedem                         
6L                     | Kedem     

Check the three minute screencast [here(table print screencast)][1]

Check the doc [here(table print doc)][2]
[1]: http://tableprintgem.com/
[2]: https://github.com/arches/table_print