command_line_reporter 3.3.6 → 4.0.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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/command_line_reporter.rb +101 -54
- data/lib/command_line_reporter/column.rb +37 -26
- data/lib/command_line_reporter/formatter/nested.rb +7 -11
- data/lib/command_line_reporter/formatter/progress.rb +5 -5
- data/lib/command_line_reporter/row.rb +15 -21
- data/lib/command_line_reporter/table.rb +37 -25
- data/lib/command_line_reporter/version.rb +1 -1
- data/spec/column_spec.rb +233 -138
- data/spec/command_line_reporter_spec.rb +172 -174
- data/spec/nested_formatter_spec.rb +66 -66
- data/spec/options_validator_spec.rb +10 -10
- data/spec/progress_formatter_spec.rb +10 -25
- data/spec/row_spec.rb +24 -22
- data/spec/spec_helper.rb +1 -1
- data/spec/support/matchers/argument.rb +0 -12
- data/spec/table_spec.rb +74 -48
- metadata +3 -3
data/spec/spec_helper.rb
CHANGED
@@ -2,16 +2,4 @@ RSpec::Matchers.define :accepts_argument do |expected|
|
|
2
2
|
match do
|
3
3
|
expected.call.should raise_exception ArgumentError
|
4
4
|
end
|
5
|
-
|
6
|
-
# failure_message_for_should do |actual|
|
7
|
-
# 'should raise an ArgumentError'
|
8
|
-
# end
|
9
|
-
|
10
|
-
# failure_message_for_should_not do |actual|
|
11
|
-
# 'should not raise ArgumentError'
|
12
|
-
# end
|
13
|
-
|
14
|
-
# description do
|
15
|
-
# 'validates options argument'
|
16
|
-
# end
|
17
5
|
end
|
data/spec/table_spec.rb
CHANGED
@@ -1,68 +1,95 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe CommandLineReporter::Table do
|
4
|
+
subject { CommandLineReporter::Table }
|
5
|
+
let(:row_subject) { CommandLineReporter::Row }
|
6
|
+
let(:col_subject) { CommandLineReporter::Column }
|
7
|
+
|
4
8
|
context 'creation' do
|
5
9
|
it 'defaults options hash' do
|
6
|
-
expect
|
7
|
-
|
8
|
-
|
10
|
+
expect do
|
11
|
+
subject.new
|
12
|
+
end.to_not raise_error Exception
|
9
13
|
end
|
10
14
|
|
11
15
|
it 'defaults the border' do
|
12
|
-
|
16
|
+
t = subject.new
|
17
|
+
expect(t.border).to be false
|
13
18
|
end
|
14
19
|
|
15
20
|
it 'accepts the border' do
|
16
|
-
|
21
|
+
t = subject.new(border: true)
|
22
|
+
expect(t.border).to eq(true)
|
17
23
|
end
|
18
24
|
|
19
25
|
it 'output encoding should be ascii' do
|
20
|
-
|
26
|
+
t = subject.new(encoding: :ascii)
|
27
|
+
expect(t.encoding).to eq(:ascii)
|
21
28
|
end
|
22
29
|
|
23
30
|
it 'output encoding should be unicode' do
|
24
|
-
|
31
|
+
t = subject.new
|
32
|
+
expect(t.encoding).to eq(:unicode)
|
25
33
|
end
|
26
34
|
end
|
27
35
|
|
28
36
|
context 'rows' do
|
29
37
|
it 'allows addition' do
|
30
|
-
cols = [
|
31
|
-
row =
|
32
|
-
cols.each {|c| row.add(c)}
|
33
|
-
expect
|
34
|
-
|
35
|
-
|
38
|
+
cols = [col_subject.new('test1'), col_subject.new('test2')]
|
39
|
+
row = row_subject.new
|
40
|
+
cols.each { |c| row.add(c) }
|
41
|
+
expect do
|
42
|
+
subject.new.add(row)
|
43
|
+
end.to_not raise_error Exception
|
36
44
|
end
|
37
45
|
|
38
46
|
context 'inherits' do
|
39
47
|
before :each do
|
40
|
-
@table =
|
41
|
-
row =
|
48
|
+
@table = subject.new
|
49
|
+
row = row_subject.new(color: 'red')
|
42
50
|
(
|
43
51
|
@cols1 = [
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
52
|
+
col_subject.new('asdf', width: 5),
|
53
|
+
col_subject.new('qwer', align: 'right', color: 'purple'),
|
54
|
+
col_subject.new('tutu', color: 'green'),
|
55
|
+
col_subject.new('uiui', bold: true)
|
48
56
|
]
|
49
|
-
).each {|c| row.add(c)}
|
57
|
+
).each { |c| row.add(c) }
|
50
58
|
@table.add(row)
|
51
|
-
row =
|
52
|
-
(
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
59
|
+
row = row_subject.new
|
60
|
+
(
|
61
|
+
@cols2 = [
|
62
|
+
col_subject.new('test'),
|
63
|
+
col_subject.new('test'),
|
64
|
+
col_subject.new('test', color: 'blue'),
|
65
|
+
col_subject.new('test')
|
57
66
|
]
|
58
|
-
).each {|c| row.add(c)}
|
67
|
+
).each { |c| row.add(c) }
|
59
68
|
@table.add(row)
|
60
69
|
end
|
61
70
|
|
62
|
-
|
63
|
-
|
71
|
+
context 'positional attributes' do
|
72
|
+
it 'should inherit alignment' do
|
73
|
+
4.times do |i|
|
74
|
+
expect(@table.rows[1].columns[i].align).to eq(@table.rows[0].columns[i].align)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should inherit width' do
|
64
79
|
4.times do |i|
|
65
|
-
expect(@table.rows[1].columns[i].
|
80
|
+
expect(@table.rows[1].columns[i].width).to eq(@table.rows[0].columns[i].width)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should inherit size' do
|
85
|
+
4.times do |i|
|
86
|
+
expect(@table.rows[1].columns[i].size).to eq(@table.rows[0].columns[i].size)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should inherit padding' do
|
91
|
+
4.times do |i|
|
92
|
+
expect(@table.rows[1].columns[i].padding).to eq(@table.rows[0].columns[i].padding)
|
66
93
|
end
|
67
94
|
end
|
68
95
|
end
|
@@ -85,12 +112,12 @@ describe CommandLineReporter::Table do
|
|
85
112
|
|
86
113
|
context 'with header row' do
|
87
114
|
before :each do
|
88
|
-
@table =
|
89
|
-
row =
|
90
|
-
@cols1.each {|c| row.add(c)}
|
115
|
+
@table = subject.new
|
116
|
+
row = row_subject.new(header: true)
|
117
|
+
@cols1.each { |c| row.add(c) }
|
91
118
|
@table.add(row)
|
92
|
-
row =
|
93
|
-
@cols2.each {|c| row.add(c)}
|
119
|
+
row = row_subject.new
|
120
|
+
@cols2.each { |c| row.add(c) }
|
94
121
|
@table.add(row)
|
95
122
|
end
|
96
123
|
|
@@ -114,20 +141,20 @@ describe CommandLineReporter::Table do
|
|
114
141
|
|
115
142
|
describe '#auto_adjust_widths' do
|
116
143
|
it 'sets the widths of each column in each row to the maximum required width for that column' do
|
117
|
-
table =
|
144
|
+
table = subject.new.tap do |t|
|
118
145
|
t.add(
|
119
|
-
|
120
|
-
r.add
|
121
|
-
r.add
|
122
|
-
r.add
|
146
|
+
row_subject.new.tap do |r|
|
147
|
+
r.add col_subject.new('medium length')
|
148
|
+
r.add col_subject.new('i am pretty long') # longest column
|
149
|
+
r.add col_subject.new('short', padding: 100)
|
123
150
|
end
|
124
151
|
)
|
125
152
|
|
126
153
|
t.add(
|
127
|
-
|
128
|
-
r.add
|
129
|
-
r.add
|
130
|
-
r.add
|
154
|
+
row_subject.new.tap do |r|
|
155
|
+
r.add col_subject.new('longer than medium length') # longest column
|
156
|
+
r.add col_subject.new('shorter')
|
157
|
+
r.add col_subject.new('longer than short') # longest column (inherits padding)
|
131
158
|
end
|
132
159
|
)
|
133
160
|
end
|
@@ -135,11 +162,10 @@ describe CommandLineReporter::Table do
|
|
135
162
|
table.auto_adjust_widths
|
136
163
|
|
137
164
|
table.rows.each do |row|
|
138
|
-
expect(row.columns[0].width).to eq(
|
139
|
-
expect(row.columns[1].width).to eq(
|
140
|
-
expect(row.columns[2].width).to eq(
|
165
|
+
expect(row.columns[0].width).to eq(col_subject.new('longer than medium length').required_width)
|
166
|
+
expect(row.columns[1].width).to eq(col_subject.new('i am pretty long').required_width)
|
167
|
+
expect(row.columns[2].width).to eq(col_subject.new('longer than short', padding: 100).required_width)
|
141
168
|
end
|
142
169
|
end
|
143
170
|
end
|
144
|
-
|
145
171
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: command_line_reporter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wes
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-07-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
86
|
rubyforge_project:
|
87
|
-
rubygems_version: 2.
|
87
|
+
rubygems_version: 2.6.12
|
88
88
|
signing_key:
|
89
89
|
specification_version: 4
|
90
90
|
summary: A tool for providing interactive command line applications
|