table_print 1.5.3 → 1.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NjkzNmMxZmM1NWY0ZGU2MjQzNGM5MzMyZTQwNmEwZTk2ZjYzMjlkMA==
5
- data.tar.gz: !binary |-
6
- MzIyMzFmODY2M2Q1ZWE4MGRlMTU4NGU5OWRhNmQxNzU5OThiYjMzNA==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- OTEzNDUyMjA4NWZjZTIyMTk3NTU3ODI5YmU3N2Q0NzY4MTcwYTFjZTNiMDUx
10
- ZTNhN2E2MzEyODJiMGVkMDgwOGMxOGIwZjRiMDBhNTM0ZDMwZTgyMWY2MWM0
11
- YTBmNGQ5MjY2N2Q4YjY4OTQxMDRlNTNiMDJmODhhMmE1OTJlNzM=
12
- data.tar.gz: !binary |-
13
- ZmZhMmVmMGJlMmQ1MTA2NGM0MjgxNjE3MTkxMWJiZTg5MzdlOTBmN2FmOTUz
14
- YjA5OWNlODE3ZmU5N2JhNzQ2NzE4OWYxMTY2ZjYzOGVlM2Y1ZTAzZDdjN2Mw
15
- YzZjNDVjNzQzMWI0OGViOGU1MmEwODY4MTJmYWViZmI4MDc0OGI=
2
+ SHA1:
3
+ metadata.gz: 9640d93b07847eee78c007820b94ab7b5e8a7aea
4
+ data.tar.gz: f6d2a835d026daba780157e4b1ee41bfc532e244
5
+ SHA512:
6
+ metadata.gz: d0e22e56b6653bb744541a93075d3183f926580ca0c254b1838ddcf1085d38f4a508f4194af1aa419c39c86505116fbad6d3071240fcc24c5b3734e52230b790
7
+ data.tar.gz: 552909c7c725776da8c02e906accbbc4ce7278c9fcdd535bdb78a60be882672a4b47f11a01d08c31359f08a2809c86e0525714b3e247ca77bee1558243108f23
@@ -15,8 +15,8 @@ powerful features and how to use them.
15
15
  # Install as a standalone gem
16
16
  $ gem install table_print
17
17
 
18
- # Install within rails
19
- In your Gemfile: gem "table_print", "~> 1.0.0"
18
+ # Or install within rails
19
+ In your Gemfile: gem "table_print"
20
20
  $ bundle install
21
21
 
22
22
  == Usage
@@ -36,7 +36,7 @@ You should see something like this:
36
36
  AUTHOR | SUMMARY | TITLE
37
37
  ------------------|---------------------------------|------------------
38
38
  Michael Connelly | Another book by Michael Con... | The Fifth Witness
39
- Manning Mardale | From acclaimed historian Ma... | Malcolm X
39
+ Manning Marable | From acclaimed historian Ma... | Malcolm X
40
40
  Tina Fey | Worth it. -Trees | Bossypants
41
41
 
42
42
  TablePrint tries to use sensible defaults to choose the columns to show. If you're inspecting ActiveRecord objects, it
@@ -97,12 +97,16 @@ Columns are named after hash keys. To rename a column, use the name you want as
97
97
 
98
98
  You can pass a proc as the display_method for a column:
99
99
 
100
- tp User.all, :email, :monthly_payment, :yearly_payment => lambda{|u| u.monthly_payment * 12}
100
+ tp User.all, :email, :monthly_payment, yearly_payment: lambda{|u| u.monthly_payment * 12}
101
101
 
102
102
  Or if you want to pass other options along with the lambda:
103
103
 
104
104
  tp User.all, :yearly_payment => {:display_method => lambda{|u| u.monthly_payment * 12}, :width => 10}
105
105
 
106
+ Make sure to add curly braces if you have more than one column with a lambda or if this column isn't the last one.
107
+
108
+ tp User.all, :email, { daily_payment: lambda { |u| u.monthly_payment / 30} }, :monthly_payment, { yearly_payment: lambda { |u| u.monthly_payment * 12} }
109
+
106
110
  ==== Column formatters
107
111
 
108
112
  Similar to a lambda column, you can use a column formatter to reuse code across prints. Any object with a 'format' method
@@ -116,6 +120,14 @@ can be used to filter a column. This could also be used for coloring output.
116
120
 
117
121
  tp User.all, :bio => {:formatters => [NoNewlineFormatter.new]} # strip newlines from user bios
118
122
 
123
+ === HTML Output
124
+
125
+ Currently the best way to show table_print output on an HTML page is using a <pre> tag. You can create a helper
126
+ method to send table_print output directly into your <pre> tag:
127
+
128
+ def tp_pre data, options={}
129
+ content_tag :pre, TablePrint::Printer.new(data, options).table_print
130
+ end
119
131
 
120
132
  === Config
121
133
 
@@ -3,13 +3,13 @@ module TablePrint
3
3
 
4
4
  DEFAULT_MAX_WIDTH = 30
5
5
  DEFAULT_TIME_FORMAT = "%Y-%m-%d %H:%M:%S"
6
- DEFAULT_IO = STDOUT
6
+ DEFAULT_IO = $stdout
7
7
  DEFAULT_CAPITALIZE_HEADERS = true
8
8
 
9
9
  @@max_width = DEFAULT_MAX_WIDTH
10
10
  @@time_format = DEFAULT_TIME_FORMAT
11
11
  @@multibyte = false
12
- @@io = STDOUT
12
+ @@io = DEFAULT_IO
13
13
  @@capitalize_headers = true
14
14
 
15
15
  @@klasses = {}
@@ -1,4 +1,4 @@
1
1
  module TablePrint
2
- VERSION = "1.5.3"
2
+ VERSION = "1.5.4"
3
3
  end
4
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: table_print
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 1.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Doyle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-25 00:00:00.000000000 Z
11
+ date: 2015-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cat
@@ -124,17 +124,17 @@ require_paths:
124
124
  - lib
125
125
  required_ruby_version: !ruby/object:Gem::Requirement
126
126
  requirements:
127
- - - ! '>='
127
+ - - '>='
128
128
  - !ruby/object:Gem::Version
129
129
  version: '0'
130
130
  required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  requirements:
132
- - - ! '>='
132
+ - - '>='
133
133
  - !ruby/object:Gem::Version
134
134
  version: '0'
135
135
  requirements: []
136
136
  rubyforge_project:
137
- rubygems_version: 2.0.7
137
+ rubygems_version: 2.0.14
138
138
  signing_key:
139
139
  specification_version: 4
140
140
  summary: Turn objects into nicely formatted columns for easy reading