tty-table 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -0
- data/README.md +458 -142
- data/lib/tty-table.rb +6 -6
- data/lib/tty/table.rb +34 -34
- data/lib/tty/table/alignment_set.rb +73 -0
- data/lib/tty/table/border.rb +54 -36
- data/lib/tty/table/border/null.rb +4 -4
- data/lib/tty/table/{columns.rb → column_constraint.rb} +30 -32
- data/lib/tty/table/column_set.rb +18 -17
- data/lib/tty/table/field.rb +50 -25
- data/lib/tty/table/header.rb +6 -2
- data/lib/tty/table/indentation.rb +7 -12
- data/lib/tty/table/operation/alignment.rb +59 -0
- data/lib/tty/table/operation/escape.rb +1 -1
- data/lib/tty/table/operation/filter.rb +1 -1
- data/lib/tty/table/operation/padding.rb +12 -61
- data/lib/tty/table/operation/truncation.rb +2 -2
- data/lib/tty/table/operation/wrapped.rb +2 -5
- data/lib/tty/table/operations.rb +35 -17
- data/lib/tty/table/orientation/vertical.rb +4 -4
- data/lib/tty/table/renderer.rb +1 -7
- data/lib/tty/table/renderer/basic.rb +69 -63
- data/lib/tty/table/version.rb +1 -1
- data/spec/spec_helper.rb +3 -4
- data/spec/unit/access_spec.rb +8 -8
- data/spec/unit/{operation/alignment_set → alignment_set}/each_spec.rb +1 -1
- data/spec/unit/{operation/alignment_set → alignment_set}/new_spec.rb +4 -4
- data/spec/unit/{operation/alignment_set → alignment_set}/to_ary_spec.rb +1 -1
- data/spec/unit/alignment_spec.rb +71 -0
- data/spec/unit/border/ascii/rendering_spec.rb +12 -12
- data/spec/unit/border/new_spec.rb +2 -2
- data/spec/unit/border/null/rendering_spec.rb +2 -2
- data/spec/unit/border/unicode/rendering_spec.rb +10 -10
- data/spec/unit/{columns → column_constraint}/enforce_spec.rb +15 -12
- data/spec/unit/{columns → column_constraint}/widths_spec.rb +6 -6
- data/spec/unit/column_set/extract_widths_spec.rb +39 -6
- data/spec/unit/data_spec.rb +4 -6
- data/spec/unit/each_spec.rb +8 -23
- data/spec/unit/each_with_index_spec.rb +27 -33
- data/spec/unit/field/length_spec.rb +23 -9
- data/spec/unit/field/width_spec.rb +1 -1
- data/spec/unit/filter_spec.rb +7 -8
- data/spec/unit/header/new_spec.rb +6 -15
- data/spec/unit/indentation/indent_spec.rb +21 -0
- data/spec/unit/new_spec.rb +73 -0
- data/spec/unit/operation/{alignment_set → alignment}/call_spec.rb +1 -1
- data/spec/unit/operation/escape/call_spec.rb +2 -3
- data/spec/unit/operation/filter/call_spec.rb +2 -3
- data/spec/unit/operation/truncation/call_spec.rb +6 -8
- data/spec/unit/operation/wrapped/call_spec.rb +15 -8
- data/spec/unit/operations/new_spec.rb +1 -1
- data/spec/unit/orientation_spec.rb +6 -6
- data/spec/unit/padding_spec.rb +29 -32
- data/spec/unit/properties_spec.rb +4 -4
- data/spec/unit/render_repeat_spec.rb +42 -0
- data/spec/unit/render_spec.rb +1 -1
- data/spec/unit/render_with_spec.rb +3 -3
- data/spec/unit/renderer/ascii/coloring_spec.rb +70 -0
- data/spec/unit/renderer/ascii/multiline_spec.rb +101 -0
- data/spec/unit/renderer/ascii/padding_spec.rb +37 -10
- data/spec/unit/renderer/ascii/render_spec.rb +4 -4
- data/spec/unit/renderer/ascii/resizing_spec.rb +22 -22
- data/spec/unit/renderer/ascii/separator_spec.rb +1 -1
- data/spec/unit/renderer/basic/alignment_spec.rb +20 -20
- data/spec/unit/renderer/basic/coloring_spec.rb +43 -28
- data/spec/unit/renderer/basic/filter_spec.rb +3 -3
- data/spec/unit/renderer/basic/multiline_spec.rb +74 -0
- data/spec/unit/renderer/basic/options_spec.rb +9 -9
- data/spec/unit/renderer/basic/padding_spec.rb +26 -2
- data/spec/unit/renderer/basic/render_spec.rb +4 -4
- data/spec/unit/renderer/basic/resizing_spec.rb +18 -18
- data/spec/unit/renderer/basic/separator_spec.rb +1 -1
- data/spec/unit/renderer/basic/truncation_spec.rb +6 -6
- data/spec/unit/renderer/basic/wrapping_spec.rb +3 -3
- data/spec/unit/renderer/border_spec.rb +4 -4
- data/spec/unit/renderer/unicode/coloring_spec.rb +70 -0
- data/spec/unit/renderer/unicode/indentation_spec.rb +1 -1
- data/spec/unit/renderer/unicode/padding_spec.rb +26 -26
- data/spec/unit/renderer/unicode/render_spec.rb +4 -4
- data/spec/unit/renderer/unicode/separator_spec.rb +1 -1
- data/spec/unit/to_s_spec.rb +4 -11
- data/spec/unit/utf_spec.rb +33 -0
- data/tty-table.gemspec +2 -1
- metadata +52 -32
- data/lib/tty/table/operation/alignment_set.rb +0 -103
- data/lib/tty/table/padder.rb +0 -180
- data/lib/tty/table/renderer/color.rb +0 -12
- data/spec/unit/indentation/insert_indent_spec.rb +0 -27
- data/spec/unit/initialize_spec.rb +0 -88
- data/spec/unit/padder/parse_spec.rb +0 -45
- data/spec/unit/padder/to_s_spec.rb +0 -14
- data/spec/unit/renderer/basic/multiline_content_spec.rb +0 -135
- data/spec/unit/renderer/style_spec.rb +0 -72
@@ -7,12 +7,12 @@ RSpec.describe TTY::Table::Renderer::Basic, 'options' do
|
|
7
7
|
let(:object) { described_class }
|
8
8
|
let(:table) { TTY::Table.new(rows) }
|
9
9
|
let(:widths) { nil }
|
10
|
-
let(:
|
10
|
+
let(:alignments) { [] }
|
11
11
|
let(:options) {
|
12
12
|
{
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
13
|
+
column_widths: widths,
|
14
|
+
alignments: alignments,
|
15
|
+
renderer: :basic
|
16
16
|
}
|
17
17
|
}
|
18
18
|
|
@@ -22,9 +22,9 @@ RSpec.describe TTY::Table::Renderer::Basic, 'options' do
|
|
22
22
|
|
23
23
|
it { expect(renderer.column_widths).to eql([2,2]) }
|
24
24
|
|
25
|
-
it { expect(renderer.
|
25
|
+
it { expect(renderer.alignments.to_a).to eql(alignments) }
|
26
26
|
|
27
|
-
it { expect(renderer.
|
27
|
+
it { expect(renderer.alignments.to_a).to be_empty }
|
28
28
|
|
29
29
|
context '#column_widths' do
|
30
30
|
let(:widths) { [10, 10] }
|
@@ -42,11 +42,11 @@ RSpec.describe TTY::Table::Renderer::Basic, 'options' do
|
|
42
42
|
}
|
43
43
|
end
|
44
44
|
|
45
|
-
context '#
|
46
|
-
let(:
|
45
|
+
context '#alignments' do
|
46
|
+
let(:alignments) { [:center, :center] }
|
47
47
|
|
48
48
|
it 'unwraps original array' do
|
49
|
-
expect(renderer.
|
49
|
+
expect(renderer.alignments.to_a).to eq(alignments)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -21,7 +21,7 @@ RSpec.describe TTY::Table::Renderer::Basic, 'padding' do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
context 'with top & bottom padding' do
|
24
|
-
let(:options) { {padding: [1,0,1,0]
|
24
|
+
let(:options) { {padding: [1,0,1,0]} }
|
25
25
|
|
26
26
|
it 'pads each field' do
|
27
27
|
expect(renderer.render).to eql <<-EOS.chomp
|
@@ -36,7 +36,7 @@ EOS
|
|
36
36
|
end
|
37
37
|
|
38
38
|
context 'with full padding' do
|
39
|
-
let(:options) { {padding: [1,1,1,1]
|
39
|
+
let(:options) { {padding: [1,1,1,1]} }
|
40
40
|
|
41
41
|
it 'pads each field' do
|
42
42
|
expect(renderer.render).to eql <<-EOS.chomp
|
@@ -49,4 +49,28 @@ EOS
|
|
49
49
|
EOS
|
50
50
|
end
|
51
51
|
end
|
52
|
+
|
53
|
+
context "with multiline content padding" do
|
54
|
+
it "pads around fields" do
|
55
|
+
padding = [1,2,1,2]
|
56
|
+
table = TTY::Table.new header: ['header1', 'header2']
|
57
|
+
table << ["a1\na1\na1",'a2']
|
58
|
+
table << ["b1","b2\nb2"]
|
59
|
+
renderer = TTY::Table::Renderer::Basic.new(table, padding: padding, multiline: true)
|
60
|
+
expect(renderer.render).to eql <<-EOS.chomp
|
61
|
+
|
62
|
+
header1 header2
|
63
|
+
|
64
|
+
|
65
|
+
a1 a2
|
66
|
+
a1
|
67
|
+
a1
|
68
|
+
|
69
|
+
|
70
|
+
b1 b2
|
71
|
+
b2
|
72
|
+
|
73
|
+
EOS
|
74
|
+
end
|
75
|
+
end
|
52
76
|
end
|
@@ -13,7 +13,7 @@ RSpec.describe TTY::Table::Renderer::Basic, '#render' do
|
|
13
13
|
let(:table) { TTY::Table.new rows }
|
14
14
|
|
15
15
|
it 'displays table without styling' do
|
16
|
-
expect(renderer.render).to eq <<-EOS
|
16
|
+
expect(renderer.render).to eq unindent(<<-EOS)
|
17
17
|
a1 a2 a3
|
18
18
|
b1 b2 b3
|
19
19
|
EOS
|
@@ -22,7 +22,7 @@ RSpec.describe TTY::Table::Renderer::Basic, '#render' do
|
|
22
22
|
|
23
23
|
context 'with header and rows' do
|
24
24
|
it 'displays table with header' do
|
25
|
-
expect(renderer.render).to eq <<-EOS
|
25
|
+
expect(renderer.render).to eq unindent(<<-EOS)
|
26
26
|
h1 h2 h3
|
27
27
|
a1 a2 a3
|
28
28
|
b1 b2 b3
|
@@ -35,7 +35,7 @@ RSpec.describe TTY::Table::Renderer::Basic, '#render' do
|
|
35
35
|
let(:rows) { [['aaa1', 'a2'], ['b1', 'bb1']] }
|
36
36
|
|
37
37
|
it 'displays table according to widths' do
|
38
|
-
expect(renderer.render).to eq <<-EOS
|
38
|
+
expect(renderer.render).to eq unindent(<<-EOS)
|
39
39
|
h1 h2
|
40
40
|
aaa1 a2
|
41
41
|
b1 bb1
|
@@ -47,7 +47,7 @@ RSpec.describe TTY::Table::Renderer::Basic, '#render' do
|
|
47
47
|
let(:header) { ['header1', 'header2', 'header3'] }
|
48
48
|
|
49
49
|
it 'header greater than row sizes' do
|
50
|
-
expect(renderer.render).to eq <<-EOS
|
50
|
+
expect(renderer.render).to eq unindent(<<-EOS)
|
51
51
|
header1 header2 header3
|
52
52
|
a1 a2 a3
|
53
53
|
b1 b2 b3
|
@@ -14,7 +14,7 @@ RSpec.describe TTY::Table::Renderer::Basic, 'resizing' do
|
|
14
14
|
let(:options) { {width: 16, resize: true} }
|
15
15
|
|
16
16
|
it 'resizes each column' do
|
17
|
-
expect(renderer.render).to eql <<-EOS
|
17
|
+
expect(renderer.render).to eql unindent(<<-EOS)
|
18
18
|
h1 h2 h3
|
19
19
|
a1 a2 a3
|
20
20
|
b1 b2 b3
|
@@ -28,7 +28,7 @@ RSpec.describe TTY::Table::Renderer::Basic, 'resizing' do
|
|
28
28
|
let(:options) { {width: 21, resize: true} }
|
29
29
|
|
30
30
|
it 'resizes each column' do
|
31
|
-
expect(renderer.render).to eql <<-EOS
|
31
|
+
expect(renderer.render).to eql unindent(<<-EOS)
|
32
32
|
h1 h2 h3 h4
|
33
33
|
a1 a2 a3 a4
|
34
34
|
b1 b2 b3 b4
|
@@ -42,7 +42,7 @@ RSpec.describe TTY::Table::Renderer::Basic, 'resizing' do
|
|
42
42
|
let(:options) { {width: 32, resize: true} }
|
43
43
|
|
44
44
|
it 'resizes each column' do
|
45
|
-
expect(renderer.render).to eql <<-EOS
|
45
|
+
expect(renderer.render).to eql unindent(<<-EOS)
|
46
46
|
h1 h2 h3
|
47
47
|
aaa1 aa2 aaaaaaa3
|
48
48
|
b1 b2 b3
|
@@ -56,25 +56,25 @@ RSpec.describe TTY::Table::Renderer::Basic, 'resizing' do
|
|
56
56
|
let(:rows) { [['aaaa1','aaaa2',], ['bbbb1','bbbb2']] }
|
57
57
|
|
58
58
|
context 'even columns' do
|
59
|
-
let(:options) { {width:
|
59
|
+
let(:options) { {width: 8, resize: true} }
|
60
60
|
|
61
61
|
it 'resizes each column' do
|
62
|
-
expect(renderer.render).to eql <<-EOS
|
63
|
-
he…
|
64
|
-
aa…
|
65
|
-
bb…
|
62
|
+
expect(renderer.render).to eql unindent(<<-EOS)
|
63
|
+
he… h…
|
64
|
+
aa… a…
|
65
|
+
bb… b…
|
66
66
|
EOS
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
context 'even columns with extra width' do
|
71
|
-
let(:options) { {width:
|
71
|
+
let(:options) { {width: 9, resize: true} }
|
72
72
|
|
73
73
|
it 'resizes each column' do
|
74
|
-
expect(renderer.render).to eql <<-EOS
|
75
|
-
|
76
|
-
|
77
|
-
|
74
|
+
expect(renderer.render).to eql unindent(<<-EOS)
|
75
|
+
he… he…
|
76
|
+
aa… aa…
|
77
|
+
bb… bb…
|
78
78
|
EOS
|
79
79
|
end
|
80
80
|
end
|
@@ -82,13 +82,13 @@ RSpec.describe TTY::Table::Renderer::Basic, 'resizing' do
|
|
82
82
|
context 'uneven columns' do
|
83
83
|
let(:header) { ['head1', 'head2', 'head3'] }
|
84
84
|
let(:rows) { [['aaa1', 'aa2', 'aaaaaaa3'], ['b1', 'b2', 'b3']] }
|
85
|
-
let(:options) { {width:
|
85
|
+
let(:options) { {width: 16, resize: true} }
|
86
86
|
|
87
87
|
it 'resizes each column' do
|
88
|
-
expect(renderer.render).to eql <<-EOS
|
89
|
-
|
90
|
-
aaa1 aa2
|
91
|
-
b1 b2
|
88
|
+
expect(renderer.render).to eql unindent(<<-EOS)
|
89
|
+
he… he… head3
|
90
|
+
aaa1 aa2 aaaa…
|
91
|
+
b1 b2 b3
|
92
92
|
EOS
|
93
93
|
end
|
94
94
|
end
|
@@ -31,7 +31,7 @@ RSpec.describe TTY::Table::Renderer::Basic, 'with separator' do
|
|
31
31
|
|
32
32
|
it "renders each row" do
|
33
33
|
renderer.border.separator= :each_row
|
34
|
-
expect(renderer.render).to eq <<-EOS
|
34
|
+
expect(renderer.render).to eq unindent(<<-EOS)
|
35
35
|
h1 h2 h3
|
36
36
|
|
37
37
|
a1 a2 a3
|
@@ -13,7 +13,7 @@ RSpec.describe TTY::Table::Renderer::Basic, 'truncation' do
|
|
13
13
|
let(:options) { {} }
|
14
14
|
|
15
15
|
it "doesn't shorten the fields" do
|
16
|
-
expect(renderer.render).to eq <<-EOS
|
16
|
+
expect(renderer.render).to eq unindent(<<-EOS)
|
17
17
|
header1 head2 h3
|
18
18
|
a1111111 a222 a3333333
|
19
19
|
b111 b2222222 b333333
|
@@ -22,13 +22,13 @@ RSpec.describe TTY::Table::Renderer::Basic, 'truncation' do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
context 'with column widths' do
|
25
|
-
let(:options) { { column_widths: [
|
25
|
+
let(:options) { { column_widths: [4, 5, 7] } }
|
26
26
|
|
27
27
|
it 'shortens the fields' do
|
28
|
-
expect(renderer.render).to eq <<-EOS
|
29
|
-
he…
|
30
|
-
a1…
|
31
|
-
|
28
|
+
expect(renderer.render).to eq unindent(<<-EOS)
|
29
|
+
he… head2 h3
|
30
|
+
a1… a222 a3333…
|
31
|
+
b111 b22… b333333
|
32
32
|
EOS
|
33
33
|
end
|
34
34
|
end
|
@@ -12,8 +12,8 @@ RSpec.describe TTY::Table::Renderer::Basic, 'wrapping' do
|
|
12
12
|
context 'without column widths' do
|
13
13
|
let(:options) { {multiline: true} }
|
14
14
|
|
15
|
-
it
|
16
|
-
expect(renderer.render).to eq <<-EOS
|
15
|
+
it "doesn't wrap the fields" do
|
16
|
+
expect(renderer.render).to eq unindent(<<-EOS)
|
17
17
|
header1 head2 h3
|
18
18
|
a1111111 a222 a3333333
|
19
19
|
b111 b2222222 b333333
|
@@ -25,7 +25,7 @@ RSpec.describe TTY::Table::Renderer::Basic, 'wrapping' do
|
|
25
25
|
let(:options) { { column_widths: [3, 5, 7], multiline: true} }
|
26
26
|
|
27
27
|
it 'wraps the fields' do
|
28
|
-
expect(renderer.render).to eq <<-EOS
|
28
|
+
expect(renderer.render).to eq unindent(<<-EOS)
|
29
29
|
hea head2 h3
|
30
30
|
der
|
31
31
|
1
|
@@ -31,7 +31,7 @@ RSpec.describe TTY::Table::Renderer, '#border' do
|
|
31
31
|
mid_mid ' '
|
32
32
|
end
|
33
33
|
|
34
|
-
expect(renderer.render).to eq <<-EOS
|
34
|
+
expect(renderer.render).to eq unindent(<<-EOS)
|
35
35
|
h1 h2 h3
|
36
36
|
== == ==
|
37
37
|
a1 a2 a3
|
@@ -51,7 +51,7 @@ RSpec.describe TTY::Table::Renderer, '#border' do
|
|
51
51
|
mid_right '='
|
52
52
|
end
|
53
53
|
|
54
|
-
expect(renderer.render).to eq <<-EOS
|
54
|
+
expect(renderer.render).to eq unindent(<<-EOS)
|
55
55
|
+--+--+--+
|
56
56
|
|h1|h2|h3|
|
57
57
|
==========
|
@@ -69,7 +69,7 @@ RSpec.describe TTY::Table::Renderer, '#border' do
|
|
69
69
|
'mid_right' => '=',
|
70
70
|
}})
|
71
71
|
|
72
|
-
expect(renderer.render).to eq <<-EOS
|
72
|
+
expect(renderer.render).to eq unindent(<<-EOS)
|
73
73
|
+--+--+--+
|
74
74
|
|h1|h2|h3|
|
75
75
|
==========
|
@@ -91,7 +91,7 @@ RSpec.describe TTY::Table::Renderer, '#border' do
|
|
91
91
|
mid_right '='
|
92
92
|
end
|
93
93
|
|
94
|
-
expect(renderer.render).to eq <<-EOS
|
94
|
+
expect(renderer.render).to eq unindent(<<-EOS)
|
95
95
|
┌──┬──┬──┐
|
96
96
|
│h1│h2│h3│
|
97
97
|
==========
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe TTY::Table::Renderer::Unicode, 'coloring' do
|
6
|
+
|
7
|
+
let(:color) { Pastel.new(enabled: true) }
|
8
|
+
|
9
|
+
before { allow(Pastel).to receive(:new).and_return(color) }
|
10
|
+
|
11
|
+
context 'when border' do
|
12
|
+
it "colors border" do
|
13
|
+
table = TTY::Table.new header: ['header1', 'header2']
|
14
|
+
table << ['a1', 'a2']
|
15
|
+
table << ['b1', 'b2']
|
16
|
+
renderer = described_class.new(table)
|
17
|
+
renderer.border = {style: :green }
|
18
|
+
|
19
|
+
expect(renderer.render).to eq unindent(<<-EOS)
|
20
|
+
#{color.green('┌───────┬───────┐')}
|
21
|
+
#{color.green('│')}header1#{color.green('│')}header2#{color.green('│')}
|
22
|
+
#{color.green('├───────┼───────┤')}
|
23
|
+
#{color.green('│')}a1 #{color.green('│')}a2 #{color.green('│')}
|
24
|
+
#{color.green('│')}b1 #{color.green('│')}b2 #{color.green('│')}
|
25
|
+
#{color.green('└───────┴───────┘')}
|
26
|
+
EOS
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when content' do
|
31
|
+
it "colors individual field" do
|
32
|
+
header = [color.yellow('header1'), 'header2']
|
33
|
+
table = TTY::Table.new header: header
|
34
|
+
table << [color.green.on_blue('a1'), 'a2']
|
35
|
+
table << ['b1', color.red.on_yellow('b2')]
|
36
|
+
renderer = described_class.new(table)
|
37
|
+
|
38
|
+
expect(renderer.render).to eq unindent(<<-EOS)
|
39
|
+
┌───────┬───────┐
|
40
|
+
│#{color.yellow('header1')}│header2│
|
41
|
+
├───────┼───────┤
|
42
|
+
│#{color.green.on_blue('a1')} │a2 │
|
43
|
+
│b1 │#{color.red.on_yellow('b2')} │
|
44
|
+
└───────┴───────┘
|
45
|
+
EOS
|
46
|
+
end
|
47
|
+
|
48
|
+
it "colors multiline content" do
|
49
|
+
header = [color.yellow("Multi\nHeader"), 'header2']
|
50
|
+
table = TTY::Table.new header: header
|
51
|
+
table << [color.green.on_blue("Multi\nLine\nContent"), 'a2']
|
52
|
+
table << ['b1', color.red.on_yellow("Multi\nLine\nContent")]
|
53
|
+
renderer = described_class.new(table, multiline: true)
|
54
|
+
|
55
|
+
expect(renderer.render).to eq unindent(<<-EOS)
|
56
|
+
┌───────┬───────┐
|
57
|
+
│#{color.yellow('Multi ')}│header2│
|
58
|
+
│#{color.yellow('Header')} │ │
|
59
|
+
├───────┼───────┤
|
60
|
+
│#{color.green.on_blue('Multi ')}│a2 │
|
61
|
+
│#{color.green.on_blue('Line ')}│ │
|
62
|
+
│#{color.green.on_blue('Content')}│ │
|
63
|
+
│b1 │#{color.red.on_yellow("Multi ")}│
|
64
|
+
│ │#{color.red.on_yellow("Line ")}│
|
65
|
+
│ │#{color.red.on_yellow("Content")}│
|
66
|
+
└───────┴───────┘
|
67
|
+
EOS
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -13,12 +13,12 @@ RSpec.describe TTY::Table::Renderer::Unicode, 'padding' do
|
|
13
13
|
let(:options) { {padding: [0,1,0,1]} }
|
14
14
|
|
15
15
|
it 'pads each field' do
|
16
|
-
expect(renderer.render).to eql <<-EOS
|
17
|
-
┌───────┬─────────┬──────┬─────┬─────────┬───────┐
|
18
|
-
│ Field │ Type │ Null │ Key │ Default │ Extra │
|
19
|
-
├───────┼─────────┼──────┼─────┼─────────┼───────┤
|
20
|
-
│ id │ int(11) │ YES │ nil │ NULL │ │
|
21
|
-
└───────┴─────────┴──────┴─────┴─────────┴───────┘
|
16
|
+
expect(renderer.render).to eql unindent(<<-EOS)
|
17
|
+
┌───────┬─────────┬──────┬─────┬─────────┬───────┐
|
18
|
+
│ Field │ Type │ Null │ Key │ Default │ Extra │
|
19
|
+
├───────┼─────────┼──────┼─────┼─────────┼───────┤
|
20
|
+
│ id │ int(11) │ YES │ nil │ NULL │ │
|
21
|
+
└───────┴─────────┴──────┴─────┴─────────┴───────┘
|
22
22
|
EOS
|
23
23
|
end
|
24
24
|
end
|
@@ -27,16 +27,16 @@ RSpec.describe TTY::Table::Renderer::Unicode, 'padding' do
|
|
27
27
|
let(:options) { {padding: [1,0,1,0], multiline: true} }
|
28
28
|
|
29
29
|
it 'pads each field' do
|
30
|
-
expect(renderer.render).to eql <<-EOS
|
31
|
-
┌─────┬───────┬────┬───┬───────┬─────┐
|
32
|
-
│ │ │ │ │ │ │
|
33
|
-
│Field│Type │Null│Key│Default│Extra│
|
34
|
-
│ │ │ │ │ │ │
|
35
|
-
├─────┼───────┼────┼───┼───────┼─────┤
|
36
|
-
│ │ │ │ │ │ │
|
37
|
-
│id │int(11)│YES │nil│NULL │ │
|
38
|
-
│ │ │ │ │ │ │
|
39
|
-
└─────┴───────┴────┴───┴───────┴─────┘
|
30
|
+
expect(renderer.render).to eql unindent(<<-EOS)
|
31
|
+
┌─────┬───────┬────┬───┬───────┬─────┐
|
32
|
+
│ │ │ │ │ │ │
|
33
|
+
│Field│Type │Null│Key│Default│Extra│
|
34
|
+
│ │ │ │ │ │ │
|
35
|
+
├─────┼───────┼────┼───┼───────┼─────┤
|
36
|
+
│ │ │ │ │ │ │
|
37
|
+
│id │int(11)│YES │nil│NULL │ │
|
38
|
+
│ │ │ │ │ │ │
|
39
|
+
└─────┴───────┴────┴───┴───────┴─────┘
|
40
40
|
EOS
|
41
41
|
end
|
42
42
|
end
|
@@ -45,16 +45,16 @@ RSpec.describe TTY::Table::Renderer::Unicode, 'padding' do
|
|
45
45
|
let(:options) { {padding: [1,1,1,1], multiline: true} }
|
46
46
|
|
47
47
|
it 'pads each field' do
|
48
|
-
expect(renderer.render).to eql <<-EOS
|
49
|
-
┌───────┬─────────┬──────┬─────┬─────────┬───────┐
|
50
|
-
│ │ │ │ │ │ │
|
51
|
-
│ Field │ Type │ Null │ Key │ Default │ Extra │
|
52
|
-
│ │ │ │ │ │ │
|
53
|
-
├───────┼─────────┼──────┼─────┼─────────┼───────┤
|
54
|
-
│ │ │ │ │ │ │
|
55
|
-
│ id │ int(11) │ YES │ nil │ NULL │ │
|
56
|
-
│ │ │ │ │ │ │
|
57
|
-
└───────┴─────────┴──────┴─────┴─────────┴───────┘
|
48
|
+
expect(renderer.render).to eql unindent(<<-EOS)
|
49
|
+
┌───────┬─────────┬──────┬─────┬─────────┬───────┐
|
50
|
+
│ │ │ │ │ │ │
|
51
|
+
│ Field │ Type │ Null │ Key │ Default │ Extra │
|
52
|
+
│ │ │ │ │ │ │
|
53
|
+
├───────┼─────────┼──────┼─────┼─────────┼───────┤
|
54
|
+
│ │ │ │ │ │ │
|
55
|
+
│ id │ int(11) │ YES │ nil │ NULL │ │
|
56
|
+
│ │ │ │ │ │ │
|
57
|
+
└───────┴─────────┴──────┴─────┴─────────┴───────┘
|
58
58
|
EOS
|
59
59
|
end
|
60
60
|
end
|