tty 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -1
- data/README.md +19 -7
- data/lib/tty.rb +10 -0
- data/lib/tty/support/equatable.rb +1 -0
- data/lib/tty/support/unicode.rb +36 -0
- data/lib/tty/table.rb +3 -3
- data/lib/tty/table/border.rb +104 -0
- data/lib/tty/table/border/ascii.rb +41 -0
- data/lib/tty/table/border/null.rb +49 -0
- data/lib/tty/table/border/unicode.rb +41 -0
- data/lib/tty/table/column_set.rb +77 -0
- data/lib/tty/table/operation/alignment.rb +2 -0
- data/lib/tty/table/operation/alignment_set.rb +4 -58
- data/lib/tty/table/operation/truncation.rb +15 -19
- data/lib/tty/table/operation/wrapped.rb +34 -0
- data/lib/tty/table/renderer.rb +8 -11
- data/lib/tty/table/renderer/ascii.rb +15 -0
- data/lib/tty/table/renderer/basic.rb +21 -34
- data/lib/tty/table/renderer/unicode.rb +2 -2
- data/lib/tty/vector.rb +117 -0
- data/lib/tty/version.rb +1 -1
- data/spec/tty/table/border/ascii/rendering_spec.rb +49 -0
- data/spec/tty/table/border/new_spec.rb +21 -0
- data/spec/tty/table/border/null/rendering_spec.rb +49 -0
- data/spec/tty/table/border/unicode/rendering_spec.rb +49 -0
- data/spec/tty/table/column_set/extract_widths_spec.rb +26 -0
- data/spec/tty/table/operation/alignment_set/align_rows_spec.rb +4 -4
- data/spec/tty/table/operation/alignment_set/new_spec.rb +1 -1
- data/spec/tty/table/operation/wrapped/wrap_spec.rb +22 -0
- data/spec/tty/table/properties_spec.rb +3 -0
- data/spec/tty/table/renderer/basic/render_spec.rb +144 -33
- data/spec/tty/table/renderer/pick_renderer_spec.rb +25 -0
- data/spec/tty/table/to_s_spec.rb +51 -0
- data/spec/tty/vector/new_spec.rb +47 -0
- metadata +35 -8
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe TTY::Table::Renderer, '#pick_renderer' do
|
6
|
+
let(:klass) { ::Class.new }
|
7
|
+
let(:instance) { klass.new }
|
8
|
+
|
9
|
+
subject { instance.pick_renderer renderer}
|
10
|
+
|
11
|
+
before { klass.send :include, described_class }
|
12
|
+
|
13
|
+
context 'with basic' do
|
14
|
+
let(:renderer) { :basic }
|
15
|
+
|
16
|
+
it { should be_instance_of(TTY::Table::Renderer::Basic) }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'with unicode' do
|
20
|
+
let(:renderer) { :unicode }
|
21
|
+
|
22
|
+
it { should be_instance_of(TTY::Table::Renderer::Unicode) }
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe TTY::Table, '#to_s' do
|
6
|
+
let(:header) { ['h1', 'h2', 'h3'] }
|
7
|
+
let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] }
|
8
|
+
let(:renderer) { :basic }
|
9
|
+
|
10
|
+
subject { described_class.new header, rows, :renderer => renderer }
|
11
|
+
|
12
|
+
context 'without border' do
|
13
|
+
it 'displays table' do
|
14
|
+
subject.to_s.should == <<-EOS.normalize
|
15
|
+
h1 h2 h3
|
16
|
+
a1 a2 a3
|
17
|
+
b1 b2 b3
|
18
|
+
EOS
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'with ascii border' do
|
23
|
+
let(:renderer) { :ascii }
|
24
|
+
|
25
|
+
it 'displays table' do
|
26
|
+
subject.to_s.should == <<-EOS.normalize
|
27
|
+
+--+--+--+
|
28
|
+
|h1|h2|h3|
|
29
|
+
+--+--+--+
|
30
|
+
|a1|a2|a3|
|
31
|
+
|b1|b2|b3|
|
32
|
+
+--+--+--+
|
33
|
+
EOS
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'with unicode border' do
|
38
|
+
let(:renderer) { :unicode}
|
39
|
+
|
40
|
+
it 'displays table' do
|
41
|
+
subject.to_s.should == <<-EOS.normalize
|
42
|
+
┌──┬──┬──┐
|
43
|
+
│h1│h2│h3│
|
44
|
+
├──┼──┼──┤
|
45
|
+
│a1│a2│a3│
|
46
|
+
│b1│b2│b3│
|
47
|
+
└──┴──┴──┘
|
48
|
+
EOS
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe TTY::Vector, '#new' do
|
6
|
+
let(:object) { described_class }
|
7
|
+
|
8
|
+
subject { object.new(argument) }
|
9
|
+
|
10
|
+
context 'with no arguments' do
|
11
|
+
subject { object.new }
|
12
|
+
|
13
|
+
it 'sets elements to empty array' do
|
14
|
+
subject.to_a.should == []
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'with nil argument' do
|
19
|
+
let(:argument) { nil }
|
20
|
+
|
21
|
+
it 'throws type error' do
|
22
|
+
expect { subject }.to raise_error(TTY::TypeError)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'with an argument that is a hash' do
|
27
|
+
let(:argument) { {:value => 'Piotr'} }
|
28
|
+
|
29
|
+
it 'sets elements' do
|
30
|
+
subject.to_a.should == [[:value, 'Piotr']]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'with an argument that respond to #to_ary' do
|
35
|
+
let(:argument) {
|
36
|
+
Class.new do
|
37
|
+
def to_ary
|
38
|
+
['Piotr']
|
39
|
+
end
|
40
|
+
end.new
|
41
|
+
}
|
42
|
+
|
43
|
+
it 'sets elements' do
|
44
|
+
subject.to_a.should == ['Piotr']
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &2152426380 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2152426380
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &2152425900 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2152425900
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: yard
|
38
|
-
requirement: &
|
38
|
+
requirement: &2152425460 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2152425460
|
47
47
|
description: Toolbox for developing CLI clients
|
48
48
|
email:
|
49
49
|
- ''
|
@@ -66,19 +66,28 @@ files:
|
|
66
66
|
- lib/tty/support/conversion.rb
|
67
67
|
- lib/tty/support/delegatable.rb
|
68
68
|
- lib/tty/support/equatable.rb
|
69
|
+
- lib/tty/support/unicode.rb
|
69
70
|
- lib/tty/support/utils.rb
|
70
71
|
- lib/tty/system.rb
|
71
72
|
- lib/tty/table.rb
|
73
|
+
- lib/tty/table/border.rb
|
74
|
+
- lib/tty/table/border/ascii.rb
|
75
|
+
- lib/tty/table/border/null.rb
|
76
|
+
- lib/tty/table/border/unicode.rb
|
77
|
+
- lib/tty/table/column_set.rb
|
72
78
|
- lib/tty/table/error.rb
|
73
79
|
- lib/tty/table/operation/alignment.rb
|
74
80
|
- lib/tty/table/operation/alignment_set.rb
|
75
81
|
- lib/tty/table/operation/truncation.rb
|
82
|
+
- lib/tty/table/operation/wrapped.rb
|
76
83
|
- lib/tty/table/renderer.rb
|
84
|
+
- lib/tty/table/renderer/ascii.rb
|
77
85
|
- lib/tty/table/renderer/basic.rb
|
78
86
|
- lib/tty/table/renderer/color.rb
|
79
87
|
- lib/tty/table/renderer/unicode.rb
|
80
88
|
- lib/tty/table/validatable.rb
|
81
89
|
- lib/tty/terminal.rb
|
90
|
+
- lib/tty/vector.rb
|
82
91
|
- lib/tty/version.rb
|
83
92
|
- spec/spec_helper.rb
|
84
93
|
- spec/tty/color_spec.rb
|
@@ -89,6 +98,11 @@ files:
|
|
89
98
|
- spec/tty/support/fixtures/classes.rb
|
90
99
|
- spec/tty/system/platform_spec.rb
|
91
100
|
- spec/tty/table/access_spec.rb
|
101
|
+
- spec/tty/table/border/ascii/rendering_spec.rb
|
102
|
+
- spec/tty/table/border/new_spec.rb
|
103
|
+
- spec/tty/table/border/null/rendering_spec.rb
|
104
|
+
- spec/tty/table/border/unicode/rendering_spec.rb
|
105
|
+
- spec/tty/table/column_set/extract_widths_spec.rb
|
92
106
|
- spec/tty/table/each_spec.rb
|
93
107
|
- spec/tty/table/empty_spec.rb
|
94
108
|
- spec/tty/table/eql_spec.rb
|
@@ -100,6 +114,7 @@ files:
|
|
100
114
|
- spec/tty/table/operation/alignment_set/new_spec.rb
|
101
115
|
- spec/tty/table/operation/alignment_set/to_ary_spec.rb
|
102
116
|
- spec/tty/table/operation/truncation/truncate_spec.rb
|
117
|
+
- spec/tty/table/operation/wrapped/wrap_spec.rb
|
103
118
|
- spec/tty/table/options_spec.rb
|
104
119
|
- spec/tty/table/properties_spec.rb
|
105
120
|
- spec/tty/table/renderer/basic/alignment_spec.rb
|
@@ -107,9 +122,12 @@ files:
|
|
107
122
|
- spec/tty/table/renderer/basic/new_spec.rb
|
108
123
|
- spec/tty/table/renderer/basic/render_spec.rb
|
109
124
|
- spec/tty/table/renderer/basic_spec.rb
|
125
|
+
- spec/tty/table/renderer/pick_renderer_spec.rb
|
110
126
|
- spec/tty/table/renderer_spec.rb
|
127
|
+
- spec/tty/table/to_s_spec.rb
|
111
128
|
- spec/tty/table/validatable_spec.rb
|
112
129
|
- spec/tty/terminal/size_spec.rb
|
130
|
+
- spec/tty/vector/new_spec.rb
|
113
131
|
- tasks/metrics/cane.rake
|
114
132
|
- tasks/metrics/flog.rake
|
115
133
|
- tasks/metrics/reek.rake
|
@@ -148,6 +166,11 @@ test_files:
|
|
148
166
|
- spec/tty/support/fixtures/classes.rb
|
149
167
|
- spec/tty/system/platform_spec.rb
|
150
168
|
- spec/tty/table/access_spec.rb
|
169
|
+
- spec/tty/table/border/ascii/rendering_spec.rb
|
170
|
+
- spec/tty/table/border/new_spec.rb
|
171
|
+
- spec/tty/table/border/null/rendering_spec.rb
|
172
|
+
- spec/tty/table/border/unicode/rendering_spec.rb
|
173
|
+
- spec/tty/table/column_set/extract_widths_spec.rb
|
151
174
|
- spec/tty/table/each_spec.rb
|
152
175
|
- spec/tty/table/empty_spec.rb
|
153
176
|
- spec/tty/table/eql_spec.rb
|
@@ -159,6 +182,7 @@ test_files:
|
|
159
182
|
- spec/tty/table/operation/alignment_set/new_spec.rb
|
160
183
|
- spec/tty/table/operation/alignment_set/to_ary_spec.rb
|
161
184
|
- spec/tty/table/operation/truncation/truncate_spec.rb
|
185
|
+
- spec/tty/table/operation/wrapped/wrap_spec.rb
|
162
186
|
- spec/tty/table/options_spec.rb
|
163
187
|
- spec/tty/table/properties_spec.rb
|
164
188
|
- spec/tty/table/renderer/basic/alignment_spec.rb
|
@@ -166,7 +190,10 @@ test_files:
|
|
166
190
|
- spec/tty/table/renderer/basic/new_spec.rb
|
167
191
|
- spec/tty/table/renderer/basic/render_spec.rb
|
168
192
|
- spec/tty/table/renderer/basic_spec.rb
|
193
|
+
- spec/tty/table/renderer/pick_renderer_spec.rb
|
169
194
|
- spec/tty/table/renderer_spec.rb
|
195
|
+
- spec/tty/table/to_s_spec.rb
|
170
196
|
- spec/tty/table/validatable_spec.rb
|
171
197
|
- spec/tty/terminal/size_spec.rb
|
198
|
+
- spec/tty/vector/new_spec.rb
|
172
199
|
has_rdoc:
|