vedeu 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -23
- data/deps.md +15 -19
- data/lib/vedeu.rb +8 -54
- data/lib/vedeu/api/base.rb +5 -3
- data/lib/vedeu/api/events.rb +75 -0
- data/lib/vedeu/api/interface.rb +12 -2
- data/lib/vedeu/api/store.rb +37 -0
- data/lib/vedeu/api/view.rb +12 -4
- data/lib/vedeu/application.rb +7 -3
- data/lib/vedeu/configuration.rb +4 -0
- data/lib/vedeu/instrumentation.rb +1 -9
- data/lib/vedeu/launcher.rb +5 -3
- data/lib/vedeu/models/attributes/background.rb +11 -0
- data/lib/vedeu/models/attributes/collection.rb +1 -7
- data/lib/vedeu/{output → models/attributes}/colour_translator.rb +19 -3
- data/lib/vedeu/models/attributes/foreground.rb +11 -0
- data/lib/vedeu/models/attributes/interface_collection.rb +5 -5
- data/lib/vedeu/models/colour.rb +2 -18
- data/lib/vedeu/models/interface.rb +22 -13
- data/lib/vedeu/models/line.rb +1 -2
- data/lib/vedeu/models/stream.rb +21 -13
- data/lib/vedeu/output/{clear_interface.rb → clear.rb} +5 -5
- data/lib/vedeu/output/{render_interface.rb → render.rb} +4 -4
- data/lib/vedeu/support/esc.rb +3 -0
- data/lib/vedeu/support/menu.rb +1 -1
- data/lib/vedeu/support/terminal.rb +4 -10
- data/test/lib/vedeu/api/base_test.rb +1 -1
- data/test/lib/vedeu/api/events_test.rb +37 -0
- data/test/lib/vedeu/api/grid_test.rb +11 -9
- data/test/lib/vedeu/api/interface_test.rb +10 -13
- data/test/lib/vedeu/api/line_test.rb +0 -2
- data/test/lib/vedeu/api/store_test.rb +49 -0
- data/test/lib/vedeu/api/stream_test.rb +1 -1
- data/test/lib/vedeu/api/view_test.rb +1 -1
- data/test/lib/vedeu/models/attributes/background_test.rb +8 -0
- data/test/lib/vedeu/models/attributes/colour_translator_test.rb +78 -0
- data/test/lib/vedeu/models/attributes/foreground_test.rb +8 -0
- data/test/lib/vedeu/models/attributes/interface_collection_test.rb +22 -6
- data/test/lib/vedeu/models/attributes/line_collection_test.rb +1 -6
- data/test/lib/vedeu/models/attributes/stream_collection_test.rb +1 -1
- data/test/lib/vedeu/models/composition_test.rb +108 -62
- data/test/lib/vedeu/models/geometry_test.rb +48 -0
- data/test/lib/vedeu/models/interface_test.rb +26 -10
- data/test/lib/vedeu/models/line_test.rb +0 -5
- data/test/lib/vedeu/output/{clear_interface_test.rb → clear_test.rb} +8 -8
- data/test/lib/vedeu/output/{render_interface_test.rb → render_test.rb} +7 -7
- data/test/lib/vedeu/support/esc_test.rb +12 -0
- data/test/lib/vedeu/support/terminal_test.rb +2 -1
- data/test/lib/vedeu_test.rb +0 -38
- data/test/support/colours.rb +1 -1
- data/vedeu.gemspec +1 -1
- metadata +23 -23
- data/lib/vedeu/output/text_adaptor.rb +0 -35
- data/lib/vedeu/support/events.rb +0 -51
- data/lib/vedeu/support/interface_store.rb +0 -43
- data/lib/vedeu/support/queue.rb +0 -31
- data/test/lib/vedeu/output/colour_translator_test.rb +0 -42
- data/test/lib/vedeu/output/text_adaptor_test.rb +0 -73
- data/test/lib/vedeu/support/events_test.rb +0 -35
- data/test/lib/vedeu/support/interface_store_test.rb +0 -51
- data/test/lib/vedeu/support/queue_test.rb +0 -44
@@ -8,12 +8,7 @@ module Vedeu
|
|
8
8
|
|
9
9
|
describe '#coerce' do
|
10
10
|
it 'returns an empty collection when there are no lines' do
|
11
|
-
Interface.new({ lines:
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'contains a single Line object when the line is just a String' do
|
15
|
-
Interface.new({ lines: 'some text' }).lines.size
|
16
|
-
.must_equal(1)
|
11
|
+
Interface.new({ lines: [] }).lines.must_equal([])
|
17
12
|
end
|
18
13
|
|
19
14
|
it 'contains a single Line object when there is a single line' do
|
@@ -3,59 +3,22 @@ require 'test_helper'
|
|
3
3
|
require 'json'
|
4
4
|
|
5
5
|
require 'vedeu/models/composition'
|
6
|
-
require 'vedeu/
|
6
|
+
require 'vedeu/api/store'
|
7
7
|
|
8
8
|
module Vedeu
|
9
9
|
describe Composition do
|
10
|
-
|
11
|
-
it 'enqueues the interfaces for rendering' do
|
12
|
-
attributes = {
|
13
|
-
interfaces: [
|
14
|
-
{
|
15
|
-
name: 'Composition.enqueue_1',
|
16
|
-
geometry: {
|
17
|
-
width: 35,
|
18
|
-
height: 5,
|
19
|
-
},
|
20
|
-
lines: {
|
21
|
-
streams: {
|
22
|
-
text: 'bd459118e6175689e4394e242debc2ae'
|
23
|
-
}
|
24
|
-
}
|
25
|
-
}, {
|
26
|
-
name: 'Composition.enqueue_2',
|
27
|
-
geometry: {
|
28
|
-
width: 35,
|
29
|
-
height: 5,
|
30
|
-
},
|
31
|
-
lines: {
|
32
|
-
streams: {
|
33
|
-
text: '837acb2cb2ea3ef359257851142a7830'
|
34
|
-
}
|
35
|
-
}
|
36
|
-
}
|
37
|
-
]
|
38
|
-
}
|
39
|
-
|
40
|
-
Composition.enqueue(attributes)
|
41
|
-
InterfaceStore
|
42
|
-
.query('Composition.enqueue_1').dequeue
|
43
|
-
.must_match(/bd459118e6175689e4394e242debc2ae/)
|
44
|
-
InterfaceStore
|
45
|
-
.query('Composition.enqueue_2').dequeue
|
46
|
-
.must_match(/837acb2cb2ea3ef359257851142a7830/)
|
47
|
-
end
|
48
|
-
end
|
10
|
+
before { API::Store.reset }
|
49
11
|
|
50
12
|
describe '#interfaces' do
|
51
13
|
it 'returns a collection of interfaces' do
|
14
|
+
Vedeu.interface('dummy') do
|
15
|
+
width 5
|
16
|
+
height 5
|
17
|
+
end
|
52
18
|
Composition.new({
|
53
19
|
interfaces: {
|
54
|
-
name:
|
55
|
-
|
56
|
-
width: 5,
|
57
|
-
height: 5
|
58
|
-
}
|
20
|
+
name: 'dummy',
|
21
|
+
lines: []
|
59
22
|
}
|
60
23
|
}).interfaces.first.must_be_instance_of(Interface)
|
61
24
|
end
|
@@ -67,7 +30,12 @@ module Vedeu
|
|
67
30
|
|
68
31
|
describe '#to_s' do
|
69
32
|
it 'returns the stringified content for a single interface, single line, single stream' do
|
70
|
-
|
33
|
+
Vedeu.interface('int1_lin1_str1') do
|
34
|
+
y 3
|
35
|
+
x 3
|
36
|
+
width 15
|
37
|
+
height 3
|
38
|
+
end
|
71
39
|
json = File.read('test/support/json/int1_lin1_str1.json')
|
72
40
|
attributes = JSON.load(json, nil, symbolize_names: true)
|
73
41
|
|
@@ -80,7 +48,12 @@ module Vedeu
|
|
80
48
|
end
|
81
49
|
|
82
50
|
it 'returns the stringified content for a single interface, single line, multiple streams' do
|
83
|
-
|
51
|
+
Vedeu.interface('int1_lin1_str3') do
|
52
|
+
y 3
|
53
|
+
x 3
|
54
|
+
width 30
|
55
|
+
height 3
|
56
|
+
end
|
84
57
|
json = File.read('test/support/json/int1_lin1_str3.json')
|
85
58
|
attributes = JSON.load(json, nil, symbolize_names: true)
|
86
59
|
|
@@ -93,7 +66,12 @@ module Vedeu
|
|
93
66
|
end
|
94
67
|
|
95
68
|
it 'returns the stringified content for a single interface, multiple lines, single stream' do
|
96
|
-
|
69
|
+
Vedeu.interface('int1_lin2_str1') do
|
70
|
+
y 3
|
71
|
+
x 3
|
72
|
+
width 15
|
73
|
+
height 3
|
74
|
+
end
|
97
75
|
json = File.read('test/support/json/int1_lin2_str1.json')
|
98
76
|
attributes = JSON.load(json, nil, symbolize_names: true)
|
99
77
|
|
@@ -107,7 +85,12 @@ module Vedeu
|
|
107
85
|
end
|
108
86
|
|
109
87
|
it 'returns the stringified content for a single interface, multiple lines, multiple streams' do
|
110
|
-
|
88
|
+
Vedeu.interface('int1_lin2_str3') do
|
89
|
+
y 3
|
90
|
+
x 3
|
91
|
+
width 30
|
92
|
+
height 3
|
93
|
+
end
|
111
94
|
json = File.read('test/support/json/int1_lin2_str3.json')
|
112
95
|
attributes = JSON.load(json, nil, symbolize_names: true)
|
113
96
|
|
@@ -121,10 +104,14 @@ module Vedeu
|
|
121
104
|
end
|
122
105
|
|
123
106
|
it 'returns the stringified content for a single interface, multiple lines, multiple streams, streams contain styles' do
|
107
|
+
Vedeu.interface('int1_lin2_str3_styles') do
|
108
|
+
y 3
|
109
|
+
x 3
|
110
|
+
width 30
|
111
|
+
height 3
|
112
|
+
end
|
124
113
|
json = File.read('test/support/json/int1_lin2_str3_styles.json')
|
125
114
|
attributes = JSON.load(json, nil, symbolize_names: true)
|
126
|
-
InterfaceStore.create({ name: 'int1_lin2_str3_styles', geometry: { y: 3, x: 3, width: 30, height: 3 } })
|
127
|
-
|
128
115
|
Composition.new(attributes).to_s.must_equal(
|
129
116
|
"\e[3;3H \e[3;3H" \
|
130
117
|
"\e[4;3H \e[4;3H" \
|
@@ -134,8 +121,18 @@ module Vedeu
|
|
134
121
|
end
|
135
122
|
|
136
123
|
it 'returns the stringified content for multiple interfaces, single line, single stream' do
|
137
|
-
|
138
|
-
|
124
|
+
Vedeu.interface('int2_lin1_str1_1') do
|
125
|
+
y 3
|
126
|
+
x 3
|
127
|
+
width 15
|
128
|
+
height 3
|
129
|
+
end
|
130
|
+
Vedeu.interface('int2_lin1_str1_2') do
|
131
|
+
y 6
|
132
|
+
x 6
|
133
|
+
width 15
|
134
|
+
height 3
|
135
|
+
end
|
139
136
|
json = File.read('test/support/json/int2_lin1_str1.json')
|
140
137
|
attributes = JSON.load(json, nil, symbolize_names: true)
|
141
138
|
|
@@ -152,8 +149,18 @@ module Vedeu
|
|
152
149
|
end
|
153
150
|
|
154
151
|
it 'returns the stringified content for multiple interfaces, single line, multiple streams' do
|
155
|
-
|
156
|
-
|
152
|
+
Vedeu.interface('int2_lin1_str3_1') do
|
153
|
+
y 3
|
154
|
+
x 3
|
155
|
+
width 30
|
156
|
+
height 3
|
157
|
+
end
|
158
|
+
Vedeu.interface('int2_lin1_str3_2') do
|
159
|
+
y 6
|
160
|
+
x 6
|
161
|
+
width 30
|
162
|
+
height 3
|
163
|
+
end
|
157
164
|
json = File.read('test/support/json/int2_lin1_str3.json')
|
158
165
|
attributes = JSON.load(json, nil, symbolize_names: true)
|
159
166
|
|
@@ -170,8 +177,18 @@ module Vedeu
|
|
170
177
|
end
|
171
178
|
|
172
179
|
it 'returns the stringified content for multiple interfaces, multiple lines, single stream' do
|
173
|
-
|
174
|
-
|
180
|
+
Vedeu.interface('int2_lin2_str1_1') do
|
181
|
+
y 3
|
182
|
+
x 3
|
183
|
+
width 15
|
184
|
+
height 3
|
185
|
+
end
|
186
|
+
Vedeu.interface('int2_lin2_str1_2') do
|
187
|
+
y 6
|
188
|
+
x 6
|
189
|
+
width 15
|
190
|
+
height 3
|
191
|
+
end
|
175
192
|
json = File.read('test/support/json/int2_lin2_str1.json')
|
176
193
|
attributes = JSON.load(json, nil, symbolize_names: true)
|
177
194
|
|
@@ -190,8 +207,18 @@ module Vedeu
|
|
190
207
|
end
|
191
208
|
|
192
209
|
it 'returns the stringified content for multiple interfaces, multiple lines, multiple streams' do
|
193
|
-
|
194
|
-
|
210
|
+
Vedeu.interface('int2_lin2_str3_1') do
|
211
|
+
y 3
|
212
|
+
x 3
|
213
|
+
width 30
|
214
|
+
height 3
|
215
|
+
end
|
216
|
+
Vedeu.interface('int2_lin2_str3_2') do
|
217
|
+
y 6
|
218
|
+
x 6
|
219
|
+
width 30
|
220
|
+
height 3
|
221
|
+
end
|
195
222
|
json = File.read('test/support/json/int2_lin2_str3.json')
|
196
223
|
attributes = JSON.load(json, nil, symbolize_names: true)
|
197
224
|
|
@@ -210,13 +237,32 @@ module Vedeu
|
|
210
237
|
end
|
211
238
|
|
212
239
|
it 'returns the stringified content for multiple interfaces, multiple lines, multiple streams, streams contain styles' do
|
213
|
-
|
214
|
-
|
240
|
+
Vedeu.interface('int2_lin2_str3_styles_1') do
|
241
|
+
y 3
|
242
|
+
x 3
|
243
|
+
width 30
|
244
|
+
height 3
|
245
|
+
end
|
246
|
+
Vedeu.interface('int2_lin2_str3_styles_2') do
|
247
|
+
y 6
|
248
|
+
x 6
|
249
|
+
width 30
|
250
|
+
height 3
|
251
|
+
end
|
215
252
|
json = File.read('test/support/json/int2_lin2_str3_styles.json')
|
216
253
|
attributes = JSON.load(json, nil, symbolize_names: true)
|
217
254
|
|
218
255
|
Composition.new(attributes).to_s.must_equal(
|
219
|
-
"\e[3;3H \e[3;3H
|
256
|
+
"\e[3;3H \e[3;3H" \
|
257
|
+
"\e[4;3H \e[4;3H" \
|
258
|
+
"\e[5;3H \e[5;3H" \
|
259
|
+
"\e[3;3H\e[38;5;16m\e[48;5;21mSome text...\e[38;5;226m\e[48;5;46m \e[38;5;231m\e[48;5;201mmore text..." \
|
260
|
+
"\e[4;3H\e[38;5;16m\e[48;5;21mSome text...\e[38;5;226m\e[48;5;46m \e[38;5;231m\e[48;5;201mmore text..." \
|
261
|
+
"\e[6;6H \e[6;6H" \
|
262
|
+
"\e[7;6H \e[7;6H" \
|
263
|
+
"\e[8;6H \e[8;6H" \
|
264
|
+
"\e[6;6H\e[38;5;16m\e[48;5;21mSome text...\e[38;5;226m\e[48;5;46m \e[38;5;231m\e[48;5;201mmore text..." \
|
265
|
+
"\e[7;6H\e[38;5;16m\e[48;5;21mSome text...\e[38;5;226m\e[48;5;46m \e[38;5;231m\e[48;5;201mmore text..."
|
220
266
|
)
|
221
267
|
end
|
222
268
|
end
|
@@ -55,6 +55,18 @@ module Vedeu
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
+
describe '#north' do
|
59
|
+
it 'returns the top minus the value when the value is provided' do
|
60
|
+
geometry = Geometry.new({ height: 6, width: 18, y: 4 })
|
61
|
+
geometry.north(2).must_equal(2)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'returns the top minus 1 without a value' do
|
65
|
+
geometry = Geometry.new({ height: 6, width: 18, y: 4 })
|
66
|
+
geometry.north.must_equal(3)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
58
70
|
describe '#left' do
|
59
71
|
it 'centred is true' do
|
60
72
|
console = IO.console
|
@@ -75,6 +87,18 @@ module Vedeu
|
|
75
87
|
end
|
76
88
|
end
|
77
89
|
|
90
|
+
describe '#west' do
|
91
|
+
it 'returns the left minus the value when the value is provided' do
|
92
|
+
geometry = Geometry.new({ height: 6, width: 18, x: 7 })
|
93
|
+
geometry.west(2).must_equal(5)
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'returns the left minus 1 without a value' do
|
97
|
+
geometry = Geometry.new({ height: 6, width: 18, x: 7 })
|
98
|
+
geometry.west.must_equal(6)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
78
102
|
describe '#bottom' do
|
79
103
|
it 'centred is true' do
|
80
104
|
console = IO.console
|
@@ -95,6 +119,18 @@ module Vedeu
|
|
95
119
|
end
|
96
120
|
end
|
97
121
|
|
122
|
+
describe '#south' do
|
123
|
+
it 'returns the bottom plus the value when the value is provided' do
|
124
|
+
geometry = Geometry.new({ height: 6, width: 18, y: 3 })
|
125
|
+
geometry.south(2).must_equal(11)
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'returns the bottom plus 1 without a value' do
|
129
|
+
geometry = Geometry.new({ height: 6, width: 18, y: 3 })
|
130
|
+
geometry.south.must_equal(10)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
98
134
|
describe '#right' do
|
99
135
|
it 'centred is true' do
|
100
136
|
console = IO.console
|
@@ -115,6 +151,18 @@ module Vedeu
|
|
115
151
|
end
|
116
152
|
end
|
117
153
|
|
154
|
+
describe '#east' do
|
155
|
+
it 'returns the right plus the value when the value is provided' do
|
156
|
+
geometry = Geometry.new({ height: 6, width: 18, x: 7 })
|
157
|
+
geometry.east(2).must_equal(27)
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'returns the right plus 1 without a value' do
|
161
|
+
geometry = Geometry.new({ height: 6, width: 18, x: 7 })
|
162
|
+
geometry.east.must_equal(26)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
118
166
|
describe '#position' do
|
119
167
|
it 'centred is true' do
|
120
168
|
console = IO.console
|
@@ -6,6 +6,7 @@ module Vedeu
|
|
6
6
|
let(:interface) {
|
7
7
|
Interface.new({
|
8
8
|
name: '#initialize',
|
9
|
+
group: 'my_group',
|
9
10
|
lines: [],
|
10
11
|
colour: {
|
11
12
|
foreground: '#ff0000',
|
@@ -25,6 +26,10 @@ module Vedeu
|
|
25
26
|
interface.name.must_equal('#initialize')
|
26
27
|
end
|
27
28
|
|
29
|
+
it 'has a name attribute' do
|
30
|
+
interface.group.must_equal('my_group')
|
31
|
+
end
|
32
|
+
|
28
33
|
it 'has a lines attribute' do
|
29
34
|
interface.lines.must_equal([])
|
30
35
|
end
|
@@ -33,6 +38,14 @@ module Vedeu
|
|
33
38
|
interface.colour.must_be_instance_of(Colour)
|
34
39
|
end
|
35
40
|
|
41
|
+
it 'has a style attribute' do
|
42
|
+
interface.style.must_equal('')
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'has a geometry attribute' do
|
46
|
+
interface.geometry.must_be_instance_of(Geometry)
|
47
|
+
end
|
48
|
+
|
36
49
|
it 'has a current attribute' do
|
37
50
|
interface.current.must_equal("\e[1;1H#initialize")
|
38
51
|
end
|
@@ -42,9 +55,12 @@ module Vedeu
|
|
42
55
|
Interface.new({ cursor: false }).cursor.must_equal(false)
|
43
56
|
end
|
44
57
|
|
58
|
+
it 'has a delay attribute' do
|
59
|
+
interface.delay.must_equal(0.0)
|
60
|
+
end
|
61
|
+
|
45
62
|
describe '#enqueue' do
|
46
63
|
it 'delegates to the Queue class to enqueue itself' do
|
47
|
-
Queue.reset
|
48
64
|
interface = Interface.new({
|
49
65
|
name: 'Interface#enqueue',
|
50
66
|
geometry: {
|
@@ -93,9 +109,9 @@ module Vedeu
|
|
93
109
|
attributes = {
|
94
110
|
name: '#refresh',
|
95
111
|
lines: [
|
96
|
-
{ streams: '#refresh' },
|
97
|
-
{ streams: '#refresh' },
|
98
|
-
{ streams: '#refresh' }
|
112
|
+
{ streams: [{ text: '#refresh' }] },
|
113
|
+
{ streams: [{ text: '#refresh' }] },
|
114
|
+
{ streams: [{ text: '#refresh' }] }
|
99
115
|
],
|
100
116
|
colour: {
|
101
117
|
foreground: '#ff0000',
|
@@ -107,7 +123,7 @@ module Vedeu
|
|
107
123
|
}
|
108
124
|
}
|
109
125
|
interface = Interface.new(attributes)
|
110
|
-
interface.enqueue
|
126
|
+
diode = interface.enqueue
|
111
127
|
|
112
128
|
Terminal.stub(:output, nil) do
|
113
129
|
interface.refresh.must_equal(
|
@@ -159,7 +175,7 @@ module Vedeu
|
|
159
175
|
end
|
160
176
|
|
161
177
|
describe '#to_s' do
|
162
|
-
it 'returns an
|
178
|
+
it 'returns an string' do
|
163
179
|
Interface.new({
|
164
180
|
name: '#to_s',
|
165
181
|
lines: [],
|
@@ -168,14 +184,14 @@ module Vedeu
|
|
168
184
|
background: '#000000'
|
169
185
|
},
|
170
186
|
geometry: {
|
171
|
-
width:
|
187
|
+
width: 9,
|
172
188
|
height: 3
|
173
189
|
}
|
174
190
|
}).to_s.must_equal(
|
175
191
|
"\e[38;5;196m\e[48;5;16m" \
|
176
|
-
"\e[1;1H
|
177
|
-
"\e[2;1H
|
178
|
-
"\e[3;1H
|
192
|
+
"\e[1;1H \e[1;1H" \
|
193
|
+
"\e[2;1H \e[2;1H" \
|
194
|
+
"\e[3;1H \e[3;1H"
|
179
195
|
)
|
180
196
|
end
|
181
197
|
end
|