tty-table 0.7.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +57 -0
- data/LICENSE.txt +1 -1
- data/README.md +165 -94
- data/lib/tty-table.rb +1 -5
- data/lib/tty/table.rb +102 -42
- data/lib/tty/table/alignment_set.rb +3 -6
- data/lib/tty/table/border.rb +57 -68
- data/lib/tty/table/border/ascii.rb +17 -17
- data/lib/tty/table/border/null.rb +20 -22
- data/lib/tty/table/border/row_line.rb +4 -3
- data/lib/tty/table/border/unicode.rb +17 -17
- data/lib/tty/table/border_dsl.rb +28 -25
- data/lib/tty/table/border_options.rb +50 -25
- data/lib/tty/table/column_constraint.rb +29 -17
- data/lib/tty/table/{column_set.rb → columns.rb} +44 -69
- data/lib/tty/table/empty.rb +2 -0
- data/lib/tty/table/error.rb +1 -1
- data/lib/tty/table/field.rb +43 -35
- data/lib/tty/table/header.rb +7 -5
- data/lib/tty/table/indentation.rb +16 -25
- data/lib/tty/table/operation/alignment.rb +10 -8
- data/lib/tty/table/operation/escape.rb +2 -3
- data/lib/tty/table/operation/filter.rb +1 -1
- data/lib/tty/table/operation/padding.rb +4 -12
- data/lib/tty/table/operation/truncation.rb +4 -4
- data/lib/tty/table/operation/wrapped.rb +4 -4
- data/lib/tty/table/operations.rb +4 -15
- data/lib/tty/table/options.rb +2 -4
- data/lib/tty/table/orientation.rb +5 -5
- data/lib/tty/table/orientation/horizontal.rb +1 -1
- data/lib/tty/table/orientation/vertical.rb +1 -1
- data/lib/tty/table/renderer.rb +40 -35
- data/lib/tty/table/renderer/ascii.rb +4 -4
- data/lib/tty/table/renderer/basic.rb +85 -88
- data/lib/tty/table/renderer/unicode.rb +3 -3
- data/lib/tty/table/row.rb +10 -8
- data/lib/tty/table/transformation.rb +2 -2
- data/lib/tty/table/validatable.rb +25 -7
- data/lib/tty/table/version.rb +3 -3
- metadata +33 -283
- data/.gitignore +0 -14
- data/.rspec +0 -3
- data/.travis.yml +0 -24
- data/CODE_OF_CONDUCT.md +0 -49
- data/Gemfile +0 -18
- data/Rakefile +0 -8
- data/benchmarks/speed.rb +0 -41
- data/spec/spec_helper.rb +0 -50
- data/spec/unit/access_spec.rb +0 -86
- data/spec/unit/add_row_spec.rb +0 -28
- data/spec/unit/alignment_set/each_spec.rb +0 -17
- data/spec/unit/alignment_set/new_spec.rb +0 -27
- data/spec/unit/alignment_set/to_ary_spec.rb +0 -14
- data/spec/unit/alignment_spec.rb +0 -71
- data/spec/unit/border/ascii/rendering_spec.rb +0 -90
- data/spec/unit/border/new_spec.rb +0 -27
- data/spec/unit/border/null/rendering_spec.rb +0 -130
- data/spec/unit/border/options/from_spec.rb +0 -38
- data/spec/unit/border/options/new_spec.rb +0 -14
- data/spec/unit/border/unicode/rendering_spec.rb +0 -63
- data/spec/unit/border_options/new_spec.rb +0 -20
- data/spec/unit/border_options/update_spec.rb +0 -18
- data/spec/unit/column_constraint/enforce_spec.rb +0 -70
- data/spec/unit/column_constraint/widths_spec.rb +0 -35
- data/spec/unit/column_set/extract_widths_spec.rb +0 -48
- data/spec/unit/column_set/total_width_spec.rb +0 -15
- data/spec/unit/column_set/widths_from_spec.rb +0 -51
- data/spec/unit/data_spec.rb +0 -12
- data/spec/unit/each_spec.rb +0 -26
- data/spec/unit/each_with_index_spec.rb +0 -51
- data/spec/unit/empty_spec.rb +0 -23
- data/spec/unit/eql_spec.rb +0 -34
- data/spec/unit/field/equality_spec.rb +0 -51
- data/spec/unit/field/length_spec.rb +0 -35
- data/spec/unit/field/lines_spec.rb +0 -21
- data/spec/unit/field/new_spec.rb +0 -29
- data/spec/unit/field/width_spec.rb +0 -23
- data/spec/unit/filter_spec.rb +0 -22
- data/spec/unit/header/call_spec.rb +0 -30
- data/spec/unit/header/color_spec.rb +0 -19
- data/spec/unit/header/equality_spec.rb +0 -51
- data/spec/unit/header/height_spec.rb +0 -27
- data/spec/unit/header/new_spec.rb +0 -16
- data/spec/unit/header/set_spec.rb +0 -20
- data/spec/unit/header/to_ary_spec.rb +0 -14
- data/spec/unit/header_spec.rb +0 -13
- data/spec/unit/indentation/indent_spec.rb +0 -21
- data/spec/unit/new_spec.rb +0 -73
- data/spec/unit/operation/alignment/call_spec.rb +0 -39
- data/spec/unit/operation/escape/call_spec.rb +0 -15
- data/spec/unit/operation/filter/call_spec.rb +0 -16
- data/spec/unit/operation/truncation/call_spec.rb +0 -30
- data/spec/unit/operation/wrapped/call_spec.rb +0 -40
- data/spec/unit/operations/new_spec.rb +0 -30
- data/spec/unit/options/access_spec.rb +0 -14
- data/spec/unit/options_spec.rb +0 -25
- data/spec/unit/orientation_spec.rb +0 -145
- data/spec/unit/padding_spec.rb +0 -117
- data/spec/unit/properties_spec.rb +0 -25
- data/spec/unit/render_repeat_spec.rb +0 -42
- data/spec/unit/render_spec.rb +0 -63
- data/spec/unit/render_with_spec.rb +0 -106
- data/spec/unit/renderer/ascii/coloring_spec.rb +0 -70
- data/spec/unit/renderer/ascii/indentation_spec.rb +0 -41
- data/spec/unit/renderer/ascii/multiline_spec.rb +0 -101
- data/spec/unit/renderer/ascii/padding_spec.rb +0 -88
- data/spec/unit/renderer/ascii/render_spec.rb +0 -68
- data/spec/unit/renderer/ascii/resizing_spec.rb +0 -114
- data/spec/unit/renderer/ascii/separator_spec.rb +0 -28
- data/spec/unit/renderer/basic/alignment_spec.rb +0 -88
- data/spec/unit/renderer/basic/coloring_spec.rb +0 -61
- data/spec/unit/renderer/basic/extract_column_widths_spec.rb +0 -28
- data/spec/unit/renderer/basic/filter_spec.rb +0 -53
- data/spec/unit/renderer/basic/indentation_spec.rb +0 -48
- data/spec/unit/renderer/basic/multiline_spec.rb +0 -74
- data/spec/unit/renderer/basic/new_spec.rb +0 -26
- data/spec/unit/renderer/basic/options_spec.rb +0 -52
- data/spec/unit/renderer/basic/padding_spec.rb +0 -76
- data/spec/unit/renderer/basic/render_spec.rb +0 -57
- data/spec/unit/renderer/basic/resizing_spec.rb +0 -96
- data/spec/unit/renderer/basic/separator_spec.rb +0 -43
- data/spec/unit/renderer/basic/truncation_spec.rb +0 -35
- data/spec/unit/renderer/basic/wrapping_spec.rb +0 -40
- data/spec/unit/renderer/border_spec.rb +0 -104
- data/spec/unit/renderer/render_spec.rb +0 -36
- data/spec/unit/renderer/select_spec.rb +0 -22
- data/spec/unit/renderer/unicode/coloring_spec.rb +0 -70
- data/spec/unit/renderer/unicode/indentation_spec.rb +0 -41
- data/spec/unit/renderer/unicode/padding_spec.rb +0 -61
- data/spec/unit/renderer/unicode/render_spec.rb +0 -68
- data/spec/unit/renderer/unicode/separator_spec.rb +0 -26
- data/spec/unit/renderer_spec.rb +0 -19
- data/spec/unit/rotate_spec.rb +0 -86
- data/spec/unit/row/access_spec.rb +0 -25
- data/spec/unit/row/call_spec.rb +0 -45
- data/spec/unit/row/data_spec.rb +0 -26
- data/spec/unit/row/each_spec.rb +0 -31
- data/spec/unit/row/equality_spec.rb +0 -73
- data/spec/unit/row/height_spec.rb +0 -27
- data/spec/unit/row/new_spec.rb +0 -41
- data/spec/unit/row/to_ary_spec.rb +0 -14
- data/spec/unit/to_s_spec.rb +0 -56
- data/spec/unit/transformation/extract_tuples_spec.rb +0 -35
- data/spec/unit/utf_spec.rb +0 -33
- data/spec/unit/validatable/validate_options_spec.rb +0 -33
- data/spec/unit/validatable_spec.rb +0 -32
- data/tasks/console.rake +0 -10
- data/tasks/coverage.rake +0 -11
- data/tasks/spec.rake +0 -29
- data/tty-table.gemspec +0 -30
@@ -1,40 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe TTY::Table::Operation::Wrapped, '#call' do
|
6
|
-
let(:text) { 'ラドクリフ、マラソン五輪代表に1万m出場にも含み' }
|
7
|
-
let(:field) { TTY::Table::Field.new(text) }
|
8
|
-
|
9
|
-
subject(:operation) { described_class.new(column_widths) }
|
10
|
-
|
11
|
-
context 'without column width' do
|
12
|
-
let(:column_widths) { [] }
|
13
|
-
|
14
|
-
it "doesn't wrap string" do
|
15
|
-
expect(operation.call(field, 0, 0)).to eql(text)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'with column width' do
|
20
|
-
let(:column_widths) { [12, 14] }
|
21
|
-
|
22
|
-
it "wraps string for 0 column" do
|
23
|
-
expect(operation.call(field, 0, 0)).to eql([
|
24
|
-
"ラドクリフ、",
|
25
|
-
"マラソン五輪",
|
26
|
-
"代表に1万m出",
|
27
|
-
"場にも含み"
|
28
|
-
].join("\n"))
|
29
|
-
end
|
30
|
-
|
31
|
-
it "wraps string for 1 column" do
|
32
|
-
expect(operation.call(field, 0, 1)).to eql([
|
33
|
-
"ラドクリフ、マ",
|
34
|
-
"ラソン五輪代表",
|
35
|
-
"に1万m出場にも",
|
36
|
-
"含み"
|
37
|
-
].join("\n"))
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe TTY::Table::Operations, '#new' do
|
6
|
-
let(:object) { described_class }
|
7
|
-
let(:row) { [1,2,3] }
|
8
|
-
let(:table) { TTY::Table.new :rows => [row] }
|
9
|
-
let(:callable) {
|
10
|
-
Class.new do
|
11
|
-
def call(val, row, col)
|
12
|
-
val.value= val.value + 1
|
13
|
-
end
|
14
|
-
end
|
15
|
-
}
|
16
|
-
let(:instance) { callable.new }
|
17
|
-
|
18
|
-
subject { object.new table }
|
19
|
-
|
20
|
-
before { subject.add(:alignment, instance) }
|
21
|
-
|
22
|
-
it 'stores away operations' do
|
23
|
-
expect(subject[:alignment]).to include(instance)
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'runs selected operations' do
|
27
|
-
subject.run_operations(:alignment)
|
28
|
-
expect(table.data[0]).to eql([2,3,4])
|
29
|
-
end
|
30
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
# describe TTY::Table::Options, 'options' do
|
6
|
-
# let(:object) { described_class }
|
7
|
-
#
|
8
|
-
# subject { described_class.new({'a' => 1, :b => 2}) }
|
9
|
-
#
|
10
|
-
# it '' do
|
11
|
-
# pending
|
12
|
-
# expect(subject[:a]).to eql(1)
|
13
|
-
# end
|
14
|
-
# end
|
data/spec/unit/options_spec.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe TTY::Table, 'options' do
|
6
|
-
let(:rows) { [['a1', 'a2'], ['b1', 'b2']] }
|
7
|
-
let(:widths) { nil }
|
8
|
-
let(:aligns) { [] }
|
9
|
-
let(:object) { described_class }
|
10
|
-
let(:options) {
|
11
|
-
{
|
12
|
-
column_widths: widths,
|
13
|
-
column_aligns: aligns,
|
14
|
-
renderer: :basic
|
15
|
-
}
|
16
|
-
}
|
17
|
-
|
18
|
-
subject(:table) { object.new rows, options }
|
19
|
-
|
20
|
-
it { expect(table.header).to be_nil }
|
21
|
-
|
22
|
-
it { expect(table.rows).to eq(rows) }
|
23
|
-
|
24
|
-
it { expect(table.orientation).to be_kind_of TTY::Table::Orientation::Horizontal }
|
25
|
-
end
|
@@ -1,145 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe TTY::Table, 'orientation' do
|
6
|
-
let(:header) { ['h1', 'h2', 'h3'] }
|
7
|
-
let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] }
|
8
|
-
let(:options) { { :orientation => orientation } }
|
9
|
-
|
10
|
-
subject { described_class.new(header, rows, options) }
|
11
|
-
|
12
|
-
context 'when illegal option' do
|
13
|
-
let(:orientation) { :accross }
|
14
|
-
|
15
|
-
it { expect { subject }.to raise_error(TTY::Table::InvalidOrientationError) }
|
16
|
-
end
|
17
|
-
|
18
|
-
context 'when horizontal' do
|
19
|
-
let(:orientation) { :horizontal }
|
20
|
-
|
21
|
-
it { expect(subject.orientation).to be_kind_of TTY::Table::Orientation }
|
22
|
-
|
23
|
-
it { expect(subject.orientation.name).to eql(:horizontal) }
|
24
|
-
|
25
|
-
it { expect(subject.header).to eql(header) }
|
26
|
-
|
27
|
-
it 'preserves original rows' do
|
28
|
-
expect(subject.to_a).to eql(subject.data)
|
29
|
-
end
|
30
|
-
|
31
|
-
context 'without border' do
|
32
|
-
it 'displays table' do
|
33
|
-
expect(subject.to_s).to eq unindent(<<-EOS)
|
34
|
-
h1 h2 h3
|
35
|
-
a1 a2 a3
|
36
|
-
b1 b2 b3
|
37
|
-
EOS
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context 'with border' do
|
42
|
-
let(:renderer) { :ascii }
|
43
|
-
|
44
|
-
it 'diplays table' do
|
45
|
-
expect(subject.render(renderer)).to eq unindent(<<-EOS)
|
46
|
-
+--+--+--+
|
47
|
-
|h1|h2|h3|
|
48
|
-
+--+--+--+
|
49
|
-
|a1|a2|a3|
|
50
|
-
|b1|b2|b3|
|
51
|
-
+--+--+--+
|
52
|
-
EOS
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
context 'when vertical' do
|
58
|
-
let(:orientation) { :vertical }
|
59
|
-
|
60
|
-
it { expect(subject.orientation).to be_kind_of TTY::Table::Orientation }
|
61
|
-
|
62
|
-
it { expect(subject.orientation.name).to eql :vertical }
|
63
|
-
|
64
|
-
it { expect(subject.header).to be_empty }
|
65
|
-
|
66
|
-
context 'with header' do
|
67
|
-
it 'rotates original rows' do
|
68
|
-
rotated_rows = [['h1','a1'],['h2','a2'],['h3','a3'], ['h1','b1'],['h2','b2'],['h3','b3']]
|
69
|
-
expect(subject.to_a).to eql rotated_rows
|
70
|
-
end
|
71
|
-
|
72
|
-
context 'without border' do
|
73
|
-
it 'displays table' do
|
74
|
-
expect(subject.to_s).to eq unindent(<<-EOS)
|
75
|
-
h1 a1
|
76
|
-
h2 a2
|
77
|
-
h3 a3
|
78
|
-
h1 b1
|
79
|
-
h2 b2
|
80
|
-
h3 b3
|
81
|
-
EOS
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
context 'with border' do
|
86
|
-
let(:renderer) { :ascii }
|
87
|
-
|
88
|
-
it 'diplays table' do
|
89
|
-
expect(subject.render(renderer)).to eq unindent(<<-EOS)
|
90
|
-
+--+--+
|
91
|
-
|h1|a1|
|
92
|
-
|h2|a2|
|
93
|
-
|h3|a3|
|
94
|
-
|h1|b1|
|
95
|
-
|h2|b2|
|
96
|
-
|h3|b3|
|
97
|
-
+--+--+
|
98
|
-
EOS
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
context 'without header' do
|
104
|
-
let(:header) { nil }
|
105
|
-
|
106
|
-
it 'rotates original rows' do
|
107
|
-
rotated_rows = [
|
108
|
-
['1','a1'],['2','a2'],['3','a3'],
|
109
|
-
['1','b1'],['2','b2'],['3','b3']
|
110
|
-
]
|
111
|
-
expect(subject.to_a).to eql rotated_rows
|
112
|
-
end
|
113
|
-
|
114
|
-
context 'without border' do
|
115
|
-
it 'displays table' do
|
116
|
-
expect(subject.to_s).to eq unindent(<<-EOS)
|
117
|
-
1 a1
|
118
|
-
2 a2
|
119
|
-
3 a3
|
120
|
-
1 b1
|
121
|
-
2 b2
|
122
|
-
3 b3
|
123
|
-
EOS
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
context 'with border' do
|
128
|
-
let(:renderer) { :ascii }
|
129
|
-
|
130
|
-
it 'diplays table' do
|
131
|
-
expect(subject.render(renderer)).to eq unindent(<<-EOS)
|
132
|
-
+-+--+
|
133
|
-
|1|a1|
|
134
|
-
|2|a2|
|
135
|
-
|3|a3|
|
136
|
-
|1|b1|
|
137
|
-
|2|b2|
|
138
|
-
|3|b3|
|
139
|
-
+-+--+
|
140
|
-
EOS
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end # orientation
|
data/spec/unit/padding_spec.rb
DELETED
@@ -1,117 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe TTY::Table, 'padding' do
|
6
|
-
let(:header) { ['h1', 'h2', 'h3'] }
|
7
|
-
let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] }
|
8
|
-
let(:table) { described_class.new(header, rows) }
|
9
|
-
|
10
|
-
it 'sets specific padding' do
|
11
|
-
expect(table.render(:ascii) { |renderer|
|
12
|
-
renderer.padding.right = 2
|
13
|
-
renderer.padding.top = 1
|
14
|
-
}).to eq unindent(<<-EOS)
|
15
|
-
+----+----+----+
|
16
|
-
| | | |
|
17
|
-
|h1 |h2 |h3 |
|
18
|
-
+----+----+----+
|
19
|
-
| | | |
|
20
|
-
|a1 |a2 |a3 |
|
21
|
-
| | | |
|
22
|
-
|b1 |b2 |b3 |
|
23
|
-
+----+----+----+
|
24
|
-
EOS
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'sets padding for all' do
|
28
|
-
expect(table.render(:ascii) { |renderer|
|
29
|
-
renderer.padding= [1,2,1,2]
|
30
|
-
}).to eq unindent(<<-EOS)
|
31
|
-
+------+------+------+
|
32
|
-
| | | |
|
33
|
-
| h1 | h2 | h3 |
|
34
|
-
| | | |
|
35
|
-
+------+------+------+
|
36
|
-
| | | |
|
37
|
-
| a1 | a2 | a3 |
|
38
|
-
| | | |
|
39
|
-
| | | |
|
40
|
-
| b1 | b2 | b3 |
|
41
|
-
| | | |
|
42
|
-
+------+------+------+
|
43
|
-
EOS
|
44
|
-
end
|
45
|
-
|
46
|
-
context 'with column width' do
|
47
|
-
let(:column_widths) { [4,4,4] }
|
48
|
-
|
49
|
-
it 'sets padding for all' do
|
50
|
-
expect(table.render(:ascii) { |renderer|
|
51
|
-
renderer.column_widths = column_widths
|
52
|
-
renderer.padding= [1,2,1,2]
|
53
|
-
}).to eq unindent(<<-EOS)
|
54
|
-
+--------+--------+--------+
|
55
|
-
| | | |
|
56
|
-
| h1 | h2 | h3 |
|
57
|
-
| | | |
|
58
|
-
+--------+--------+--------+
|
59
|
-
| | | |
|
60
|
-
| a1 | a2 | a3 |
|
61
|
-
| | | |
|
62
|
-
| | | |
|
63
|
-
| b1 | b2 | b3 |
|
64
|
-
| | | |
|
65
|
-
+--------+--------+--------+
|
66
|
-
EOS
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context 'with multi line text' do
|
71
|
-
let(:header) { ['h1', 'head2'] }
|
72
|
-
let(:rows) { [["Multi\nLine", "Text\nthat\nwraps"],
|
73
|
-
["Some\nother\ntext", 'Simple']] }
|
74
|
-
|
75
|
-
context 'when wrapped' do
|
76
|
-
it 'sets padding for all' do
|
77
|
-
expect(table.render(:ascii) { |renderer|
|
78
|
-
renderer.multiline = true
|
79
|
-
renderer.padding= [1,2,1,2]
|
80
|
-
}).to eq unindent(<<-EOS)
|
81
|
-
+---------+----------+
|
82
|
-
| | |
|
83
|
-
| h1 | head2 |
|
84
|
-
| | |
|
85
|
-
+---------+----------+
|
86
|
-
| | |
|
87
|
-
| Multi | Text |
|
88
|
-
| Line | that |
|
89
|
-
| | wraps |
|
90
|
-
| | |
|
91
|
-
| | |
|
92
|
-
| Some | Simple |
|
93
|
-
| other | |
|
94
|
-
| text | |
|
95
|
-
| | |
|
96
|
-
+---------+----------+
|
97
|
-
EOS
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
context 'when escaped' do
|
102
|
-
it 'sets padding for all' do
|
103
|
-
expect(table.render(:ascii) { |renderer|
|
104
|
-
renderer.multiline = false
|
105
|
-
renderer.padding= [0,2,0,2]
|
106
|
-
}).to eq unindent(<<-EOS)
|
107
|
-
+---------------------+---------------------+
|
108
|
-
| h1 | head2 |
|
109
|
-
+---------------------+---------------------+
|
110
|
-
| Multi\\nLine | Text\\nthat\\nwraps |
|
111
|
-
| Some\\nother\\ntext | Simple |
|
112
|
-
+---------------------+---------------------+
|
113
|
-
EOS
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe TTY::Table, 'properties' do
|
6
|
-
let(:rows) {[['a1', 'a2', 'a3'], ['b1', 'b2', 'c3']] }
|
7
|
-
|
8
|
-
subject(:table) { described_class.new rows }
|
9
|
-
|
10
|
-
it { expect(table.width).to eq(6) }
|
11
|
-
|
12
|
-
it { expect(table.rows_size).to eq(2) }
|
13
|
-
|
14
|
-
it { expect(table.columns_size).to eq(3) }
|
15
|
-
|
16
|
-
it { expect(table.size).to eq([2,3]) }
|
17
|
-
|
18
|
-
context 'no size' do
|
19
|
-
let(:rows) { [] }
|
20
|
-
|
21
|
-
it { expect(table.rows_size).to eq(0) }
|
22
|
-
|
23
|
-
it { expect(table.columns_size).to eq(0) }
|
24
|
-
end
|
25
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe TTY::Table, 'render repeat' do
|
6
|
-
|
7
|
-
it "renders consistently" do
|
8
|
-
table = TTY::Table.new header: ['header1', 'header2']
|
9
|
-
table << ['a1', 'a2']
|
10
|
-
table << ['b1', 'b2']
|
11
|
-
options = {padding: [1,1,1,1], alignments: [:right, :center]}
|
12
|
-
expect(table.render(:ascii, options)).to eq unindent(<<-EOS)
|
13
|
-
+---------+---------+
|
14
|
-
| | |
|
15
|
-
| header1 | header2 |
|
16
|
-
| | |
|
17
|
-
+---------+---------+
|
18
|
-
| | |
|
19
|
-
| a1 | a2 |
|
20
|
-
| | |
|
21
|
-
| | |
|
22
|
-
| b1 | b2 |
|
23
|
-
| | |
|
24
|
-
+---------+---------+
|
25
|
-
EOS
|
26
|
-
|
27
|
-
expect(table.render(:ascii, options)).to eq unindent(<<-EOS)
|
28
|
-
+---------+---------+
|
29
|
-
| | |
|
30
|
-
| header1 | header2 |
|
31
|
-
| | |
|
32
|
-
+---------+---------+
|
33
|
-
| | |
|
34
|
-
| a1 | a2 |
|
35
|
-
| | |
|
36
|
-
| | |
|
37
|
-
| b1 | b2 |
|
38
|
-
| | |
|
39
|
-
+---------+---------+
|
40
|
-
EOS
|
41
|
-
end
|
42
|
-
end
|