vedeu 0.0.32 → 0.0.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vedeu/application.rb +2 -0
- data/lib/vedeu/launcher.rb +1 -1
- data/lib/vedeu/models/colour.rb +7 -7
- data/lib/vedeu/models/command.rb +2 -0
- data/lib/vedeu/models/composition.rb +2 -2
- data/lib/vedeu/models/interface.rb +15 -6
- data/lib/vedeu/models/line.rb +5 -3
- data/lib/vedeu/models/presentation.rb +3 -3
- data/lib/vedeu/models/stream.rb +6 -3
- data/lib/vedeu/models/style.rb +31 -0
- data/lib/vedeu/output/interface_renderer.rb +1 -3
- data/lib/vedeu/support/coordinate.rb +21 -7
- data/lib/vedeu/support/parsing/json_parser.rb +3 -3
- data/test/lib/vedeu/application_test.rb +0 -11
- data/test/lib/vedeu/launcher_test.rb +0 -8
- data/test/lib/vedeu/models/collection_test.rb +3 -3
- data/test/lib/vedeu/models/colour_test.rb +7 -2
- data/test/lib/vedeu/models/command_test.rb +0 -6
- data/test/lib/vedeu/models/composition_test.rb +127 -37
- data/test/lib/vedeu/models/interface_collection_test.rb +8 -9
- data/test/lib/vedeu/models/interface_test.rb +64 -18
- data/test/lib/vedeu/models/line_test.rb +3 -7
- data/test/lib/vedeu/models/presentation_test.rb +7 -5
- data/test/lib/vedeu/models/stream_test.rb +21 -11
- data/test/lib/vedeu/models/style_test.rb +86 -0
- data/test/lib/vedeu/output/interface_renderer_test.rb +32 -5
- data/test/lib/vedeu/output/output_test.rb +8 -1
- data/test/lib/vedeu/repository/command_repository_test.rb +14 -10
- data/test/lib/vedeu/repository/interface_repository_test.rb +9 -9
- data/test/lib/vedeu/support/coordinate_test.rb +72 -19
- data/test/lib/vedeu/support/menu_test.rb +16 -16
- data/test/lib/vedeu/support/parsing/hash_parser_test.rb +7 -7
- data/test/lib/vedeu/support/parsing/json_parser_test.rb +1 -1
- data/test/lib/vedeu/support/terminal_test.rb +0 -7
- data/test/lib/vedeu_test.rb +0 -5
- data/test/test_helper.rb +1 -0
- data/vedeu.gemspec +2 -3
- metadata +7 -25
- data/lib/vedeu/models/style_collection.rb +0 -19
- data/lib/vedeu/support/geometry.rb +0 -62
- data/test/lib/vedeu/models/style_collection_test.rb +0 -13
- data/test/lib/vedeu/support/geometry_test.rb +0 -107
@@ -9,8 +9,8 @@ module Vedeu
|
|
9
9
|
Composition.new({
|
10
10
|
interfaces: {
|
11
11
|
name: 'dummy',
|
12
|
-
width:
|
13
|
-
height:
|
12
|
+
width: 5,
|
13
|
+
height: 5
|
14
14
|
}
|
15
15
|
}).interfaces.first.must_be_instance_of(Interface)
|
16
16
|
end
|
@@ -24,8 +24,8 @@ module Vedeu
|
|
24
24
|
it 'returns a collection of interfaces' do
|
25
25
|
Composition.enqueue({
|
26
26
|
interfaces: [
|
27
|
-
{ name: 'enq1', lines: { streams: { text: 'Composition.enqueue 1' } } },
|
28
|
-
{ name: 'enq2', lines: { streams: { text: 'Composition.enqueue 2' } } }
|
27
|
+
{ name: 'enq1', width: 5, height: 5, lines: { streams: { text: 'Composition.enqueue 1' } } },
|
28
|
+
{ name: 'enq2', width: 5, height: 5, lines: { streams: { text: 'Composition.enqueue 2' } } }
|
29
29
|
]
|
30
30
|
}).interfaces.first.must_be_instance_of(Interface)
|
31
31
|
end
|
@@ -33,8 +33,8 @@ module Vedeu
|
|
33
33
|
it 'enqueues the interfaces for rendering' do
|
34
34
|
Composition.enqueue({
|
35
35
|
interfaces: [
|
36
|
-
{ name: 'enq1', lines: { streams: { text: 'Composition.enqueue 3' } } },
|
37
|
-
{ name: 'enq2', lines: { streams: { text: 'Composition.enqueue 4' } } }
|
36
|
+
{ name: 'enq1', width: 5, height: 5, lines: { streams: { text: 'Composition.enqueue 3' } } },
|
37
|
+
{ name: 'enq2', width: 5, height: 5, lines: { streams: { text: 'Composition.enqueue 4' } } }
|
38
38
|
]
|
39
39
|
}).interfaces.first.enqueued?.must_equal(true)
|
40
40
|
end
|
@@ -42,9 +42,21 @@ module Vedeu
|
|
42
42
|
|
43
43
|
describe '#to_json' do
|
44
44
|
it 'returns the model as JSON' do
|
45
|
-
attributes = {
|
45
|
+
attributes = {
|
46
|
+
interfaces: [
|
47
|
+
{
|
48
|
+
name: 'Composition#to_json',
|
49
|
+
width: 5,
|
50
|
+
height: 5,
|
51
|
+
colour: {
|
52
|
+
foreground: '#ffff33',
|
53
|
+
background: '#ffff77'
|
54
|
+
}
|
55
|
+
}
|
56
|
+
]
|
57
|
+
}
|
46
58
|
|
47
|
-
Composition.new(attributes).to_json.must_equal("{\"interfaces\":[{\"colour\":
|
59
|
+
Composition.new(attributes).to_json.must_equal("{\"interfaces\":[{\"colour\":{\"foreground\":\"\#ffff33\",\"background\":\"\#ffff77\"},\"style\":\"\",\"name\":\"Composition#to_json\",\"lines\":[],\"y\":1,\"x\":1,\"z\":1,\"width\":5,\"height\":5,\"cursor\":true}]}")
|
48
60
|
end
|
49
61
|
end
|
50
62
|
|
@@ -52,86 +64,164 @@ module Vedeu
|
|
52
64
|
it 'returns the stringified content for a single interface, single line, single stream' do
|
53
65
|
InterfaceRepository.create({ name: 'int1_lin1_str1', y: 3, x: 3, width: 10, height: 3 })
|
54
66
|
json = File.read('test/support/json/int1_lin1_str1.json')
|
55
|
-
attributes =
|
56
|
-
|
57
|
-
Composition.new(attributes).to_s.must_equal(
|
67
|
+
attributes = JSON.load(json, nil, symbolize_names: true)
|
68
|
+
|
69
|
+
Composition.new(attributes).to_s.must_equal(
|
70
|
+
"\e[3;3H \e[3;3H" \
|
71
|
+
"\e[4;3H \e[4;3H" \
|
72
|
+
"\e[5;3H \e[5;3H" \
|
73
|
+
"\e[3;3HSome text..."
|
74
|
+
)
|
58
75
|
end
|
59
76
|
|
60
77
|
it 'returns the stringified content for a single interface, single line, multiple streams' do
|
61
78
|
InterfaceRepository.create({ name: 'int1_lin1_str3', y: 3, x: 3, width: 10, height: 3 })
|
62
79
|
json = File.read('test/support/json/int1_lin1_str3.json')
|
63
|
-
attributes =
|
64
|
-
|
65
|
-
Composition.new(attributes).to_s.must_equal(
|
80
|
+
attributes = JSON.load(json, nil, symbolize_names: true)
|
81
|
+
|
82
|
+
Composition.new(attributes).to_s.must_equal(
|
83
|
+
"\e[3;3H \e[3;3H" \
|
84
|
+
"\e[4;3H \e[4;3H" \
|
85
|
+
"\e[5;3H \e[5;3H" \
|
86
|
+
"\e[3;3HSome text... more text..."
|
87
|
+
)
|
66
88
|
end
|
67
89
|
|
68
90
|
it 'returns the stringified content for a single interface, multiple lines, single stream' do
|
69
91
|
InterfaceRepository.create({ name: 'int1_lin2_str1', y: 3, x: 3, width: 10, height: 3 })
|
70
92
|
json = File.read('test/support/json/int1_lin2_str1.json')
|
71
|
-
attributes =
|
72
|
-
|
73
|
-
Composition.new(attributes).to_s.must_equal(
|
93
|
+
attributes = JSON.load(json, nil, symbolize_names: true)
|
94
|
+
|
95
|
+
Composition.new(attributes).to_s.must_equal(
|
96
|
+
"\e[3;3H \e[3;3H" \
|
97
|
+
"\e[4;3H \e[4;3H" \
|
98
|
+
"\e[5;3H \e[5;3H" \
|
99
|
+
"\e[3;3HSome text..." \
|
100
|
+
"\e[4;3HSome text..."
|
101
|
+
)
|
74
102
|
end
|
75
103
|
|
76
104
|
it 'returns the stringified content for a single interface, multiple lines, multiple streams' do
|
77
105
|
InterfaceRepository.create({ name: 'int1_lin2_str3', y: 3, x: 3, width: 10, height: 3 })
|
78
106
|
json = File.read('test/support/json/int1_lin2_str3.json')
|
79
|
-
attributes =
|
80
|
-
|
81
|
-
Composition.new(attributes).to_s.must_equal(
|
107
|
+
attributes = JSON.load(json, nil, symbolize_names: true)
|
108
|
+
|
109
|
+
Composition.new(attributes).to_s.must_equal(
|
110
|
+
"\e[3;3H \e[3;3H" \
|
111
|
+
"\e[4;3H \e[4;3H" \
|
112
|
+
"\e[5;3H \e[5;3H" \
|
113
|
+
"\e[3;3HSome text... more text..." \
|
114
|
+
"\e[4;3HSome text... more text..."
|
115
|
+
)
|
82
116
|
end
|
83
117
|
|
84
118
|
it 'returns the stringified content for a single interface, multiple lines, multiple streams, streams contain styles' do
|
85
119
|
json = File.read('test/support/json/int1_lin2_str3_styles.json')
|
86
|
-
attributes =
|
120
|
+
attributes = JSON.load(json, nil, symbolize_names: true)
|
87
121
|
InterfaceRepository.create({ name: 'int1_lin2_str3_styles', y: 3, x: 3, width: 10, height: 3 })
|
88
122
|
|
89
|
-
Composition.new(attributes).to_s.must_equal(
|
123
|
+
Composition.new(attributes).to_s.must_equal(
|
124
|
+
"\e[3;3H \e[3;3H" \
|
125
|
+
"\e[4;3H \e[4;3H" \
|
126
|
+
"\e[5;3H \e[5;3H" \
|
127
|
+
"\e[3;3H\e[38;5;16m\e[48;5;21m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;5;226m\e[48;5;46m\e[24m\e[21m\e[27m \e[38;5;231m\e[48;5;201m\e[1mmore text..."
|
128
|
+
)
|
90
129
|
end
|
91
130
|
|
92
131
|
it 'returns the stringified content for multiple interfaces, single line, single stream' do
|
93
132
|
InterfaceRepository.create({ name: 'int2_lin1_str1_1', y: 3, x: 3, width: 10, height: 3 })
|
94
133
|
InterfaceRepository.create({ name: 'int2_lin1_str1_2', y: 6, x: 6, width: 10, height: 3 })
|
95
134
|
json = File.read('test/support/json/int2_lin1_str1.json')
|
96
|
-
attributes =
|
97
|
-
|
98
|
-
Composition.new(attributes).to_s.must_equal(
|
135
|
+
attributes = JSON.load(json, nil, symbolize_names: true)
|
136
|
+
|
137
|
+
Composition.new(attributes).to_s.must_equal(
|
138
|
+
"\e[3;3H \e[3;3H" \
|
139
|
+
"\e[4;3H \e[4;3H" \
|
140
|
+
"\e[5;3H \e[5;3H" \
|
141
|
+
"\e[3;3HSome text..." \
|
142
|
+
"\e[6;6H \e[6;6H" \
|
143
|
+
"\e[7;6H \e[7;6H" \
|
144
|
+
"\e[8;6H \e[8;6H" \
|
145
|
+
"\e[6;6HSome text..."
|
146
|
+
)
|
99
147
|
end
|
100
148
|
|
101
149
|
it 'returns the stringified content for multiple interfaces, single line, multiple streams' do
|
102
150
|
InterfaceRepository.create({ name: 'int2_lin1_str3_1', y: 3, x: 3, width: 10, height: 3 })
|
103
151
|
InterfaceRepository.create({ name: 'int2_lin1_str3_2', y: 6, x: 6, width: 10, height: 3 })
|
104
152
|
json = File.read('test/support/json/int2_lin1_str3.json')
|
105
|
-
attributes =
|
106
|
-
|
107
|
-
Composition.new(attributes).to_s.must_equal(
|
153
|
+
attributes = JSON.load(json, nil, symbolize_names: true)
|
154
|
+
|
155
|
+
Composition.new(attributes).to_s.must_equal(
|
156
|
+
"\e[3;3H \e[3;3H" \
|
157
|
+
"\e[4;3H \e[4;3H" \
|
158
|
+
"\e[5;3H \e[5;3H" \
|
159
|
+
"\e[3;3HSome text... more text..." \
|
160
|
+
"\e[6;6H \e[6;6H" \
|
161
|
+
"\e[7;6H \e[7;6H" \
|
162
|
+
"\e[8;6H \e[8;6H" \
|
163
|
+
"\e[6;6HSome text... more text..."
|
164
|
+
)
|
108
165
|
end
|
109
166
|
|
110
167
|
it 'returns the stringified content for multiple interfaces, multiple lines, single stream' do
|
111
168
|
InterfaceRepository.create({ name: 'int2_lin2_str1_1', y: 3, x: 3, width: 10, height: 3 })
|
112
169
|
InterfaceRepository.create({ name: 'int2_lin2_str1_2', y: 6, x: 6, width: 10, height: 3 })
|
113
170
|
json = File.read('test/support/json/int2_lin2_str1.json')
|
114
|
-
attributes =
|
115
|
-
|
116
|
-
Composition.new(attributes).to_s.must_equal(
|
171
|
+
attributes = JSON.load(json, nil, symbolize_names: true)
|
172
|
+
|
173
|
+
Composition.new(attributes).to_s.must_equal(
|
174
|
+
"\e[3;3H \e[3;3H" \
|
175
|
+
"\e[4;3H \e[4;3H" \
|
176
|
+
"\e[5;3H \e[5;3H" \
|
177
|
+
"\e[3;3HSome text..." \
|
178
|
+
"\e[4;3HSome text..." \
|
179
|
+
"\e[3;3H \e[3;3H" \
|
180
|
+
"\e[4;3H \e[4;3H" \
|
181
|
+
"\e[5;3H \e[5;3H" \
|
182
|
+
"\e[3;3HSome text..." \
|
183
|
+
"\e[4;3HSome text..."
|
184
|
+
)
|
117
185
|
end
|
118
186
|
|
119
187
|
it 'returns the stringified content for multiple interfaces, multiple lines, multiple streams' do
|
120
188
|
InterfaceRepository.create({ name: 'int2_lin2_str3_1', y: 3, x: 3, width: 10, height: 3 })
|
121
189
|
InterfaceRepository.create({ name: 'int2_lin2_str3_2', y: 6, x: 6, width: 10, height: 3 })
|
122
190
|
json = File.read('test/support/json/int2_lin2_str3.json')
|
123
|
-
attributes =
|
124
|
-
|
125
|
-
Composition.new(attributes).to_s.must_equal(
|
191
|
+
attributes = JSON.load(json, nil, symbolize_names: true)
|
192
|
+
|
193
|
+
Composition.new(attributes).to_s.must_equal(
|
194
|
+
"\e[3;3H \e[3;3H" \
|
195
|
+
"\e[4;3H \e[4;3H" \
|
196
|
+
"\e[5;3H \e[5;3H" \
|
197
|
+
"\e[3;3HSome text... more text..." \
|
198
|
+
"\e[4;3HSome text... more text..." \
|
199
|
+
"\e[6;6H \e[6;6H" \
|
200
|
+
"\e[7;6H \e[7;6H" \
|
201
|
+
"\e[8;6H \e[8;6H" \
|
202
|
+
"\e[6;6HSome text... more text..." \
|
203
|
+
"\e[7;6HSome text... more text..."
|
204
|
+
)
|
126
205
|
end
|
127
206
|
|
128
207
|
it 'returns the stringified content for multiple interfaces, multiple lines, multiple streams, streams contain styles' do
|
129
208
|
InterfaceRepository.create({ name: 'int2_lin2_str3_styles_1', y: 3, x: 3, width: 10, height: 3 })
|
130
209
|
InterfaceRepository.create({ name: 'int2_lin2_str3_styles_2', y: 6, x: 6, width: 10, height: 3 })
|
131
210
|
json = File.read('test/support/json/int2_lin2_str3_styles.json')
|
132
|
-
attributes =
|
133
|
-
|
134
|
-
Composition.new(attributes).to_s.must_equal(
|
211
|
+
attributes = JSON.load(json, nil, symbolize_names: true)
|
212
|
+
|
213
|
+
Composition.new(attributes).to_s.must_equal(
|
214
|
+
"\e[3;3H \e[3;3H" \
|
215
|
+
"\e[4;3H \e[4;3H" \
|
216
|
+
"\e[5;3H \e[5;3H" \
|
217
|
+
"\e[3;3H\e[38;5;16m\e[48;5;21m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;5;226m\e[48;5;46m\e[24m\e[21m\e[27m \e[38;5;231m\e[48;5;201m\e[1mmore text..." \
|
218
|
+
"\e[4;3H\e[38;5;16m\e[48;5;21m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;5;226m\e[48;5;46m\e[24m\e[21m\e[27m \e[38;5;231m\e[48;5;201m\e[1mmore text..." \
|
219
|
+
"\e[6;6H \e[6;6H" \
|
220
|
+
"\e[7;6H \e[7;6H" \
|
221
|
+
"\e[8;6H \e[8;6H" \
|
222
|
+
"\e[6;6H\e[38;5;16m\e[48;5;21m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;5;226m\e[48;5;46m\e[24m\e[21m\e[27m \e[38;5;231m\e[48;5;201m\e[1mmore text..." \
|
223
|
+
"\e[7;6H\e[38;5;16m\e[48;5;21m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;5;226m\e[48;5;46m\e[24m\e[21m\e[27m \e[38;5;231m\e[48;5;201m\e[1mmore text..."
|
224
|
+
)
|
135
225
|
end
|
136
226
|
end
|
137
227
|
end
|
@@ -5,25 +5,24 @@ require_relative '../../../../lib/vedeu/models/composition'
|
|
5
5
|
module Vedeu
|
6
6
|
describe InterfaceCollection do
|
7
7
|
describe '#coerce' do
|
8
|
-
|
9
|
-
Composition.new.interfaces.must_be_instance_of(Array)
|
10
|
-
end
|
8
|
+
before { InterfaceRepository.reset }
|
11
9
|
|
12
10
|
it 'returns an empty collection when there are no interfaces' do
|
13
|
-
Composition.new
|
11
|
+
composition = Composition.new
|
12
|
+
composition.interfaces.must_equal([])
|
14
13
|
end
|
15
14
|
|
16
15
|
it 'returns a collection when there is a single interface' do
|
17
|
-
|
18
|
-
|
19
|
-
.must_be_instance_of(Interface)
|
16
|
+
composition = Composition.new({ interfaces: { name: 'InterfaceCollection#coerce' } })
|
17
|
+
composition.interfaces.first.must_be_instance_of(Interface)
|
20
18
|
end
|
21
19
|
|
22
20
|
it 'returns a collection when there are multiple interfaces' do
|
23
|
-
Composition.new({ interfaces: [
|
21
|
+
composition = Composition.new({ interfaces: [
|
24
22
|
{ name: 'dumb' },
|
25
23
|
{ name: 'dumber' }
|
26
|
-
]})
|
24
|
+
]})
|
25
|
+
composition.interfaces.size.must_equal(2)
|
27
26
|
end
|
28
27
|
end
|
29
28
|
end
|
@@ -21,12 +21,12 @@ module Vedeu
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'has a y attribute' do
|
24
|
-
Interface.new({ y:
|
24
|
+
Interface.new({ y: 3 }).y.must_equal(3)
|
25
25
|
Interface.new.y.must_equal(1)
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'has an x attribute' do
|
29
|
-
Interface.new({ x:
|
29
|
+
Interface.new({ x: 5 }).x.must_equal(5)
|
30
30
|
Interface.new.x.must_equal(1)
|
31
31
|
end
|
32
32
|
|
@@ -36,11 +36,11 @@ module Vedeu
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'has a width attribute' do
|
39
|
-
Interface.new({ width:
|
39
|
+
Interface.new({ width: 10 }).width.must_equal(10)
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'has a height attribute' do
|
43
|
-
Interface.new({ height:
|
43
|
+
Interface.new({ height: 15 }).height.must_equal(15)
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'has a current attribute' do
|
@@ -48,15 +48,31 @@ module Vedeu
|
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'has a cursor attribute' do
|
51
|
-
Interface.new({ cursor: true }).cursor.
|
52
|
-
Interface.new({ cursor: false }).cursor.
|
53
|
-
Interface.new.cursor.
|
51
|
+
Interface.new({ cursor: true }).cursor.must_equal(true)
|
52
|
+
Interface.new({ cursor: false }).cursor.must_equal(false)
|
53
|
+
Interface.new.cursor.must_equal(true)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'has a centred attribute' do
|
57
|
+
Interface.new.centred.must_equal(false)
|
58
|
+
Interface.new({ centred: true }).centred.must_equal(true)
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#origin' do
|
62
|
+
it 'delegates to the Coordinate class to get the origin' do
|
63
|
+
interface = Interface.new({
|
64
|
+
name: '#origin',
|
65
|
+
width: 5,
|
66
|
+
height: 5
|
67
|
+
})
|
68
|
+
interface.origin.must_equal("\e[1;1H")
|
69
|
+
end
|
54
70
|
end
|
55
71
|
|
56
72
|
describe '#refresh' do
|
57
73
|
let(:attributes) {
|
58
74
|
{
|
59
|
-
name: '
|
75
|
+
name: '#refresh',
|
60
76
|
lines: [],
|
61
77
|
colour: {
|
62
78
|
foreground: '#ff0000',
|
@@ -68,25 +84,50 @@ module Vedeu
|
|
68
84
|
}
|
69
85
|
|
70
86
|
it 'returns a blank interface when there is no content to display (initial state)' do
|
71
|
-
Interface.new(attributes).refresh.must_equal(
|
87
|
+
Interface.new(attributes).refresh.must_equal(
|
88
|
+
"\e[38;5;196m\e[48;5;16m" \
|
89
|
+
"\e[1;1H \e[1;1H" \
|
90
|
+
"\e[2;1H \e[2;1H" \
|
91
|
+
"\e[3;1H \e[3;1H"
|
92
|
+
)
|
72
93
|
end
|
73
94
|
|
74
95
|
it 'returns the fresh content when content is queued up to be displayed' do
|
75
|
-
|
76
|
-
|
96
|
+
interface = Interface.new(attributes).enqueue(
|
97
|
+
"\e[38;5;196m\e[48;5;16m" \
|
98
|
+
"\e[1;1HContent\e[1;1H" \
|
99
|
+
"\e[2;1HContent\e[2;1H" \
|
100
|
+
"\e[3;1HContent\e[3;1H"
|
101
|
+
)
|
102
|
+
|
103
|
+
interface.refresh.must_equal(
|
104
|
+
"\e[38;5;196m\e[48;5;16m" \
|
105
|
+
"\e[1;1HContent\e[1;1H" \
|
106
|
+
"\e[2;1HContent\e[2;1H" \
|
107
|
+
"\e[3;1HContent\e[3;1H"
|
108
|
+
)
|
77
109
|
end
|
78
110
|
|
79
111
|
it 'returns the previously shown content when there is stale content from last run' do
|
80
|
-
|
81
|
-
|
82
|
-
|
112
|
+
interface = Interface.new(attributes)
|
113
|
+
interface.current = "\e[38;5;196m\e[48;5;16m" \
|
114
|
+
"\e[1;1HOld\e[1;1H" \
|
115
|
+
"\e[2;1HContent\e[2;1H" \
|
116
|
+
"\e[3;1Here\e[3;1H"
|
117
|
+
|
118
|
+
interface.refresh.must_equal(
|
119
|
+
"\e[38;5;196m\e[48;5;16m" \
|
120
|
+
"\e[1;1HOld\e[1;1H" \
|
121
|
+
"\e[2;1HContent\e[2;1H" \
|
122
|
+
"\e[3;1Here\e[3;1H"
|
123
|
+
)
|
83
124
|
end
|
84
125
|
end
|
85
126
|
|
86
127
|
describe '#to_s' do
|
87
128
|
it 'returns an String' do
|
88
129
|
Interface.new({
|
89
|
-
name: '
|
130
|
+
name: '#to_s',
|
90
131
|
lines: [],
|
91
132
|
colour: {
|
92
133
|
foreground: '#ff0000',
|
@@ -94,14 +135,19 @@ module Vedeu
|
|
94
135
|
},
|
95
136
|
width: 3,
|
96
137
|
height: 3
|
97
|
-
}).to_s.must_equal(
|
138
|
+
}).to_s.must_equal(
|
139
|
+
"\e[38;5;196m\e[48;5;16m" \
|
140
|
+
"\e[1;1H \e[1;1H" \
|
141
|
+
"\e[2;1H \e[2;1H" \
|
142
|
+
"\e[3;1H \e[3;1H"
|
143
|
+
)
|
98
144
|
end
|
99
145
|
end
|
100
146
|
|
101
147
|
describe '#to_json' do
|
102
148
|
it 'returns an String' do
|
103
149
|
Interface.new({
|
104
|
-
name: '
|
150
|
+
name: '#to_json',
|
105
151
|
lines: [],
|
106
152
|
colour: {
|
107
153
|
foreground: '#ff0000',
|
@@ -109,7 +155,7 @@ module Vedeu
|
|
109
155
|
},
|
110
156
|
width: 3,
|
111
157
|
height: 3
|
112
|
-
}).to_json.must_equal("{\"colour\":{\"foreground\":\"
|
158
|
+
}).to_json.must_equal("{\"colour\":{\"foreground\":\"#ff0000\",\"background\":\"#000000\"},\"style\":\"\",\"name\":\"#to_json\",\"lines\":[],\"y\":1,\"x\":1,\"z\":1,\"width\":3,\"height\":3,\"cursor\":true}")
|
113
159
|
end
|
114
160
|
end
|
115
161
|
end
|
@@ -3,10 +3,6 @@ require_relative '../../../../lib/vedeu/models/line'
|
|
3
3
|
|
4
4
|
module Vedeu
|
5
5
|
describe Line do
|
6
|
-
it 'has a style attribute' do
|
7
|
-
Line.new(style: 'normal').style.must_be_instance_of(String)
|
8
|
-
end
|
9
|
-
|
10
6
|
it 'has a colour attribute' do
|
11
7
|
Line.new({
|
12
8
|
colour: { foreground: '#ff0000', background: '#000000' }
|
@@ -24,18 +20,18 @@ module Vedeu
|
|
24
20
|
describe '#to_json' do
|
25
21
|
it 'returns an String' do
|
26
22
|
Line.new({
|
27
|
-
style: 'normal',
|
28
23
|
colour: { foreground: '#ff0000', background: '#000000' },
|
24
|
+
style: 'normal',
|
29
25
|
streams: [],
|
30
|
-
}).to_json.must_equal("{\"colour\":{\"foreground\":\"
|
26
|
+
}).to_json.must_equal("{\"colour\":{\"foreground\":\"#ff0000\",\"background\":\"#000000\"},\"style\":[\"normal\"],\"streams\":[]}")
|
31
27
|
end
|
32
28
|
end
|
33
29
|
|
34
30
|
describe '#to_s' do
|
35
31
|
it 'returns an String' do
|
36
32
|
Line.new({
|
37
|
-
style: 'normal',
|
38
33
|
colour: { foreground: '#ff0000', background: '#000000' },
|
34
|
+
style: 'normal',
|
39
35
|
}).to_s.must_equal("\e[38;5;196m\e[48;5;16m\e[24m\e[21m\e[27m")
|
40
36
|
end
|
41
37
|
end
|