tabularize 0.2.8 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ 0.2.9
2
+ -----
3
+ - Bug fix: exception on empty column
4
+
1
5
  0.2.8
2
6
  -----
3
7
  - 1.8 compatibility
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tabularize (0.2.8)
4
+ tabularize (0.2.9)
5
5
  unicode-display_width (~> 0.1.1)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -54,7 +54,7 @@ puts table
54
54
  * Alignment
55
55
  * `:align` Horizontal alignment. `:left`, `:center`, `:right`, or Array of the three options
56
56
  * `:valign` Vertical alignment. `:top`, `:middle`, `:bottom`, or Array of the three options
57
- * Ellipses: Cut off trailing cells if the total width exceeds the specified screen width
57
+ * Ellipsis: Cut off trailing cells if the total width exceeds the specified screen width
58
58
  * `:screen_width` The number of columns for the current terminal. Default: unlimited.
59
59
  * `:ellipsis` Ellipsis string when cells are cut off. Default: `>`
60
60
 
@@ -66,7 +66,7 @@ table = Tabularize.new :pad => '.', :pad_left => 2, :pad_right => 0,
66
66
  :border_color => ANSI::Code.red,
67
67
  :align => [:left, :center, :right],
68
68
  :valign => [:top, :bottom, :middle, :middle],
69
- :screen_width => 75, :ellipsis => 'X'
69
+ :screen_width => 75, :ellipsis => '~'
70
70
  table << %w[Name Dept Location Phone Description]
71
71
  table.separator!
72
72
  table << ['John Doe', 'Finance', 'Los Angeles CA 90089', '555-1555', 'Just a guy']
data/lib/tabularize.rb CHANGED
@@ -198,7 +198,7 @@ class Tabularize
198
198
 
199
199
  row.each_with_index do |cell, idx|
200
200
  nlines = 0
201
- cell.lines do |c|
201
+ (cell.empty? ? [''] : cell.lines).each do |c|
202
202
  max_widths[idx] = [ Tabularize.cell_width(c.chomp, unicode, ansi), max_widths[idx] || 0 ].max
203
203
  nlines += 1
204
204
  end
@@ -1,3 +1,3 @@
1
1
  class Tabularize
2
- VERSION = "0.2.8"
2
+ VERSION = "0.2.9"
3
3
  end
@@ -298,4 +298,19 @@ I..This should change everything doh!I.............I............................
298
298
  table << %w[abcde] * 100
299
299
  assert table.to_s.lines.first.display_width > 190
300
300
  end
301
+
302
+ def test_it_nil_column
303
+ assert_equal [['1 ', '', '2 '], ['11', '', '22']], Tabularize.it([[1, nil, 2], [11, nil, 22]])
304
+ end
305
+
306
+ def test_analyze_nil_column
307
+ assert_equal [2, 0, 2], Tabularize.analyze([[1, nil, 2], [11, nil, 22]])[:max_widths]
308
+ end
309
+
310
+ def test_tabualarize_nil_column
311
+ table = Tabularize.new
312
+ table << [1, nil, 2]
313
+ table << [11, nil, 22]
314
+ table.to_s
315
+ end
301
316
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tabularize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-01 00:00:00.000000000 Z
12
+ date: 2012-09-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: awesome_print