columnist 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/spec/table_spec.rb CHANGED
@@ -1,154 +1,154 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Columnist::Table do
4
- context 'creation' do
5
- it 'defaults options hash' do
6
- expect {
7
- Columnist::Table.new
8
- }.to_not raise_error
9
- end
4
+ context 'creation' do
5
+ it 'defaults options hash' do
6
+ expect {
7
+ Columnist::Table.new
8
+ }.to_not raise_error
9
+ end
10
10
 
11
- it 'defaults the border' do
12
- expect(Columnist::Table.new.border).to be_false
13
- end
11
+ it 'defaults the border' do
12
+ expect(Columnist::Table.new.border).to be_false
13
+ end
14
14
 
15
- it 'accepts the border' do
16
- expect(Columnist::Table.new(:border => true).border).to eq(true)
17
- end
15
+ it 'accepts the border' do
16
+ expect(Columnist::Table.new(:border => true).border).to eq(true)
17
+ end
18
18
 
19
- it 'defaults the border_color' do
20
- expect(Columnist::Table.new.border_color).to be_false
21
- end
19
+ it 'defaults the border_color' do
20
+ expect(Columnist::Table.new.border_color).to be_false
21
+ end
22
22
 
23
- it 'accepts the border_color' do
24
- expect(Columnist::Table.new(:border_color => true).border_color).to eq(true)
25
- end
23
+ it 'accepts the border_color' do
24
+ expect(Columnist::Table.new(:border_color => true).border_color).to eq(true)
25
+ end
26
26
 
27
- it 'output encoding should be ascii' do
28
- expect(Columnist::Table.new(:encoding => :ascii).encoding).to eq(:ascii)
29
- end
27
+ it 'output encoding should be ascii' do
28
+ expect(Columnist::Table.new(:encoding => :ascii).encoding).to eq(:ascii)
29
+ end
30
30
 
31
- it 'output encoding should be unicode' do
32
- expect(Columnist::Table.new.encoding).to eq(:unicode)
33
- end
34
- end
35
-
36
- context 'rows' do
37
- it 'allows addition' do
38
- cols = [Columnist::Column.new('test1'), Columnist::Column.new('test2')]
39
- row = Columnist::Row.new
40
- cols.each {|c| row.add(c)}
41
- expect {
42
- Columnist::Table.new.add(row)
43
- }.to_not raise_error
31
+ it 'output encoding should be unicode' do
32
+ expect(Columnist::Table.new.encoding).to eq(:unicode)
33
+ end
44
34
  end
45
35
 
46
- context 'inherits' do
47
- before :each do
48
- @table = Columnist::Table.new
49
- row = Columnist::Row.new(:color => 'red')
50
- (
51
- @cols1 = [
52
- Columnist::Column.new('asdf', :width => 5),
53
- Columnist::Column.new('qwer', :align => 'right', :color => 'purple'),
54
- Columnist::Column.new('tutu', :color => 'green'),
55
- Columnist::Column.new('uiui', :bold => true),
56
- ]
57
- ).each {|c| row.add(c)}
58
- @table.add(row)
59
- row = Columnist::Row.new
60
- (@cols2 = [
61
- Columnist::Column.new('test'),
62
- Columnist::Column.new('test'),
63
- Columnist::Column.new('test', :color => 'blue'),
64
- Columnist::Column.new('test'),
65
- ]
66
- ).each {|c| row.add(c)}
67
- @table.add(row)
68
- end
69
-
70
- it 'positional attributes' do
71
- [:align, :width, :size, :padding].each do |m|
72
- 4.times do |i|
73
- expect(@table.rows[1].columns[i].send(m)).to eq(@table.rows[0].columns[i].send(m))
74
- end
75
- end
76
- end
77
-
78
- context 'no header row' do
79
- it 'color' do
80
- expect(@table.rows[1].columns[0].color).to eq('red')
81
- expect(@table.rows[1].columns[1].color).to eq('purple')
82
- expect(@table.rows[1].columns[2].color).to eq('blue')
83
- expect(@table.rows[1].columns[3].color).to eq('red')
36
+ context 'rows' do
37
+ it 'allows addition' do
38
+ cols = [Columnist::Column.new('test1'), Columnist::Column.new('test2')]
39
+ row = Columnist::Row.new
40
+ cols.each { |c| row.add(c) }
41
+ expect {
42
+ Columnist::Table.new.add(row)
43
+ }.to_not raise_error
84
44
  end
85
45
 
86
- it 'bold' do
87
- expect(@table.rows[1].columns[0].bold).to be_false
88
- expect(@table.rows[1].columns[1].bold).to be_false
89
- expect(@table.rows[1].columns[2].bold).to be_false
90
- expect(@table.rows[1].columns[3].bold).to be_true
91
- end
92
- end
93
-
94
- context 'with header row' do
95
- before :each do
96
- @table = Columnist::Table.new
97
- row = Columnist::Row.new(:header => true)
98
- @cols1.each {|c| row.add(c)}
99
- @table.add(row)
100
- row = Columnist::Row.new
101
- @cols2.each {|c| row.add(c)}
102
- @table.add(row)
46
+ context 'inherits' do
47
+ before :each do
48
+ @table = Columnist::Table.new
49
+ row = Columnist::Row.new(:color => 'red')
50
+ (
51
+ @cols1 = [
52
+ Columnist::Column.new('asdf', :width => 5),
53
+ Columnist::Column.new('qwer', :align => 'right', :color => 'purple'),
54
+ Columnist::Column.new('tutu', :color => 'green'),
55
+ Columnist::Column.new('uiui', :bold => true),
56
+ ]
57
+ ).each { |c| row.add(c) }
58
+ @table.add(row)
59
+ row = Columnist::Row.new
60
+ (@cols2 = [
61
+ Columnist::Column.new('test'),
62
+ Columnist::Column.new('test'),
63
+ Columnist::Column.new('test', :color => 'blue'),
64
+ Columnist::Column.new('test'),
65
+ ]
66
+ ).each { |c| row.add(c) }
67
+ @table.add(row)
68
+ end
69
+
70
+ it 'positional attributes' do
71
+ [:align, :width, :size, :padding].each do |m|
72
+ 4.times do |i|
73
+ expect(@table.rows[1].columns[i].send(m)).to eq(@table.rows[0].columns[i].send(m))
74
+ end
75
+ end
76
+ end
77
+
78
+ context 'no header row' do
79
+ it 'color' do
80
+ expect(@table.rows[1].columns[0].color).to eq('red')
81
+ expect(@table.rows[1].columns[1].color).to eq('purple')
82
+ expect(@table.rows[1].columns[2].color).to eq('blue')
83
+ expect(@table.rows[1].columns[3].color).to eq('red')
84
+ end
85
+
86
+ it 'bold' do
87
+ expect(@table.rows[1].columns[0].bold).to be_false
88
+ expect(@table.rows[1].columns[1].bold).to be_false
89
+ expect(@table.rows[1].columns[2].bold).to be_false
90
+ expect(@table.rows[1].columns[3].bold).to be_true
91
+ end
92
+ end
93
+
94
+ context 'with header row' do
95
+ before :each do
96
+ @table = Columnist::Table.new
97
+ row = Columnist::Row.new(:header => true)
98
+ @cols1.each { |c| row.add(c) }
99
+ @table.add(row)
100
+ row = Columnist::Row.new
101
+ @cols2.each { |c| row.add(c) }
102
+ @table.add(row)
103
+ end
104
+
105
+ it 'color' do
106
+ expect(@table.rows[1].columns[0].color).to eq('red')
107
+ expect(@table.rows[1].columns[1].color).to eq('purple')
108
+ expect(@table.rows[1].columns[2].color).to eq('blue')
109
+ expect(@table.rows[1].columns[3].color).to eq('red')
110
+ end
111
+
112
+ it 'bold' do
113
+ expect(@table.rows[1].columns[0].bold).to be_false
114
+ expect(@table.rows[1].columns[0].bold).to be_false
115
+ expect(@table.rows[1].columns[1].bold).to be_false
116
+ expect(@table.rows[1].columns[2].bold).to be_false
117
+ expect(@table.rows[1].columns[3].bold).to be_true
118
+ end
119
+ end
103
120
  end
121
+ end
104
122
 
105
- it 'color' do
106
- expect(@table.rows[1].columns[0].color).to eq('red')
107
- expect(@table.rows[1].columns[1].color).to eq('purple')
108
- expect(@table.rows[1].columns[2].color).to eq('blue')
109
- expect(@table.rows[1].columns[3].color).to eq('red')
110
- end
111
123
 
112
- it 'bold' do
113
- expect(@table.rows[1].columns[0].bold).to be_false
114
- expect(@table.rows[1].columns[0].bold).to be_false
115
- expect(@table.rows[1].columns[1].bold).to be_false
116
- expect(@table.rows[1].columns[2].bold).to be_false
117
- expect(@table.rows[1].columns[3].bold).to be_true
124
+ describe '#auto_adjust_widths' do
125
+ it 'sets the widths of each column in each row to the maximum required width for that column' do
126
+ table = Columnist::Table.new.tap do |t|
127
+ t.add(
128
+ Columnist::Row.new.tap do |r|
129
+ r.add Columnist::Column.new('medium length')
130
+ r.add Columnist::Column.new('i am pretty long') # longest column
131
+ r.add Columnist::Column.new('short', :padding => 100)
132
+ end
133
+ )
134
+
135
+ t.add(
136
+ Columnist::Row.new.tap do |r|
137
+ r.add Columnist::Column.new('longer than medium length') # longest column
138
+ r.add Columnist::Column.new('shorter')
139
+ r.add Columnist::Column.new('longer than short') # longest column (inherits padding)
140
+ end
141
+ )
142
+ end
143
+
144
+ table.auto_adjust_widths
145
+
146
+ table.rows.each do |row|
147
+ expect(row.columns[0].width).to eq(Columnist::Column.new('longer than medium length').required_width)
148
+ expect(row.columns[1].width).to eq(Columnist::Column.new('i am pretty long').required_width)
149
+ expect(row.columns[2].width).to eq(Columnist::Column.new('longer than short', :padding => 100).required_width)
150
+ end
118
151
  end
119
- end
120
- end
121
- end
122
-
123
-
124
- describe '#auto_adjust_widths' do
125
- it 'sets the widths of each column in each row to the maximum required width for that column' do
126
- table = Columnist::Table.new.tap do |t|
127
- t.add(
128
- Columnist::Row.new.tap do |r|
129
- r.add Columnist::Column.new('medium length')
130
- r.add Columnist::Column.new('i am pretty long') # longest column
131
- r.add Columnist::Column.new('short', :padding => 100)
132
- end
133
- )
134
-
135
- t.add(
136
- Columnist::Row.new.tap do |r|
137
- r.add Columnist::Column.new('longer than medium length') # longest column
138
- r.add Columnist::Column.new('shorter')
139
- r.add Columnist::Column.new('longer than short') # longest column (inherits padding)
140
- end
141
- )
142
- end
143
-
144
- table.auto_adjust_widths
145
-
146
- table.rows.each do |row|
147
- expect(row.columns[0].width).to eq(Columnist::Column.new('longer than medium length').required_width)
148
- expect(row.columns[1].width).to eq(Columnist::Column.new('i am pretty long').required_width)
149
- expect(row.columns[2].width).to eq(Columnist::Column.new('longer than short', :padding => 100).required_width)
150
- end
151
152
  end
152
- end
153
153
 
154
154
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: columnist
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Albert Rannetsperger
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-01-08 00:00:00.000000000 Z
12
+ date: 2019-08-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colored
@@ -99,18 +99,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  version: '0'
100
100
  requirements: []
101
101
  rubyforge_project:
102
- rubygems_version: 2.4.1
102
+ rubygems_version: 2.6.12
103
103
  signing_key:
104
104
  specification_version: 4
105
105
  summary: A tool for building interactive command line reports
106
106
  test_files:
107
- - spec/column_spec.rb
108
- - spec/columnist.rb
107
+ - spec/spec_helper.rb
109
108
  - spec/nested_formatter_spec.rb
110
- - spec/options_validator_spec.rb
111
- - spec/progress_formatter_spec.rb
109
+ - spec/columnist.rb
112
110
  - spec/row_spec.rb
113
- - spec/spec_helper.rb
114
- - spec/support/helpers/stdout.rb
111
+ - spec/progress_formatter_spec.rb
115
112
  - spec/support/matchers/argument.rb
113
+ - spec/support/helpers/stdout.rb
114
+ - spec/options_validator_spec.rb
115
+ - spec/column_spec.rb
116
116
  - spec/table_spec.rb