vedeu 0.4.13 → 0.4.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -1
- data/.travis.yml +2 -1
- data/Guardfile +6 -5
- data/README.md +3 -30
- data/Rakefile +5 -5
- data/bin/vedeu_drb_client +1 -1
- data/bin/vedeu_drb_server +91 -89
- data/bin/vedeu_test +4 -0
- data/config/rubocop_enabled.yml +5 -10
- data/examples/borders_app.rb +2 -1
- data/examples/colours_app.rb +13 -8
- data/examples/configuration_app.rb +3 -2
- data/examples/cursor_app.rb +16 -11
- data/examples/drb_app.rb +88 -89
- data/examples/focus_app.rb +31 -32
- data/examples/geometry_app.rb +2 -1
- data/examples/hello_world.rb +2 -1
- data/examples/lines_app.rb +2 -1
- data/examples/material_colours_app.rb +126 -0
- data/examples/typed_commands/typed_commands_app.rb +5 -1
- data/examples/view_templates_app/view_templates_app.rb +6 -3
- data/lib/vedeu/all.rb +1 -1
- data/lib/vedeu/api.rb +18 -10
- data/lib/vedeu/application.rb +0 -1
- data/lib/vedeu/bindings.rb +77 -16
- data/lib/vedeu/buffers/all.rb +2 -5
- data/lib/vedeu/buffers/buffer.rb +69 -25
- data/lib/vedeu/buffers/display_buffer.rb +3 -7
- data/lib/vedeu/configuration/all.rb +3 -6
- data/lib/vedeu/configuration/api.rb +28 -4
- data/lib/vedeu/configuration/cli.rb +9 -9
- data/lib/vedeu/configuration/configuration.rb +11 -7
- data/lib/vedeu/cursor/all.rb +3 -6
- data/lib/vedeu/cursor/cursor.rb +22 -14
- data/lib/vedeu/cursor/move.rb +32 -22
- data/lib/vedeu/cursor/refresh_cursor.rb +1 -1
- data/lib/vedeu/debug.rb +2 -1
- data/lib/vedeu/distributed/client.rb +1 -7
- data/lib/vedeu/distributed/server.rb +0 -4
- data/lib/vedeu/distributed/subprocess.rb +1 -1
- data/lib/vedeu/distributed/templates/default_configuration.vedeu +1 -1
- data/lib/vedeu/distributed/test_application.rb +3 -5
- data/lib/vedeu/distributed/uri.rb +2 -2
- data/lib/vedeu/dsl/all.rb +6 -6
- data/lib/vedeu/dsl/components/all.rb +0 -3
- data/lib/vedeu/dsl/components/border.rb +20 -12
- data/lib/vedeu/dsl/components/geometry.rb +68 -3
- data/lib/vedeu/dsl/components/keymap.rb +1 -2
- data/lib/vedeu/dsl/composition.rb +8 -1
- data/lib/vedeu/dsl/interface.rb +61 -11
- data/lib/vedeu/dsl/line.rb +12 -12
- data/lib/vedeu/dsl/shared/all.rb +4 -7
- data/lib/vedeu/dsl/shared/colour.rb +2 -2
- data/lib/vedeu/dsl/shared/text.rb +2 -35
- data/lib/vedeu/dsl/shared/use.rb +2 -2
- data/lib/vedeu/dsl/view.rb +4 -4
- data/lib/vedeu/events/all.rb +3 -5
- data/lib/vedeu/events/event.rb +5 -5
- data/lib/vedeu/geometry/all.rb +11 -16
- data/lib/vedeu/geometry/area.rb +2 -5
- data/lib/vedeu/geometry/canvas.rb +12 -16
- data/lib/vedeu/geometry/dimension.rb +20 -22
- data/lib/vedeu/geometry/geometry.rb +28 -30
- data/lib/vedeu/geometry/grid.rb +1 -1
- data/lib/vedeu/geometry/index_position.rb +7 -0
- data/lib/vedeu/geometry/null_geometry.rb +61 -0
- data/lib/vedeu/geometry/position.rb +0 -3
- data/lib/vedeu/geometry/position_index.rb +7 -0
- data/lib/vedeu/geometry/position_validator.rb +44 -33
- data/lib/vedeu/input/all.rb +5 -4
- data/lib/vedeu/input/keymap.rb +0 -1
- data/lib/vedeu/input/mapper.rb +1 -3
- data/lib/vedeu/launcher.rb +6 -7
- data/lib/vedeu/main_loop.rb +1 -2
- data/lib/vedeu/models/all.rb +1 -0
- data/lib/vedeu/models/cell.rb +5 -8
- data/lib/vedeu/models/char.rb +50 -15
- data/lib/vedeu/models/composition.rb +8 -1
- data/lib/vedeu/models/focus.rb +4 -4
- data/lib/vedeu/models/group.rb +3 -3
- data/lib/vedeu/models/interface.rb +62 -46
- data/lib/vedeu/models/line.rb +1 -1
- data/lib/vedeu/models/null.rb +48 -0
- data/lib/vedeu/models/stream.rb +5 -5
- data/lib/vedeu/output/all.rb +20 -30
- data/lib/vedeu/output/border.rb +93 -40
- data/lib/vedeu/output/clear.rb +100 -15
- data/lib/vedeu/output/colour.rb +56 -12
- data/lib/vedeu/output/compressor.rb +59 -0
- data/lib/vedeu/output/html_char.rb +4 -2
- data/lib/vedeu/output/null_border.rb +16 -4
- data/lib/vedeu/output/output.rb +13 -21
- data/lib/vedeu/output/presentation.rb +28 -23
- data/lib/vedeu/output/refresh.rb +2 -2
- data/lib/vedeu/output/renderers/all.rb +80 -3
- data/lib/vedeu/output/renderers/file_renderer.rb +38 -2
- data/lib/vedeu/output/renderers/html_renderer.rb +6 -4
- data/lib/vedeu/output/renderers/json_renderer.rb +52 -0
- data/lib/vedeu/output/renderers/null_renderer.rb +14 -0
- data/lib/vedeu/output/renderers/terminal_renderer.rb +2 -12
- data/lib/vedeu/output/style.rb +33 -3
- data/lib/vedeu/output/text.rb +98 -1
- data/lib/vedeu/output/translator.rb +30 -7
- data/lib/vedeu/output/viewport.rb +43 -79
- data/lib/vedeu/output/wordwrap.rb +4 -4
- data/lib/vedeu/repositories/all.rb +22 -179
- data/lib/vedeu/repositories/collection.rb +11 -13
- data/lib/vedeu/repositories/collections/all.rb +8 -0
- data/lib/vedeu/repositories/collections/chars.rb +9 -0
- data/lib/vedeu/repositories/collections/events.rb +9 -0
- data/lib/vedeu/repositories/collections/interfaces.rb +9 -0
- data/lib/vedeu/repositories/collections/keys.rb +9 -0
- data/lib/vedeu/repositories/collections/lines.rb +9 -0
- data/lib/vedeu/repositories/collections/streams.rb +9 -0
- data/lib/vedeu/repositories/model.rb +7 -2
- data/lib/vedeu/repositories/repositories/all.rb +14 -0
- data/lib/vedeu/repositories/repositories/background_colours.rb +14 -0
- data/lib/vedeu/repositories/repositories/borders.rb +38 -0
- data/lib/vedeu/repositories/repositories/buffers.rb +36 -0
- data/lib/vedeu/repositories/repositories/colours.rb +63 -0
- data/lib/vedeu/repositories/repositories/cursors.rb +29 -0
- data/lib/vedeu/repositories/repositories/events_repository.rb +24 -0
- data/lib/vedeu/repositories/repositories/foreground_colours.rb +14 -0
- data/lib/vedeu/repositories/repositories/geometries.rb +37 -0
- data/lib/vedeu/repositories/repositories/groups.rb +24 -0
- data/lib/vedeu/repositories/repositories/interfaces_repository.rb +24 -0
- data/lib/vedeu/repositories/repositories/keymaps.rb +24 -0
- data/lib/vedeu/repositories/repositories/menus.rb +24 -0
- data/lib/vedeu/repositories/repository.rb +29 -47
- data/lib/vedeu/storage/all.rb +6 -0
- data/lib/vedeu/storage/associative_store.rb +47 -0
- data/lib/vedeu/storage/conveyor_store.rb +69 -0
- data/lib/vedeu/storage/fifo_store.rb +37 -0
- data/lib/vedeu/storage/store.rb +58 -0
- data/lib/vedeu/support/all.rb +5 -10
- data/lib/vedeu/support/common.rb +0 -8
- data/lib/vedeu/support/log.rb +13 -24
- data/lib/vedeu/support/template.rb +4 -1
- data/lib/vedeu/support/terminal.rb +10 -10
- data/lib/vedeu/support/trace.rb +15 -88
- data/lib/vedeu/support/visibility.rb +73 -0
- data/lib/vedeu.rb +37 -0
- data/test/lib/vedeu/api_test.rb +7 -3
- data/test/lib/vedeu/application_test.rb +9 -3
- data/test/lib/vedeu/bindings_test.rb +21 -0
- data/test/lib/vedeu/buffers/buffer_test.rb +110 -134
- data/test/lib/vedeu/buffers/display_buffer_test.rb +8 -0
- data/test/lib/vedeu/configuration/api_test.rb +5 -1
- data/test/lib/vedeu/configuration/configuration_test.rb +4 -6
- data/test/lib/vedeu/cursor/cursor_test.rb +25 -17
- data/test/lib/vedeu/cursor/move_test.rb +7 -7
- data/test/lib/vedeu/distributed/client_test.rb +1 -1
- data/test/lib/vedeu/distributed/subprocess_test.rb +3 -1
- data/test/lib/vedeu/distributed/uri_test.rb +5 -5
- data/test/lib/vedeu/dsl/components/geometry_test.rb +43 -0
- data/test/lib/vedeu/dsl/components/keymap_test.rb +1 -1
- data/test/lib/vedeu/dsl/composition_test.rb +6 -5
- data/test/lib/vedeu/dsl/interface_test.rb +81 -16
- data/test/lib/vedeu/dsl/shared/colour_test.rb +4 -4
- data/test/lib/vedeu/dsl/shared/text_test.rb +87 -9
- data/test/lib/vedeu/dsl/stream_test.rb +1 -1
- data/test/lib/vedeu/events/event_test.rb +3 -1
- data/test/lib/vedeu/events/trigger_test.rb +8 -4
- data/test/lib/vedeu/geometry/dimension_test.rb +1 -1
- data/test/lib/vedeu/geometry/geometry_test.rb +5 -3
- data/test/lib/vedeu/geometry/index_position_test.rb +30 -7
- data/test/lib/vedeu/geometry/null_geometry_test.rb +57 -0
- data/test/lib/vedeu/geometry/position_index_test.rb +14 -0
- data/test/lib/vedeu/geometry/position_validator_test.rb +17 -3
- data/test/lib/vedeu/input/keymap_test.rb +3 -1
- data/test/lib/vedeu/input/mapper_test.rb +8 -4
- data/test/lib/vedeu/launcher_test.rb +1 -1
- data/test/lib/vedeu/models/cell_test.rb +10 -8
- data/test/lib/vedeu/models/char_test.rb +52 -28
- data/test/lib/vedeu/models/composition_test.rb +26 -4
- data/test/lib/vedeu/models/group_test.rb +11 -5
- data/test/lib/vedeu/models/interface_test.rb +32 -19
- data/test/lib/vedeu/models/line_test.rb +21 -25
- data/test/lib/vedeu/models/menu_test.rb +10 -6
- data/test/lib/vedeu/models/null_test.rb +66 -0
- data/test/lib/vedeu/models/stream_test.rb +13 -10
- data/test/lib/vedeu/output/border_test.rb +29 -8
- data/test/lib/vedeu/output/clear_test.rb +23 -4
- data/test/lib/vedeu/output/colour_test.rb +20 -4
- data/test/lib/vedeu/output/compressor_test.rb +43 -0
- data/test/lib/vedeu/output/html_char_test.rb +29 -17
- data/test/lib/vedeu/output/null_border_test.rb +2 -1
- data/test/lib/vedeu/output/output_test.rb +20 -30
- data/test/lib/vedeu/output/presentation_test.rb +39 -16
- data/test/lib/vedeu/output/refresh_test.rb +14 -10
- data/test/lib/vedeu/output/renderers/all_test.rb +96 -0
- data/test/lib/vedeu/output/renderers/file_renderer_test.rb +1 -1
- data/test/lib/vedeu/output/renderers/html_renderer_test.rb +13 -9
- data/test/lib/vedeu/output/renderers/json_renderer_test.rb +52 -0
- data/test/lib/vedeu/output/renderers/null_renderer_test.rb +19 -0
- data/test/lib/vedeu/output/style_test.rb +41 -1
- data/test/lib/vedeu/output/text_test.rb +61 -10
- data/test/lib/vedeu/output/translator_test.rb +14 -0
- data/test/lib/vedeu/output/viewport_test.rb +22 -3
- data/test/lib/vedeu/output/virtual_terminal_test.rb +3 -3
- data/test/lib/vedeu/output/wordwrap_test.rb +58 -45
- data/test/lib/vedeu/repositories/collections/chars_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/events_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/interfaces_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/keys_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/lines_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/streams_test.rb +16 -0
- data/test/lib/vedeu/repositories/repositories/background_colours_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/borders_test.rb +51 -0
- data/test/lib/vedeu/repositories/repositories/buffers_test.rb +52 -0
- data/test/lib/vedeu/repositories/repositories/colours_test.rb +16 -0
- data/test/lib/vedeu/repositories/repositories/cursors_test.rb +39 -0
- data/test/lib/vedeu/repositories/repositories/events_repository_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/foreground_colours_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/geometries_test.rb +42 -0
- data/test/lib/vedeu/repositories/repositories/groups_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/interfaces_repositories_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/keymaps_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/menus_test.rb +17 -0
- data/test/lib/vedeu/repositories/repository_test.rb +16 -36
- data/test/lib/vedeu/storage/associative_store_test.rb +69 -0
- data/test/lib/vedeu/storage/conveyor_store_test.rb +135 -0
- data/test/lib/vedeu/storage/fifo_store_test.rb +47 -0
- data/test/lib/vedeu/storage/store_test.rb +123 -0
- data/test/lib/vedeu/support/common_test.rb +0 -9
- data/test/lib/vedeu/support/terminal_test.rb +78 -55
- data/test/lib/vedeu/support/visibility_test.rb +80 -0
- data/test/test_helper.rb +13 -11
- data/vedeu.gemspec +4 -3
- metadata +92 -32
- data/lib/vedeu/cursor/toggle.rb +0 -55
- data/lib/vedeu/exceptions.rb +0 -37
- data/lib/vedeu/geometry/centre.rb +0 -85
- data/lib/vedeu/geometry/content.rb +0 -70
- data/lib/vedeu/geometry/limit.rb +0 -58
- data/lib/vedeu/output/compositor.rb +0 -62
- data/lib/vedeu/repositories/collections.rb +0 -41
- data/lib/vedeu/support/coercions.rb +0 -60
- data/lib/vedeu/support/sentence.rb +0 -91
- data/lib/vedeu/support/visible.rb +0 -90
- data/test/lib/vedeu/cursor/toggle_test.rb +0 -63
- data/test/lib/vedeu/geometry/centre_test.rb +0 -58
- data/test/lib/vedeu/geometry/content_test.rb +0 -98
- data/test/lib/vedeu/geometry/limit_test.rb +0 -30
- data/test/lib/vedeu/output/compositor_test.rb +0 -48
- data/test/lib/vedeu/repositories/all_test.rb +0 -135
- data/test/lib/vedeu/repositories/collections_test.rb +0 -71
- data/test/lib/vedeu/support/coercions_test.rb +0 -84
- data/test/lib/vedeu/support/sentence_test.rb +0 -56
- data/test/lib/vedeu/support/visible_test.rb +0 -161
@@ -35,13 +35,31 @@ module Vedeu
|
|
35
35
|
end
|
36
36
|
}
|
37
37
|
|
38
|
-
it { subject.must_be_instance_of(Vedeu::Border) }
|
39
|
-
|
40
38
|
context 'when the block is not given' do
|
41
39
|
subject { instance.border }
|
42
40
|
|
43
41
|
it { proc { subject }.must_raise(InvalidSyntax) }
|
44
42
|
end
|
43
|
+
|
44
|
+
context 'when the block is given' do
|
45
|
+
subject { instance.border { } }
|
46
|
+
|
47
|
+
it { subject.must_be_instance_of(Vedeu::Border) }
|
48
|
+
|
49
|
+
context 'when the name is not given' do
|
50
|
+
it 'uses the interface name for storing the border' do
|
51
|
+
subject.name.must_equal('actinium')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'when the name is given' do
|
56
|
+
subject { instance.border('magnesium') { } }
|
57
|
+
|
58
|
+
it 'uses the name for storing the border' do
|
59
|
+
subject.name.must_equal('magnesium')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
45
63
|
end
|
46
64
|
|
47
65
|
describe '#border!' do
|
@@ -59,7 +77,7 @@ module Vedeu
|
|
59
77
|
|
60
78
|
it {
|
61
79
|
subject
|
62
|
-
Vedeu.cursors.find('actinium').
|
80
|
+
Vedeu.cursors.find('actinium').visible?.must_equal(false)
|
63
81
|
}
|
64
82
|
|
65
83
|
context 'when the value is false' do
|
@@ -67,16 +85,16 @@ module Vedeu
|
|
67
85
|
|
68
86
|
it {
|
69
87
|
subject
|
70
|
-
Vedeu.cursors.find('actinium').
|
88
|
+
Vedeu.cursors.find('actinium').visible?.must_equal(false)
|
71
89
|
}
|
72
90
|
end
|
73
91
|
|
74
|
-
context 'when the value is
|
75
|
-
let(:value) {
|
92
|
+
context 'when the value is nil' do
|
93
|
+
let(:value) {}
|
76
94
|
|
77
95
|
it {
|
78
96
|
subject
|
79
|
-
Vedeu.cursors.find('actinium').
|
97
|
+
Vedeu.cursors.find('actinium').visible?.must_equal(false)
|
80
98
|
}
|
81
99
|
end
|
82
100
|
|
@@ -85,7 +103,7 @@ module Vedeu
|
|
85
103
|
|
86
104
|
it {
|
87
105
|
subject
|
88
|
-
Vedeu.cursors.find('actinium').
|
106
|
+
Vedeu.cursors.find('actinium').visible?.must_equal(true)
|
89
107
|
}
|
90
108
|
end
|
91
109
|
|
@@ -94,7 +112,7 @@ module Vedeu
|
|
94
112
|
|
95
113
|
it {
|
96
114
|
subject
|
97
|
-
Vedeu.cursors.find('actinium').
|
115
|
+
Vedeu.cursors.find('actinium').visible?.must_equal(true)
|
98
116
|
}
|
99
117
|
end
|
100
118
|
|
@@ -103,7 +121,7 @@ module Vedeu
|
|
103
121
|
|
104
122
|
it {
|
105
123
|
subject
|
106
|
-
Vedeu.cursors.find('actinium').
|
124
|
+
Vedeu.cursors.find('actinium').visible?.must_equal(true)
|
107
125
|
}
|
108
126
|
end
|
109
127
|
end
|
@@ -113,7 +131,7 @@ module Vedeu
|
|
113
131
|
|
114
132
|
it {
|
115
133
|
subject
|
116
|
-
Vedeu.cursors.find('actinium').
|
134
|
+
Vedeu.cursors.find('actinium').visible?.must_equal(true)
|
117
135
|
}
|
118
136
|
end
|
119
137
|
|
@@ -159,13 +177,31 @@ module Vedeu
|
|
159
177
|
end
|
160
178
|
}
|
161
179
|
|
162
|
-
|
163
|
-
|
164
|
-
context 'when the require block is not provided' do
|
180
|
+
context 'when the required block is not provided' do
|
165
181
|
subject { instance.geometry }
|
166
182
|
|
167
183
|
it { proc { subject }.must_raise(InvalidSyntax) }
|
168
184
|
end
|
185
|
+
|
186
|
+
context 'when the block is given' do
|
187
|
+
subject { instance.geometry { } }
|
188
|
+
|
189
|
+
it { subject.must_be_instance_of(Vedeu::Geometry) }
|
190
|
+
|
191
|
+
context 'when the name is not given' do
|
192
|
+
it 'uses the interface name for storing the geometry' do
|
193
|
+
subject.name.must_equal('actinium')
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
context 'when the name is given' do
|
198
|
+
subject { instance.geometry('magnesium') { } }
|
199
|
+
|
200
|
+
it 'uses the name for storing the geometry' do
|
201
|
+
subject.name.must_equal('magnesium')
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
169
205
|
end
|
170
206
|
|
171
207
|
describe '#group' do
|
@@ -184,13 +220,15 @@ module Vedeu
|
|
184
220
|
end
|
185
221
|
|
186
222
|
context 'when the named group exists' do
|
223
|
+
let(:members) { Set['actinium', 'lanthanum'] }
|
224
|
+
|
187
225
|
before do
|
188
|
-
Vedeu::Group.new(
|
226
|
+
Vedeu::Group.new(name: 'elements', members: ['lanthanum']).store
|
189
227
|
end
|
190
228
|
|
191
229
|
it {
|
192
230
|
subject
|
193
|
-
Vedeu.groups.find('elements').members.must_equal(
|
231
|
+
Vedeu.groups.find('elements').members.must_equal(members)
|
194
232
|
}
|
195
233
|
end
|
196
234
|
|
@@ -238,6 +276,33 @@ module Vedeu
|
|
238
276
|
end
|
239
277
|
end
|
240
278
|
|
279
|
+
describe '#show!' do
|
280
|
+
subject {
|
281
|
+
Vedeu.interface 'xenon' do
|
282
|
+
show!
|
283
|
+
end
|
284
|
+
}
|
285
|
+
|
286
|
+
it { subject.visible.must_equal(true) }
|
287
|
+
end
|
288
|
+
|
289
|
+
describe '#hide!' do
|
290
|
+
subject {
|
291
|
+
Vedeu.interface 'xenon' do
|
292
|
+
hide!
|
293
|
+
end
|
294
|
+
}
|
295
|
+
|
296
|
+
it { subject.visible.must_equal(false) }
|
297
|
+
end
|
298
|
+
|
299
|
+
describe '#visible' do
|
300
|
+
it { instance.visible(false).must_equal(false) }
|
301
|
+
it { instance.visible(true).must_equal(true) }
|
302
|
+
it { instance.visible(nil).must_equal(false) }
|
303
|
+
it { instance.visible(:show).must_equal(true) }
|
304
|
+
end
|
305
|
+
|
241
306
|
end # Interface
|
242
307
|
|
243
308
|
end # DSL
|
@@ -26,7 +26,7 @@ module Vedeu
|
|
26
26
|
|
27
27
|
it 'sets the background' do
|
28
28
|
subject.attributes.must_equal(
|
29
|
-
|
29
|
+
background: '#00ff00', foreground: ''
|
30
30
|
)
|
31
31
|
end
|
32
32
|
end
|
@@ -38,7 +38,7 @@ module Vedeu
|
|
38
38
|
|
39
39
|
it 'sets the foreground' do
|
40
40
|
subject.attributes.must_equal(
|
41
|
-
|
41
|
+
background: '', foreground: '#ff00ff'
|
42
42
|
)
|
43
43
|
end
|
44
44
|
end
|
@@ -55,7 +55,7 @@ module Vedeu
|
|
55
55
|
|
56
56
|
it 'sets only the valid attributes' do
|
57
57
|
subject.attributes.must_equal(
|
58
|
-
|
58
|
+
background: '', foreground: '#ff00ff'
|
59
59
|
)
|
60
60
|
end
|
61
61
|
end
|
@@ -65,7 +65,7 @@ module Vedeu
|
|
65
65
|
|
66
66
|
it 'sets only the valid attributes' do
|
67
67
|
subject.attributes.must_equal(
|
68
|
-
|
68
|
+
background: '#00ff00', foreground: ''
|
69
69
|
)
|
70
70
|
end
|
71
71
|
end
|
@@ -4,27 +4,105 @@ module Vedeu
|
|
4
4
|
|
5
5
|
module DSL
|
6
6
|
|
7
|
-
class TextTestClass
|
8
|
-
include Vedeu::DSL::Text
|
9
|
-
|
10
|
-
end
|
11
|
-
|
12
7
|
describe Text do
|
13
8
|
|
14
|
-
let(:instance) { Vedeu::DSL::TextTestClass.new }
|
15
|
-
let(:value) {}
|
16
|
-
let(:options) { {} }
|
17
|
-
|
18
9
|
describe '#text' do
|
10
|
+
let(:value) {}
|
11
|
+
let(:options) { {} }
|
12
|
+
let(:modified_options) {
|
13
|
+
{
|
14
|
+
anchor: anchor,
|
15
|
+
model: model,
|
16
|
+
}
|
17
|
+
}
|
18
|
+
let(:anchor) { :text }
|
19
|
+
let(:model) { Vedeu::Line.new }
|
20
|
+
let(:instance) { Vedeu::DSL::Line.new(model) }
|
21
|
+
|
19
22
|
subject { instance.text(value, options) }
|
20
23
|
|
21
24
|
context 'when the model is a Vedeu::Interface' do
|
25
|
+
let(:model) { Vedeu::Interface.new }
|
26
|
+
let(:instance) { Vedeu::DSL::Interface.new(model) }
|
27
|
+
|
28
|
+
it { subject.must_be_instance_of(Vedeu::Lines) }
|
29
|
+
|
30
|
+
it 'adds the text to the model' do
|
31
|
+
Vedeu::Text.expects(:add).with(value, modified_options)
|
32
|
+
subject
|
33
|
+
end
|
22
34
|
end
|
23
35
|
|
24
36
|
context 'when the model is a Vedeu::Line' do
|
37
|
+
let(:model) { Vedeu::Line.new }
|
38
|
+
let(:instance) { Vedeu::DSL::Line.new(model) }
|
39
|
+
|
40
|
+
it { subject.must_be_instance_of(Vedeu::Streams) }
|
41
|
+
|
42
|
+
it 'adds the text to the model' do
|
43
|
+
Vedeu::Text.expects(:add).with(value, modified_options)
|
44
|
+
subject
|
45
|
+
end
|
25
46
|
end
|
26
47
|
|
27
48
|
context 'when the model is a Vedeu::Stream' do
|
49
|
+
let(:parent) { Vedeu::Line.new }
|
50
|
+
let(:model) { Vedeu::Stream.new(parent: parent) }
|
51
|
+
let(:instance) { Vedeu::DSL::Stream.new(model) }
|
52
|
+
|
53
|
+
it { subject.must_be_instance_of(Vedeu::Streams) }
|
54
|
+
|
55
|
+
it 'adds the text to the model' do
|
56
|
+
Vedeu::Text.expects(:add).with(value, modified_options)
|
57
|
+
subject
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'alias methods' do
|
62
|
+
context '#align' do
|
63
|
+
let(:anchor) { :align }
|
64
|
+
|
65
|
+
it 'adds the text to the model' do
|
66
|
+
Vedeu::Text.expects(:add).with(value, modified_options)
|
67
|
+
instance.align(value, options)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context '#center' do
|
72
|
+
let(:anchor) { :center }
|
73
|
+
|
74
|
+
it 'adds the text to the model' do
|
75
|
+
Vedeu::Text.expects(:add).with(value, modified_options)
|
76
|
+
instance.center(value, options)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context '#centre' do
|
81
|
+
let(:anchor) { :centre }
|
82
|
+
|
83
|
+
it 'adds the text to the model' do
|
84
|
+
Vedeu::Text.expects(:add).with(value, modified_options)
|
85
|
+
instance.centre(value, options)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context '#left' do
|
90
|
+
let(:anchor) { :left }
|
91
|
+
|
92
|
+
it 'adds the text to the model' do
|
93
|
+
Vedeu::Text.expects(:add).with(value, modified_options)
|
94
|
+
instance.left(value, options)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context '#right' do
|
99
|
+
let(:anchor) { :right }
|
100
|
+
|
101
|
+
it 'adds the text to the model' do
|
102
|
+
Vedeu::Text.expects(:add).with(value, modified_options)
|
103
|
+
instance.right(value, options)
|
104
|
+
end
|
105
|
+
end
|
28
106
|
end
|
29
107
|
end
|
30
108
|
|
@@ -8,7 +8,7 @@ module Vedeu
|
|
8
8
|
|
9
9
|
let(:described) { Vedeu::DSL::Stream }
|
10
10
|
let(:instance) { described.new(model) }
|
11
|
-
let(:model) { Vedeu::Stream.new(
|
11
|
+
let(:model) { Vedeu::Stream.new(parent: parent) }
|
12
12
|
let(:client) {}
|
13
13
|
let(:parent) { Vedeu::Line.new }
|
14
14
|
|
@@ -29,7 +29,9 @@ module Vedeu
|
|
29
29
|
it { instance.instance_variable_get('@deadline').must_equal(0) }
|
30
30
|
it { instance.instance_variable_get('@executed_at').must_equal(0) }
|
31
31
|
it { instance.instance_variable_get('@now').must_equal(0) }
|
32
|
-
it
|
32
|
+
it do
|
33
|
+
instance.instance_variable_get('@repository').must_equal(Vedeu.events)
|
34
|
+
end
|
33
35
|
end
|
34
36
|
|
35
37
|
describe '#bind' do
|
@@ -18,10 +18,14 @@ module Vedeu
|
|
18
18
|
end
|
19
19
|
|
20
20
|
describe '#initialize' do
|
21
|
-
|
22
|
-
|
23
|
-
it {
|
24
|
-
it {
|
21
|
+
subject { instance }
|
22
|
+
|
23
|
+
it { subject.must_be_instance_of(Vedeu::Trigger) }
|
24
|
+
it { subject.instance_variable_get('@name').must_equal(event_name) }
|
25
|
+
it { subject.instance_variable_get('@args').must_equal([args]) }
|
26
|
+
it do
|
27
|
+
subject.instance_variable_get('@repository').must_equal(Vedeu.events)
|
28
|
+
end
|
25
29
|
end
|
26
30
|
|
27
31
|
describe '#trigger' do
|
@@ -40,7 +40,9 @@ module Vedeu
|
|
40
40
|
it { instance.instance_variable_get('@xn').must_equal(xn) }
|
41
41
|
it { instance.instance_variable_get('@y').must_equal(y) }
|
42
42
|
it { instance.instance_variable_get('@yn').must_equal(yn) }
|
43
|
-
it
|
43
|
+
it do
|
44
|
+
instance.instance_variable_get('@repository').must_equal(Vedeu.geometries)
|
45
|
+
end
|
44
46
|
end
|
45
47
|
|
46
48
|
describe '#top, #right, #bottom, #left' do
|
@@ -85,7 +87,7 @@ module Vedeu
|
|
85
87
|
|
86
88
|
it { instance.top.must_equal(4) }
|
87
89
|
it { instance.right.must_equal(18) }
|
88
|
-
it { instance.bottom.must_equal(
|
90
|
+
it { instance.bottom.must_equal(9) }
|
89
91
|
it { instance.left.must_equal(1) }
|
90
92
|
end
|
91
93
|
|
@@ -93,7 +95,7 @@ module Vedeu
|
|
93
95
|
let(:attributes) { { height: 6, width: 18, x: 4 } }
|
94
96
|
|
95
97
|
it { instance.top.must_equal(1) }
|
96
|
-
it { instance.right.must_equal(
|
98
|
+
it { instance.right.must_equal(21) }
|
97
99
|
it { instance.bottom.must_equal(6) }
|
98
100
|
it { instance.left.must_equal(4) }
|
99
101
|
end
|
@@ -53,16 +53,25 @@ module Vedeu
|
|
53
53
|
|
54
54
|
it { subject.must_be_instance_of(Vedeu::Position) }
|
55
55
|
|
56
|
-
context 'when the interface
|
57
|
-
|
56
|
+
context 'when the interface is registered' do
|
57
|
+
context 'when the interface has a border' do
|
58
|
+
before { Vedeu.border('IndexPosition.from_interface') {} }
|
58
59
|
|
59
|
-
|
60
|
-
|
60
|
+
it { subject.x.must_equal(8) }
|
61
|
+
it { subject.y.must_equal(10) }
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'when the interface does not have a border' do
|
65
|
+
it { subject.x.must_equal(7) }
|
66
|
+
it { subject.y.must_equal(9) }
|
67
|
+
end
|
61
68
|
end
|
62
69
|
|
63
|
-
context 'when the interface
|
64
|
-
|
65
|
-
|
70
|
+
context 'when the interface is not registered' do
|
71
|
+
before { Vedeu.interfaces.reset }
|
72
|
+
|
73
|
+
it { subject.x.must_equal(4) }
|
74
|
+
it { subject.y.must_equal(4) }
|
66
75
|
end
|
67
76
|
end
|
68
77
|
|
@@ -74,6 +83,20 @@ module Vedeu
|
|
74
83
|
it { subject.x.must_equal(22) }
|
75
84
|
end
|
76
85
|
|
86
|
+
describe '#eql?' do
|
87
|
+
let(:other) { described.new(8, 21) }
|
88
|
+
|
89
|
+
subject { instance.eql?(other) }
|
90
|
+
|
91
|
+
it { subject.must_equal(true) }
|
92
|
+
|
93
|
+
context 'when different to other' do
|
94
|
+
let(:other) { described.new(2, 9) }
|
95
|
+
|
96
|
+
it { subject.must_equal(false) }
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
77
100
|
describe '#y' do
|
78
101
|
subject { instance.y }
|
79
102
|
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe NullGeometry do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::NullGeometry }
|
8
|
+
let(:instance) { described.new }
|
9
|
+
|
10
|
+
before do
|
11
|
+
Vedeu::Terminal.stubs(:height).returns(25)
|
12
|
+
Vedeu::Terminal.stubs(:width).returns(40)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#initialize' do
|
16
|
+
it { instance.must_be_instance_of(described) }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#centred' do
|
20
|
+
subject { instance.centred }
|
21
|
+
|
22
|
+
it { subject.must_equal(false) }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#store' do
|
26
|
+
subject { instance.store }
|
27
|
+
|
28
|
+
it { subject.must_be_instance_of(described) }
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#height' do
|
32
|
+
it { instance.height.must_equal(25) }
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#width' do
|
36
|
+
it { instance.width.must_equal(40) }
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#x' do
|
40
|
+
it { instance.x.must_equal(1) }
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#xn' do
|
44
|
+
it { instance.xn.must_equal(40) }
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#y' do
|
48
|
+
it { instance.y.must_equal(1) }
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#yn' do
|
52
|
+
it { instance.yn.must_equal(25) }
|
53
|
+
end
|
54
|
+
|
55
|
+
end # NullGeometry
|
56
|
+
|
57
|
+
end # Vedeu
|
@@ -41,6 +41,20 @@ module Vedeu
|
|
41
41
|
it { subject.must_equal([5, 16]) }
|
42
42
|
end
|
43
43
|
|
44
|
+
describe '#eql?' do
|
45
|
+
let(:other) { described.new(6, 17) }
|
46
|
+
|
47
|
+
subject { instance.eql?(other) }
|
48
|
+
|
49
|
+
it { subject.must_equal(true) }
|
50
|
+
|
51
|
+
context 'when different to other' do
|
52
|
+
let(:other) { described.new(2, 9) }
|
53
|
+
|
54
|
+
it { subject.must_equal(false) }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
44
58
|
describe '#to_position' do
|
45
59
|
subject { instance.to_position }
|
46
60
|
|
@@ -5,18 +5,32 @@ module Vedeu
|
|
5
5
|
describe PositionValidator do
|
6
6
|
|
7
7
|
let(:described) { Vedeu::PositionValidator }
|
8
|
-
let(:instance) { described.new(
|
9
|
-
let(:
|
8
|
+
let(:instance) { described.new(_name, x, y) }
|
9
|
+
let(:_name) {}
|
10
10
|
let(:x) {}
|
11
11
|
let(:y) {}
|
12
12
|
|
13
13
|
describe '#initialize' do
|
14
14
|
it { instance.must_be_instance_of(described) }
|
15
|
-
it { instance.instance_variable_get('@
|
15
|
+
it { instance.instance_variable_get('@name').must_equal(_name) }
|
16
16
|
it { instance.instance_variable_get('@x').must_equal(x) }
|
17
17
|
it { instance.instance_variable_get('@y').must_equal(y) }
|
18
18
|
end
|
19
19
|
|
20
|
+
describe '.validate' do
|
21
|
+
subject { described.validate(_name, x, y) }
|
22
|
+
|
23
|
+
it { instance.must_be_instance_of(described) }
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#y' do
|
27
|
+
subject { described.validate(_name, x, y).y }
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#x' do
|
31
|
+
subject { described.validate(_name, x, y).x }
|
32
|
+
end
|
33
|
+
|
20
34
|
end # PositionValidator
|
21
35
|
|
22
36
|
end # Vedeu
|
@@ -20,7 +20,9 @@ module Vedeu
|
|
20
20
|
it { instance.must_be_instance_of(Keymap) }
|
21
21
|
it { instance.instance_variable_get('@name').must_equal(map_name) }
|
22
22
|
it { instance.instance_variable_get('@keys').must_be_instance_of(Array) }
|
23
|
-
it
|
23
|
+
it do
|
24
|
+
instance.instance_variable_get('@repository').must_equal(Vedeu.keymaps)
|
25
|
+
end
|
24
26
|
end
|
25
27
|
|
26
28
|
describe '#add' do
|
@@ -18,12 +18,16 @@ module Vedeu
|
|
18
18
|
it { instance.must_be_instance_of(described) }
|
19
19
|
it { instance.instance_variable_get('@key').must_equal(key) }
|
20
20
|
it { instance.instance_variable_get('@name').must_equal(keymap) }
|
21
|
-
it
|
21
|
+
it do
|
22
|
+
instance.instance_variable_get('@repository').must_equal(Vedeu.keymaps)
|
23
|
+
end
|
22
24
|
|
23
25
|
context 'when the repository is provided' do
|
24
26
|
let(:repository) { Vedeu::Repository.new }
|
25
27
|
|
26
|
-
it
|
28
|
+
it do
|
29
|
+
instance.instance_variable_get('@repository').must_equal(repository)
|
30
|
+
end
|
27
31
|
end
|
28
32
|
end
|
29
33
|
|
@@ -41,7 +45,7 @@ module Vedeu
|
|
41
45
|
|
42
46
|
context 'and the key is defined' do
|
43
47
|
let(:key_test) { Key.new('a') { :do_something } }
|
44
|
-
let(:keymap_test) { Keymap.new(
|
48
|
+
let(:keymap_test) { Keymap.new(name: 'test', keys: [key_test]) }
|
45
49
|
|
46
50
|
before do
|
47
51
|
Vedeu.keymaps.reset
|
@@ -71,7 +75,7 @@ module Vedeu
|
|
71
75
|
|
72
76
|
context 'and the key is defined' do
|
73
77
|
let(:key_test) { Key.new('a') { :do_something } }
|
74
|
-
let(:keymap_test) { Keymap.new(
|
78
|
+
let(:keymap_test) { Keymap.new(name: 'test', keys: [key_test]) }
|
75
79
|
|
76
80
|
before do
|
77
81
|
Vedeu.keymaps.reset
|
@@ -8,7 +8,7 @@ module Vedeu
|
|
8
8
|
let(:instance) { described.new }
|
9
9
|
|
10
10
|
before do
|
11
|
-
Configuration.stubs(:configure)
|
11
|
+
Configuration.stubs(:configure)# .returns(test_configuration)
|
12
12
|
Application.stubs(:start)
|
13
13
|
Kernel.stubs(:exit)
|
14
14
|
Kernel.stubs(:puts)
|
@@ -24,17 +24,19 @@ module Vedeu
|
|
24
24
|
let(:y) {}
|
25
25
|
|
26
26
|
describe '#initialize' do
|
27
|
-
|
28
|
-
|
29
|
-
it {
|
30
|
-
it {
|
31
|
-
it {
|
32
|
-
it {
|
33
|
-
it {
|
27
|
+
subject { instance }
|
28
|
+
|
29
|
+
it { subject.must_be_instance_of(described) }
|
30
|
+
it { subject.instance_variable_get('@background').must_equal(background) }
|
31
|
+
it { subject.instance_variable_get('@foreground').must_equal(foreground) }
|
32
|
+
it { subject.instance_variable_get('@style').must_equal(style) }
|
33
|
+
it { subject.instance_variable_get('@value').must_equal(value) }
|
34
|
+
it { subject.instance_variable_get('@x').must_equal(x) }
|
35
|
+
it { subject.instance_variable_get('@y').must_equal(y) }
|
34
36
|
end
|
35
37
|
|
36
38
|
describe '#eql?' do
|
37
|
-
let(:other) { described.new(
|
39
|
+
let(:other) { described.new(background: '#000000') }
|
38
40
|
|
39
41
|
subject { instance.eql?(other) }
|
40
42
|
|