vedeu 0.0.33 → 0.0.34
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vedeu/models/{collection.rb → attributes/collection.rb} +0 -0
- data/lib/vedeu/models/{interface_collection.rb → attributes/interface_collection.rb} +1 -1
- data/lib/vedeu/models/{line_collection.rb → attributes/line_collection.rb} +1 -1
- data/lib/vedeu/models/{stream_collection.rb → attributes/stream_collection.rb} +1 -1
- data/lib/vedeu/models/composition.rb +4 -23
- data/lib/vedeu/models/interface.rb +17 -17
- data/lib/vedeu/models/line.rb +6 -12
- data/lib/vedeu/models/stream.rb +5 -11
- data/lib/vedeu/output/interface_renderer.rb +4 -10
- data/lib/vedeu/repository/command_repository.rb +2 -2
- data/lib/vedeu/repository/interface_repository.rb +7 -3
- data/lib/vedeu/repository/repository.rb +0 -4
- data/lib/vedeu/repository/storage.rb +1 -5
- data/lib/vedeu/support/compositor.rb +25 -0
- data/lib/vedeu/support/coordinate.rb +41 -54
- data/lib/vedeu/support/parser.rb +2 -2
- data/test/lib/vedeu/models/{collection_test.rb → attributes/collection_test.rb} +2 -2
- data/test/lib/vedeu/models/{interface_collection_test.rb → attributes/interface_collection_test.rb} +3 -3
- data/test/lib/vedeu/models/{line_collection_test.rb → attributes/line_collection_test.rb} +3 -3
- data/test/lib/vedeu/models/{stream_collection_test.rb → attributes/stream_collection_test.rb} +3 -3
- data/test/lib/vedeu/models/composition_test.rb +45 -65
- data/test/lib/vedeu/models/interface_test.rb +84 -38
- data/test/lib/vedeu/models/line_test.rb +20 -14
- data/test/lib/vedeu/models/presentation_test.rb +10 -6
- data/test/lib/vedeu/output/interface_renderer_test.rb +4 -4
- data/test/lib/vedeu/process/process_test.rb +5 -2
- data/test/lib/vedeu/repository/interface_repository_test.rb +32 -20
- data/test/lib/vedeu/repository/repository_test.rb +9 -11
- data/test/lib/vedeu/repository/storage_test.rb +8 -9
- data/test/lib/vedeu/support/compositor_test.rb +40 -0
- data/test/lib/vedeu/support/coordinate_test.rb +0 -16
- data/test/lib/vedeu/support/parser_test.rb +7 -4
- data/test/test_helper.rb +2 -0
- data/vedeu.gemspec +1 -1
- metadata +17 -14
@@ -20,26 +20,6 @@ module Vedeu
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
describe '.enqueue' do
|
24
|
-
it 'returns a collection of interfaces' do
|
25
|
-
Composition.enqueue({
|
26
|
-
interfaces: [
|
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
|
-
]
|
30
|
-
}).interfaces.first.must_be_instance_of(Interface)
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'enqueues the interfaces for rendering' do
|
34
|
-
Composition.enqueue({
|
35
|
-
interfaces: [
|
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
|
-
]
|
39
|
-
}).interfaces.first.enqueued?.must_equal(true)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
23
|
describe '#to_json' do
|
44
24
|
it 'returns the model as JSON' do
|
45
25
|
attributes = {
|
@@ -67,9 +47,9 @@ module Vedeu
|
|
67
47
|
attributes = JSON.load(json, nil, symbolize_names: true)
|
68
48
|
|
69
49
|
Composition.new(attributes).to_s.must_equal(
|
70
|
-
"\e[3;3H
|
71
|
-
"\e[4;3H
|
72
|
-
"\e[5;3H
|
50
|
+
"\e[3;3H " \
|
51
|
+
"\e[4;3H " \
|
52
|
+
"\e[5;3H " \
|
73
53
|
"\e[3;3HSome text..."
|
74
54
|
)
|
75
55
|
end
|
@@ -80,9 +60,9 @@ module Vedeu
|
|
80
60
|
attributes = JSON.load(json, nil, symbolize_names: true)
|
81
61
|
|
82
62
|
Composition.new(attributes).to_s.must_equal(
|
83
|
-
"\e[3;3H
|
84
|
-
"\e[4;3H
|
85
|
-
"\e[5;3H
|
63
|
+
"\e[3;3H " \
|
64
|
+
"\e[4;3H " \
|
65
|
+
"\e[5;3H " \
|
86
66
|
"\e[3;3HSome text... more text..."
|
87
67
|
)
|
88
68
|
end
|
@@ -93,9 +73,9 @@ module Vedeu
|
|
93
73
|
attributes = JSON.load(json, nil, symbolize_names: true)
|
94
74
|
|
95
75
|
Composition.new(attributes).to_s.must_equal(
|
96
|
-
"\e[3;3H
|
97
|
-
"\e[4;3H
|
98
|
-
"\e[5;3H
|
76
|
+
"\e[3;3H " \
|
77
|
+
"\e[4;3H " \
|
78
|
+
"\e[5;3H " \
|
99
79
|
"\e[3;3HSome text..." \
|
100
80
|
"\e[4;3HSome text..."
|
101
81
|
)
|
@@ -107,9 +87,9 @@ module Vedeu
|
|
107
87
|
attributes = JSON.load(json, nil, symbolize_names: true)
|
108
88
|
|
109
89
|
Composition.new(attributes).to_s.must_equal(
|
110
|
-
"\e[3;3H
|
111
|
-
"\e[4;3H
|
112
|
-
"\e[5;3H
|
90
|
+
"\e[3;3H " \
|
91
|
+
"\e[4;3H " \
|
92
|
+
"\e[5;3H " \
|
113
93
|
"\e[3;3HSome text... more text..." \
|
114
94
|
"\e[4;3HSome text... more text..."
|
115
95
|
)
|
@@ -121,9 +101,9 @@ module Vedeu
|
|
121
101
|
InterfaceRepository.create({ name: 'int1_lin2_str3_styles', y: 3, x: 3, width: 10, height: 3 })
|
122
102
|
|
123
103
|
Composition.new(attributes).to_s.must_equal(
|
124
|
-
"\e[3;3H
|
125
|
-
"\e[4;3H
|
126
|
-
"\e[5;3H
|
104
|
+
"\e[3;3H " \
|
105
|
+
"\e[4;3H " \
|
106
|
+
"\e[5;3H " \
|
127
107
|
"\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
108
|
)
|
129
109
|
end
|
@@ -135,13 +115,13 @@ module Vedeu
|
|
135
115
|
attributes = JSON.load(json, nil, symbolize_names: true)
|
136
116
|
|
137
117
|
Composition.new(attributes).to_s.must_equal(
|
138
|
-
"\e[3;3H
|
139
|
-
"\e[4;3H
|
140
|
-
"\e[5;3H
|
118
|
+
"\e[3;3H " \
|
119
|
+
"\e[4;3H " \
|
120
|
+
"\e[5;3H " \
|
141
121
|
"\e[3;3HSome text..." \
|
142
|
-
"\e[6;6H
|
143
|
-
"\e[7;6H
|
144
|
-
"\e[8;6H
|
122
|
+
"\e[6;6H " \
|
123
|
+
"\e[7;6H " \
|
124
|
+
"\e[8;6H " \
|
145
125
|
"\e[6;6HSome text..."
|
146
126
|
)
|
147
127
|
end
|
@@ -153,13 +133,13 @@ module Vedeu
|
|
153
133
|
attributes = JSON.load(json, nil, symbolize_names: true)
|
154
134
|
|
155
135
|
Composition.new(attributes).to_s.must_equal(
|
156
|
-
"\e[3;3H
|
157
|
-
"\e[4;3H
|
158
|
-
"\e[5;3H
|
136
|
+
"\e[3;3H " \
|
137
|
+
"\e[4;3H " \
|
138
|
+
"\e[5;3H " \
|
159
139
|
"\e[3;3HSome text... more text..." \
|
160
|
-
"\e[6;6H
|
161
|
-
"\e[7;6H
|
162
|
-
"\e[8;6H
|
140
|
+
"\e[6;6H " \
|
141
|
+
"\e[7;6H " \
|
142
|
+
"\e[8;6H " \
|
163
143
|
"\e[6;6HSome text... more text..."
|
164
144
|
)
|
165
145
|
end
|
@@ -171,14 +151,14 @@ module Vedeu
|
|
171
151
|
attributes = JSON.load(json, nil, symbolize_names: true)
|
172
152
|
|
173
153
|
Composition.new(attributes).to_s.must_equal(
|
174
|
-
"\e[3;3H
|
175
|
-
"\e[4;3H
|
176
|
-
"\e[5;3H
|
154
|
+
"\e[3;3H " \
|
155
|
+
"\e[4;3H " \
|
156
|
+
"\e[5;3H " \
|
177
157
|
"\e[3;3HSome text..." \
|
178
158
|
"\e[4;3HSome text..." \
|
179
|
-
"\e[3;3H
|
180
|
-
"\e[4;3H
|
181
|
-
"\e[5;3H
|
159
|
+
"\e[3;3H " \
|
160
|
+
"\e[4;3H " \
|
161
|
+
"\e[5;3H " \
|
182
162
|
"\e[3;3HSome text..." \
|
183
163
|
"\e[4;3HSome text..."
|
184
164
|
)
|
@@ -191,14 +171,14 @@ module Vedeu
|
|
191
171
|
attributes = JSON.load(json, nil, symbolize_names: true)
|
192
172
|
|
193
173
|
Composition.new(attributes).to_s.must_equal(
|
194
|
-
"\e[3;3H
|
195
|
-
"\e[4;3H
|
196
|
-
"\e[5;3H
|
174
|
+
"\e[3;3H " \
|
175
|
+
"\e[4;3H " \
|
176
|
+
"\e[5;3H " \
|
197
177
|
"\e[3;3HSome text... more text..." \
|
198
178
|
"\e[4;3HSome text... more text..." \
|
199
|
-
"\e[6;6H
|
200
|
-
"\e[7;6H
|
201
|
-
"\e[8;6H
|
179
|
+
"\e[6;6H " \
|
180
|
+
"\e[7;6H " \
|
181
|
+
"\e[8;6H " \
|
202
182
|
"\e[6;6HSome text... more text..." \
|
203
183
|
"\e[7;6HSome text... more text..."
|
204
184
|
)
|
@@ -211,14 +191,14 @@ module Vedeu
|
|
211
191
|
attributes = JSON.load(json, nil, symbolize_names: true)
|
212
192
|
|
213
193
|
Composition.new(attributes).to_s.must_equal(
|
214
|
-
"\e[3;3H
|
215
|
-
"\e[4;3H
|
216
|
-
"\e[5;3H
|
194
|
+
"\e[3;3H " \
|
195
|
+
"\e[4;3H " \
|
196
|
+
"\e[5;3H " \
|
217
197
|
"\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
198
|
"\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
|
220
|
-
"\e[7;6H
|
221
|
-
"\e[8;6H
|
199
|
+
"\e[6;6H " \
|
200
|
+
"\e[7;6H " \
|
201
|
+
"\e[8;6H " \
|
222
202
|
"\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
203
|
"\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
204
|
)
|
@@ -3,61 +3,78 @@ require_relative '../../../../lib/vedeu/models/interface'
|
|
3
3
|
|
4
4
|
module Vedeu
|
5
5
|
describe Interface do
|
6
|
+
let(:interface) {
|
7
|
+
Interface.new({
|
8
|
+
name: '#initialize',
|
9
|
+
lines: [],
|
10
|
+
colour: {
|
11
|
+
foreground: '#ff0000',
|
12
|
+
background: '#000000'
|
13
|
+
},
|
14
|
+
y: 3,
|
15
|
+
x: 5,
|
16
|
+
z: 2,
|
17
|
+
width: 10,
|
18
|
+
height: 15,
|
19
|
+
current: "\e[1;1H#initialize"
|
20
|
+
})
|
21
|
+
}
|
22
|
+
|
6
23
|
it 'has a name attribute' do
|
7
|
-
|
24
|
+
interface.name.must_equal('#initialize')
|
8
25
|
end
|
9
26
|
|
10
27
|
it 'has a lines attribute' do
|
11
|
-
|
28
|
+
interface.lines.must_equal([])
|
12
29
|
end
|
13
30
|
|
14
31
|
it 'has a colour attribute' do
|
15
|
-
|
16
|
-
colour: {
|
17
|
-
foreground: '#ff0000',
|
18
|
-
background: '#000000'
|
19
|
-
}
|
20
|
-
}).colour.must_be_instance_of(Colour)
|
32
|
+
interface.colour.must_be_instance_of(Colour)
|
21
33
|
end
|
22
34
|
|
23
35
|
it 'has a y attribute' do
|
24
|
-
|
36
|
+
interface.y.must_equal(3)
|
25
37
|
Interface.new.y.must_equal(1)
|
26
38
|
end
|
27
39
|
|
28
40
|
it 'has an x attribute' do
|
29
|
-
|
41
|
+
interface.x.must_equal(5)
|
30
42
|
Interface.new.x.must_equal(1)
|
31
43
|
end
|
32
44
|
|
33
45
|
it 'has a z attribute' do
|
34
|
-
|
46
|
+
interface.z.must_equal(2)
|
35
47
|
Interface.new.z.must_equal(1)
|
36
48
|
end
|
37
49
|
|
38
50
|
it 'has a width attribute' do
|
39
|
-
|
51
|
+
interface.width.must_equal(10)
|
40
52
|
end
|
41
53
|
|
42
54
|
it 'has a height attribute' do
|
43
|
-
|
55
|
+
interface.height.must_equal(15)
|
44
56
|
end
|
45
57
|
|
46
58
|
it 'has a current attribute' do
|
47
|
-
|
59
|
+
interface.current.must_equal("\e[1;1H#initialize")
|
48
60
|
end
|
49
61
|
|
50
62
|
it 'has a cursor attribute' do
|
51
|
-
|
63
|
+
interface.cursor.must_equal(true)
|
52
64
|
Interface.new({ cursor: false }).cursor.must_equal(false)
|
53
|
-
Interface.new.cursor.must_equal(true)
|
54
65
|
end
|
55
66
|
|
56
67
|
it 'has a centred attribute' do
|
57
|
-
|
68
|
+
interface.centred.must_equal(false)
|
58
69
|
Interface.new({ centred: true }).centred.must_equal(true)
|
59
70
|
end
|
60
71
|
|
72
|
+
describe '#enqueue' do
|
73
|
+
it 'delegates to the Queue class to enqueue itself' do
|
74
|
+
skip
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
61
78
|
describe '#origin' do
|
62
79
|
it 'delegates to the Coordinate class to get the origin' do
|
63
80
|
interface = Interface.new({
|
@@ -86,40 +103,69 @@ module Vedeu
|
|
86
103
|
it 'returns a blank interface when there is no content to display (initial state)' do
|
87
104
|
Interface.new(attributes).refresh.must_equal(
|
88
105
|
"\e[38;5;196m\e[48;5;16m" \
|
89
|
-
"\e[1;1H
|
90
|
-
"\e[2;1H
|
91
|
-
"\e[3;1H
|
106
|
+
"\e[1;1H " \
|
107
|
+
"\e[2;1H " \
|
108
|
+
"\e[3;1H "
|
92
109
|
)
|
93
110
|
end
|
94
111
|
|
95
112
|
it 'returns the fresh content when content is queued up to be displayed' do
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
113
|
+
attributes = {
|
114
|
+
name: '#refresh',
|
115
|
+
lines: [
|
116
|
+
{ streams: '#refresh' },
|
117
|
+
{ streams: '#refresh' },
|
118
|
+
{ streams: '#refresh' }
|
119
|
+
],
|
120
|
+
colour: {
|
121
|
+
foreground: '#ff0000',
|
122
|
+
background: '#000000'
|
123
|
+
},
|
124
|
+
width: 8,
|
125
|
+
height: 3
|
126
|
+
}
|
127
|
+
interface = Interface.new(attributes)
|
128
|
+
interface.enqueue
|
102
129
|
|
103
130
|
interface.refresh.must_equal(
|
104
131
|
"\e[38;5;196m\e[48;5;16m" \
|
105
|
-
"\e[1;
|
106
|
-
"\e[2;
|
107
|
-
"\e[3;
|
132
|
+
"\e[1;1H " \
|
133
|
+
"\e[2;1H " \
|
134
|
+
"\e[3;1H " \
|
135
|
+
"\e[1;1H#refresh" \
|
136
|
+
"\e[2;1H#refresh" \
|
137
|
+
"\e[3;1H#refresh"
|
108
138
|
)
|
109
139
|
end
|
110
140
|
|
111
141
|
it 'returns the previously shown content when there is stale content from last run' do
|
142
|
+
attributes = {
|
143
|
+
name: '#refresh',
|
144
|
+
lines: [],
|
145
|
+
colour: {
|
146
|
+
foreground: '#ff0000',
|
147
|
+
background: '#000000'
|
148
|
+
},
|
149
|
+
width: 8,
|
150
|
+
height: 3
|
151
|
+
}
|
112
152
|
interface = Interface.new(attributes)
|
113
153
|
interface.current = "\e[38;5;196m\e[48;5;16m" \
|
114
|
-
"\e[1;
|
115
|
-
"\e[2;
|
116
|
-
"\e[3;
|
154
|
+
"\e[1;1H " \
|
155
|
+
"\e[2;1H " \
|
156
|
+
"\e[3;1H " \
|
157
|
+
"\e[1;1H#refresh" \
|
158
|
+
"\e[2;1H#refresh" \
|
159
|
+
"\e[3;1H#refresh"
|
117
160
|
|
118
161
|
interface.refresh.must_equal(
|
119
162
|
"\e[38;5;196m\e[48;5;16m" \
|
120
|
-
"\e[1;
|
121
|
-
"\e[2;
|
122
|
-
"\e[3;
|
163
|
+
"\e[1;1H " \
|
164
|
+
"\e[2;1H " \
|
165
|
+
"\e[3;1H " \
|
166
|
+
"\e[1;1H#refresh" \
|
167
|
+
"\e[2;1H#refresh" \
|
168
|
+
"\e[3;1H#refresh"
|
123
169
|
)
|
124
170
|
end
|
125
171
|
end
|
@@ -137,9 +183,9 @@ module Vedeu
|
|
137
183
|
height: 3
|
138
184
|
}).to_s.must_equal(
|
139
185
|
"\e[38;5;196m\e[48;5;16m" \
|
140
|
-
"\e[1;1H
|
141
|
-
"\e[2;1H
|
142
|
-
"\e[3;1H
|
186
|
+
"\e[1;1H " \
|
187
|
+
"\e[2;1H " \
|
188
|
+
"\e[3;1H "
|
143
189
|
)
|
144
190
|
end
|
145
191
|
end
|
@@ -3,36 +3,42 @@ require_relative '../../../../lib/vedeu/models/line'
|
|
3
3
|
|
4
4
|
module Vedeu
|
5
5
|
describe Line do
|
6
|
-
|
6
|
+
let(:line) {
|
7
7
|
Line.new({
|
8
|
-
colour: {
|
9
|
-
|
8
|
+
colour: {
|
9
|
+
foreground: '#ff0000',
|
10
|
+
background: '#000000'
|
11
|
+
},
|
12
|
+
model: {},
|
13
|
+
streams: [],
|
14
|
+
style: 'normal'
|
15
|
+
})
|
16
|
+
}
|
17
|
+
|
18
|
+
it 'has a colour attribute' do
|
19
|
+
line.colour.must_be_instance_of(Colour)
|
10
20
|
end
|
11
21
|
|
12
22
|
it 'has a model attribute' do
|
13
|
-
|
23
|
+
line.model.must_be_instance_of(Hash)
|
14
24
|
end
|
15
25
|
|
16
26
|
it 'has a streams attribute' do
|
17
|
-
|
27
|
+
line.streams.must_equal([])
|
18
28
|
end
|
19
29
|
|
20
30
|
describe '#to_json' do
|
21
31
|
it 'returns an String' do
|
22
|
-
|
23
|
-
colour: { foreground: '#ff0000', background: '#000000' },
|
24
|
-
style: 'normal',
|
25
|
-
streams: [],
|
26
|
-
}).to_json.must_equal("{\"colour\":{\"foreground\":\"#ff0000\",\"background\":\"#000000\"},\"style\":[\"normal\"],\"streams\":[]}")
|
32
|
+
line.to_json.must_equal("{\"colour\":{\"foreground\":\"#ff0000\",\"background\":\"#000000\"},\"style\":[\"normal\"],\"streams\":[]}")
|
27
33
|
end
|
28
34
|
end
|
29
35
|
|
30
36
|
describe '#to_s' do
|
31
37
|
it 'returns an String' do
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
38
|
+
line.to_s.must_equal(
|
39
|
+
"\e[38;5;196m\e[48;5;16m" \
|
40
|
+
"\e[24m\e[21m\e[27m"
|
41
|
+
)
|
36
42
|
end
|
37
43
|
end
|
38
44
|
end
|
@@ -7,20 +7,24 @@ module Vedeu
|
|
7
7
|
end
|
8
8
|
|
9
9
|
describe Presentation do
|
10
|
+
let(:presentation) {
|
11
|
+
TestPresentation.new({
|
12
|
+
colour: {
|
13
|
+
foreground: '#ff0000',
|
14
|
+
background: '#333333'
|
15
|
+
},
|
16
|
+
style: ['bold', 'underline']
|
17
|
+
})
|
18
|
+
}
|
19
|
+
|
10
20
|
describe '#colour' do
|
11
21
|
it 'returns a Colour instance' do
|
12
|
-
presentation = TestPresentation.new({
|
13
|
-
colour: { foreground: '#ff0000', background: '#333333' }
|
14
|
-
})
|
15
22
|
presentation.colour.must_be_instance_of(Colour)
|
16
23
|
end
|
17
24
|
end
|
18
25
|
|
19
26
|
describe '#style' do
|
20
27
|
it 'has a style attribute' do
|
21
|
-
presentation = TestPresentation.new({
|
22
|
-
style: ['bold', 'underline']
|
23
|
-
})
|
24
28
|
presentation.style.must_equal(['bold', 'underline'])
|
25
29
|
end
|
26
30
|
end
|
@@ -15,8 +15,8 @@ module Vedeu
|
|
15
15
|
height: 2
|
16
16
|
})
|
17
17
|
InterfaceRenderer.clear(interface).must_equal(
|
18
|
-
"\e[1;1H
|
19
|
-
"\e[2;1H
|
18
|
+
"\e[1;1H " \
|
19
|
+
"\e[2;1H "
|
20
20
|
)
|
21
21
|
end
|
22
22
|
|
@@ -32,8 +32,8 @@ module Vedeu
|
|
32
32
|
})
|
33
33
|
InterfaceRenderer.clear(interface).must_equal(
|
34
34
|
"\e[38;5;46m\e[48;5;226m" \
|
35
|
-
"\e[1;1H
|
36
|
-
"\e[2;1H
|
35
|
+
"\e[1;1H " \
|
36
|
+
"\e[2;1H "
|
37
37
|
)
|
38
38
|
end
|
39
39
|
end
|
@@ -42,7 +42,7 @@ module Vedeu
|
|
42
42
|
proc { Process.evaluate }.must_raise(StopIteration)
|
43
43
|
end
|
44
44
|
|
45
|
-
it 'returns
|
45
|
+
it 'returns a collection of interfaces when there is a result' do
|
46
46
|
CommandRepository.reset
|
47
47
|
CommandRepository.create({
|
48
48
|
name: 'test',
|
@@ -51,7 +51,10 @@ module Vedeu
|
|
51
51
|
})
|
52
52
|
Queue.reset
|
53
53
|
Queue.enqueue('t')
|
54
|
-
Process.evaluate
|
54
|
+
evaluation = Process.evaluate
|
55
|
+
|
56
|
+
evaluation.must_be_instance_of(Array)
|
57
|
+
evaluation.size.must_equal(1)
|
55
58
|
end
|
56
59
|
|
57
60
|
it 'returns a NilClass when there is no result' do
|
@@ -3,6 +3,8 @@ require_relative '../../../../lib/vedeu/repository/interface_repository'
|
|
3
3
|
|
4
4
|
module Vedeu
|
5
5
|
describe InterfaceRepository do
|
6
|
+
before { InterfaceRepository.reset }
|
7
|
+
|
6
8
|
describe '.create' do
|
7
9
|
it 'returns an Interface' do
|
8
10
|
InterfaceRepository.create({
|
@@ -14,19 +16,14 @@ module Vedeu
|
|
14
16
|
end
|
15
17
|
|
16
18
|
describe '.find' do
|
17
|
-
it 'returns
|
18
|
-
InterfaceRepository.create({
|
19
|
-
|
20
|
-
|
21
|
-
height: 5
|
22
|
-
})
|
23
|
-
InterfaceRepository.find('dummy')
|
24
|
-
.must_be_instance_of(Interface)
|
19
|
+
it 'returns the interface if it exists' do
|
20
|
+
hydrogen = InterfaceRepository.create({ name: 'hydrogen' })
|
21
|
+
|
22
|
+
InterfaceRepository.find('hydrogen').must_equal(hydrogen)
|
25
23
|
end
|
26
24
|
|
27
|
-
it 'raises an exception
|
28
|
-
InterfaceRepository.
|
29
|
-
proc { InterfaceRepository.find('dummy') }
|
25
|
+
it 'raises an exception if it does not exist' do
|
26
|
+
proc { InterfaceRepository.find('helium') }
|
30
27
|
.must_raise(UndefinedInterface)
|
31
28
|
end
|
32
29
|
end
|
@@ -43,7 +40,6 @@ module Vedeu
|
|
43
40
|
end
|
44
41
|
|
45
42
|
it 'returns a new interface when the interface does not exist' do
|
46
|
-
InterfaceRepository.reset
|
47
43
|
InterfaceRepository.update('dummy', { name: 'dumber' }).name
|
48
44
|
.must_equal('dumber')
|
49
45
|
end
|
@@ -55,17 +51,33 @@ module Vedeu
|
|
55
51
|
end
|
56
52
|
|
57
53
|
it 'returns the collection in order they should be drawn' do
|
58
|
-
InterfaceRepository.reset
|
59
54
|
InterfaceRepository.create({
|
60
|
-
name:
|
61
|
-
|
55
|
+
name: '.refresh_1',
|
56
|
+
width: 1,
|
57
|
+
height: 1,
|
58
|
+
z: 3,
|
59
|
+
lines: 'alpha'
|
60
|
+
}).enqueue
|
62
61
|
InterfaceRepository.create({
|
63
|
-
name:
|
64
|
-
|
62
|
+
name: '.refresh_2',
|
63
|
+
width: 1,
|
64
|
+
height: 1,
|
65
|
+
z: 1,
|
66
|
+
lines: 'beta'
|
67
|
+
}).enqueue
|
65
68
|
InterfaceRepository.create({
|
66
|
-
name:
|
67
|
-
|
68
|
-
|
69
|
+
name: '.refresh_3',
|
70
|
+
width: 1,
|
71
|
+
height: 1,
|
72
|
+
z: 2,
|
73
|
+
lines: 'gamma'
|
74
|
+
}).enqueue
|
75
|
+
|
76
|
+
InterfaceRepository.refresh.must_equal([
|
77
|
+
"\e[1;1H \e[1;1Hbeta",
|
78
|
+
"\e[1;1H \e[1;1Hgamma",
|
79
|
+
"\e[1;1H \e[1;1Halpha"
|
80
|
+
])
|
69
81
|
end
|
70
82
|
end
|
71
83
|
|
@@ -23,13 +23,6 @@ module Vedeu
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
describe '#find' do
|
27
|
-
it 'returns a Dummy' do
|
28
|
-
dummy = DummyRepository.create(Dummy.new)
|
29
|
-
DummyRepository.find(dummy.name).must_be_instance_of(Dummy)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
26
|
describe '#all' do
|
34
27
|
it 'returns all the stored items' do
|
35
28
|
DummyRepository.all.must_be_instance_of(Array)
|
@@ -37,10 +30,15 @@ module Vedeu
|
|
37
30
|
end
|
38
31
|
|
39
32
|
describe '#query' do
|
40
|
-
it '
|
41
|
-
|
42
|
-
DummyRepository.
|
43
|
-
|
33
|
+
it 'delegates to the adaptor' do
|
34
|
+
dumb = Dummy.new
|
35
|
+
DummyRepository.create(dumb)
|
36
|
+
|
37
|
+
result = DummyRepository.query(Dummy, :name, 'dummy')
|
38
|
+
result.must_equal(dumb)
|
39
|
+
|
40
|
+
result = DummyRepository.query(Dummy, :name, 'dumber')
|
41
|
+
result.must_equal(false)
|
44
42
|
end
|
45
43
|
end
|
46
44
|
|
@@ -24,12 +24,6 @@ module Vedeu
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
describe '#find' do
|
28
|
-
it 'returns a NilClass' do
|
29
|
-
Storage.new.find(nil, 'dummy').must_be_instance_of(NilClass)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
27
|
describe '#all' do
|
34
28
|
it 'returns an Array' do
|
35
29
|
Storage.new.all(nil).must_be_instance_of(Array)
|
@@ -37,9 +31,14 @@ module Vedeu
|
|
37
31
|
end
|
38
32
|
|
39
33
|
describe '#query' do
|
40
|
-
it 'returns
|
41
|
-
|
42
|
-
|
34
|
+
it 'returns the item if found, otherwise false' do
|
35
|
+
Record = Struct.new(:name)
|
36
|
+
storage = Storage.new
|
37
|
+
hydrogen = storage.create(Record.new('hydrogen'))
|
38
|
+
|
39
|
+
storage.query(Record, :name, nil).must_equal(false)
|
40
|
+
storage.query(Record, :name, 'lithium').must_equal(false)
|
41
|
+
storage.query(Record, :name, 'hydrogen').must_equal(hydrogen)
|
43
42
|
end
|
44
43
|
end
|
45
44
|
end
|