table_print 1.1.5 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -34,7 +34,7 @@ You should see something like this:
34
34
 
35
35
  > tp Book.all
36
36
  AUTHOR | SUMMARY | TITLE
37
- -----------------------------------------------------------------------
37
+ ------------------|---------------------------------|------------------
38
38
  Michael Connelly | Another book by Michael Con... | The Fifth Witness
39
39
  Manning Mardale | From acclaimed historian Ma... | Malcolm X
40
40
  Tina Fey | Worth it. -Trees | Bossypants
@@ -57,7 +57,7 @@ books had photos.
57
57
 
58
58
  > tp Author.limit(3), "name", "books.title", "books.photos.caption"
59
59
  NAME | BOOKS.TITLE | BOOKS.PHOTOS.CAPTION
60
- -------------------------------------------------------------------------
60
+ ------------------|-------------------|----------------------------------
61
61
  Michael Connelly | The Fifth Witness | Susan was running, fast, away...
62
62
  | | Along came a spider.
63
63
  | Malcolm X |
@@ -124,7 +124,7 @@ Use tp.set and tp.clear to set options on a class-by-class basis.
124
124
 
125
125
  > tp User.first
126
126
  ID | EMAIL
127
- ----------------
127
+ ---|------------
128
128
  1 | foo@bar.com
129
129
 
130
130
  # the config sets a 'baseline' for each print. You can still include/except columns:
@@ -14,7 +14,7 @@ Feature: Adding columns
14
14
  Then the output should contain
15
15
  """
16
16
  HERP | BLOG.AUTHOR | BLOG.TITLE
17
- -------------------------------
17
+ -----|-------------|-----------
18
18
  derp | Ryan | post!
19
19
  """
20
20
 
@@ -10,7 +10,7 @@ Feature: Configuring output
10
10
  Then the output should contain
11
11
  """
12
12
  TITLE | AUTHOR
13
- ------------------------------------------------
13
+ ------|-----------------------------------------
14
14
  post! | Ryan Ryan Ryan Ryan Ryan Ryan Ryan Ry...
15
15
  """
16
16
  Scenario: Specifying configuration on a per-object basis
@@ -38,7 +38,7 @@ Feature: Configuring output
38
38
  Then the output should contain
39
39
  """
40
40
  TITLE | AUTHOR | FOOBAR
41
- -----------------------
41
+ ------|--------|-------
42
42
  post! | Ryan | post!
43
43
  """
44
44
  Scenario: Applying a formatter
@@ -23,6 +23,6 @@ Feature: Excluding columns
23
23
  Then the output should contain
24
24
  """
25
25
  AUTHOR | URL
26
- --------------------------
26
+ -------|------------------
27
27
  Ryan | http://google.com
28
28
  """
@@ -10,7 +10,7 @@ Feature: Printing hash
10
10
  Then the output should contain
11
11
  """
12
12
  TITLE | AUTHOR
13
- ---------------------
13
+ -------------|-------
14
14
  First post! | Ryan
15
15
  Second post! | John
16
16
  Third post! | Peter
@@ -26,7 +26,7 @@ Feature: Printing hash
26
26
  Then the output should contain
27
27
  """
28
28
  TITLE | AUTHOR | TWO
29
- ----------------------------------
29
+ -------------|--------|-----------
30
30
  First post! | Ryan | RyanRyan
31
31
  Second post! | John | JohnJohn
32
32
  Third post! | Peter | PeterPeter
@@ -42,7 +42,7 @@ Feature: Printing hash
42
42
  Then the output should contain
43
43
  """
44
44
  TITLE | AUTHOR | SIZE
45
- ----------------------------
45
+ -------------|--------|-----
46
46
  First post! | Ryan | 2
47
47
  Second post! | John | 2
48
48
  Third post! | Peter | 2
@@ -22,7 +22,7 @@ Feature: Sensible defaults
22
22
  Then the output should contain
23
23
  """
24
24
  TITLE | AUTHOR
25
- --------------------
25
+ ------------|-------
26
26
  First post! | Ryan
27
27
  """
28
28
 
@@ -43,7 +43,7 @@ Feature: Sensible defaults
43
43
  Then the output should contain
44
44
  """
45
45
  TITLE | AUTHOR
46
- ---------------------
46
+ -------------|-------
47
47
  First post! | Ryan
48
48
  Second post! | Ryan
49
49
  Third post! | Ryan
@@ -63,7 +63,7 @@ Feature: Sensible defaults
63
63
  Then the output should contain
64
64
  """
65
65
  ID | COMMENTS.ID | COMMENTS.USERNAME
66
- ------------------------------------
66
+ ---|-------------|------------------
67
67
  1 | 1 | chris
68
68
  | 2 | joe
69
69
  """
@@ -62,7 +62,9 @@ module TablePrint
62
62
  end
63
63
 
64
64
  def horizontal_separator
65
- '-' * header.length # columns don't know how to respect max_width (formatter does that) so just match the header
65
+ columns.collect do |column|
66
+ '-' * column.width
67
+ end.join('-|-')
66
68
  end
67
69
 
68
70
  def header
@@ -1,4 +1,4 @@
1
1
  module TablePrint
2
- VERSION = "1.1.5"
2
+ VERSION = "1.2.0"
3
3
  end
4
4
 
@@ -94,8 +94,13 @@ describe RowRecursion do
94
94
 
95
95
  describe "#horizontal_separator" do
96
96
  it "returns hyphens equal to the table width" do
97
- child.set_cell_values(:title => 'foobar')
98
- child.horizontal_separator.should == '------'
97
+ parent.add_child(r1 = Row.new)
98
+ parent.add_child(r2 = Row.new)
99
+
100
+ r1.set_cell_values(:title => 'a' * 5, :description => 'b' * 3, :category => 'c' * 10)
101
+ r2.set_cell_values(:title => 'a' * 6, :description => 'b' * 4, :category => 'c' * 9)
102
+ parent.header.size.should == parent.horizontal_separator.size
103
+ compare_rows(parent.horizontal_separator, '-' * 6 + '-|-' + '-' * 'description'.size + '-|-' + '-' * 10)
99
104
  end
100
105
 
101
106
  it "matches the header width" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: table_print
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.2.0
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: 2013-08-19 00:00:00.000000000Z
12
+ date: 2013-08-30 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cat