vedeu 0.2.12 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Guardfile +13 -0
- data/README.md +11 -9
- data/Rakefile +10 -1
- data/bin/vedeu_test +14 -0
- data/config/cucumber.yml +8 -0
- data/docs/api.md +45 -16
- data/docs/events.md +21 -9
- data/docs/getting_started.md +16 -0
- data/docs/views.md +158 -0
- data/examples/borders_app.rb +236 -110
- data/examples/colour_support.sh +98 -0
- data/examples/colours_app.rb +41 -0
- data/examples/configuration_app.rb +11 -6
- data/examples/cursor_app.rb +60 -61
- data/examples/focus_app.rb +72 -34
- data/examples/hello_world.rb +13 -8
- data/examples/lines_app.rb +37 -28
- data/features/start_stop.feature +27 -0
- data/features/support/env.rb +14 -0
- data/lib/vedeu/all.rb +29 -0
- data/lib/vedeu/api.rb +39 -0
- data/lib/vedeu/application.rb +15 -7
- data/lib/vedeu/bindings.rb +121 -0
- data/lib/vedeu/buffers/all.rb +10 -0
- data/lib/vedeu/{repositories/models → buffers}/buffer.rb +47 -64
- data/lib/vedeu/buffers/display_buffer.rb +118 -0
- data/lib/vedeu/configuration/all.rb +6 -0
- data/lib/vedeu/configuration/api.rb +3 -1
- data/lib/vedeu/configuration/cli.rb +3 -1
- data/lib/vedeu/configuration/configuration.rb +23 -2
- data/lib/vedeu/cursor/all.rb +23 -0
- data/lib/vedeu/cursor/cursor.rb +116 -0
- data/lib/vedeu/cursor/move_cursor.rb +137 -0
- data/lib/vedeu/cursor/toggle_cursor.rb +53 -0
- data/lib/vedeu/dsl/all.rb +28 -0
- data/lib/vedeu/dsl/components/all.rb +7 -0
- data/lib/vedeu/dsl/components/border.rb +104 -0
- data/lib/vedeu/dsl/components/geometry.rb +153 -0
- data/lib/vedeu/dsl/components/keymap.rb +93 -0
- data/lib/vedeu/dsl/components/menu.rb +82 -0
- data/lib/vedeu/dsl/composition.rb +72 -0
- data/lib/vedeu/dsl/interface.rb +210 -0
- data/lib/vedeu/dsl/line.rb +135 -0
- data/lib/vedeu/dsl/shared/all.rb +7 -0
- data/lib/vedeu/dsl/shared/colour.rb +85 -0
- data/lib/vedeu/dsl/shared/style.rb +38 -0
- data/lib/vedeu/dsl/shared/text.rb +102 -0
- data/lib/vedeu/dsl/shared/use.rb +47 -0
- data/lib/vedeu/dsl/stream.rb +49 -0
- data/lib/vedeu/dsl/view.rb +136 -0
- data/lib/vedeu/events/all.rb +10 -0
- data/lib/vedeu/{repositories/models → events}/event.rb +97 -8
- data/lib/vedeu/events/trigger.rb +58 -0
- data/lib/vedeu/exceptions.rb +34 -0
- data/lib/vedeu/input/all.rb +29 -0
- data/lib/vedeu/input/input.rb +26 -0
- data/lib/vedeu/{models → input}/key.rb +21 -11
- data/lib/vedeu/input/keymap.rb +130 -0
- data/lib/vedeu/input/keys.rb +8 -0
- data/lib/vedeu/input/mapper.rb +112 -0
- data/lib/vedeu/launcher.rb +7 -4
- data/lib/vedeu/models/all.rb +12 -0
- data/lib/vedeu/models/collection.rb +71 -0
- data/lib/vedeu/{repositories → models}/focus.rb +63 -21
- data/lib/vedeu/models/geometry.rb +100 -259
- data/lib/vedeu/{repositories/models → models}/group.rb +16 -14
- data/lib/vedeu/{repositories/models → models}/menu.rb +85 -22
- data/lib/vedeu/models/model.rb +51 -0
- data/lib/vedeu/models/view/all.rb +12 -0
- data/lib/vedeu/models/view/char.rb +84 -0
- data/lib/vedeu/models/view/chars.rb +8 -0
- data/lib/vedeu/models/view/composition.rb +101 -0
- data/lib/vedeu/models/view/interface.rb +215 -0
- data/lib/vedeu/models/view/interfaces.rb +8 -0
- data/lib/vedeu/models/view/line.rb +134 -0
- data/lib/vedeu/models/view/lines.rb +8 -0
- data/lib/vedeu/models/view/stream.rb +144 -0
- data/lib/vedeu/models/view/streams.rb +8 -0
- data/lib/vedeu/output/all.rb +8 -0
- data/lib/vedeu/output/border.rb +387 -0
- data/lib/vedeu/output/compositor.rb +41 -30
- data/lib/vedeu/output/output.rb +6 -13
- data/lib/vedeu/output/viewport.rb +78 -94
- data/lib/vedeu/output/writer.rb +29 -0
- data/lib/vedeu/presentation/all.rb +9 -0
- data/lib/vedeu/{colours → presentation}/background.rb +1 -9
- data/lib/vedeu/{colours → presentation}/colour.rb +21 -8
- data/lib/vedeu/{colours → presentation}/foreground.rb +5 -9
- data/lib/vedeu/presentation/presentation.rb +91 -0
- data/lib/vedeu/presentation/style.rb +47 -0
- data/lib/vedeu/{colours → presentation}/translator.rb +11 -5
- data/lib/vedeu/repositories/all.rb +5 -0
- data/lib/vedeu/repositories/menus.rb +5 -42
- data/lib/vedeu/{support → repositories}/repository.rb +78 -41
- data/lib/vedeu/support/all.rb +22 -0
- data/lib/vedeu/support/bounding_area.rb +2 -1
- data/lib/vedeu/support/coercions.rb +18 -1
- data/lib/vedeu/support/console.rb +73 -0
- data/lib/vedeu/support/content_geometry.rb +69 -0
- data/lib/vedeu/support/coordinate.rb +246 -0
- data/lib/vedeu/support/esc.rb +29 -2
- data/lib/vedeu/support/log.rb +36 -2
- data/lib/vedeu/support/node.rb +61 -0
- data/lib/vedeu/support/position.rb +28 -13
- data/lib/vedeu/support/position_validator.rb +79 -0
- data/lib/vedeu/support/read.rb +65 -0
- data/lib/vedeu/support/refresh.rb +8 -32
- data/lib/vedeu/support/terminal.rb +34 -4
- data/lib/vedeu/support/text.rb +104 -0
- data/lib/vedeu/support/trace.rb +11 -23
- data/lib/vedeu/support/visible.rb +75 -0
- data/lib/vedeu/support/write.rb +85 -0
- data/lib/vedeu/traps.rb +18 -0
- data/lib/vedeu.rb +41 -101
- data/test/integration/dsl/compositions_test.rb +27 -0
- data/test/integration/dsl/interfaces_test.rb +261 -0
- data/test/integration/dsl/keymaps_test.rb +42 -0
- data/test/integration/dsl/lines_test.rb +146 -0
- data/test/integration/dsl/menus_test.rb +59 -0
- data/test/integration/dsl/streams_test.rb +129 -0
- data/test/integration/dsl/views_test.rb +63 -0
- data/test/lib/vedeu/api_test.rb +163 -0
- data/test/lib/vedeu/application_test.rb +19 -10
- data/test/lib/vedeu/bindings_test.rb +54 -0
- data/test/lib/vedeu/buffers/all_test.rb +11 -0
- data/test/lib/vedeu/buffers/buffer_test.rb +196 -0
- data/test/lib/vedeu/buffers/display_buffer_test.rb +58 -0
- data/test/lib/vedeu/configuration/api_test.rb +42 -58
- data/test/lib/vedeu/configuration/cli_test.rb +4 -4
- data/test/lib/vedeu/configuration/configuration_test.rb +11 -29
- data/test/lib/vedeu/cursor/all_test.rb +33 -0
- data/test/lib/vedeu/cursor/cursor_test.rb +85 -0
- data/test/lib/vedeu/cursor/move_cursor_test.rb +212 -0
- data/test/lib/vedeu/cursor/toggle_cursor_test.rb +63 -0
- data/test/lib/vedeu/dsl/components/border_test.rb +414 -0
- data/test/lib/vedeu/dsl/components/geometry_test.rb +231 -0
- data/test/lib/vedeu/dsl/components/keymap_test.rb +80 -0
- data/test/lib/vedeu/dsl/components/menu_test.rb +115 -0
- data/test/lib/vedeu/dsl/composition_test.rb +41 -0
- data/test/lib/vedeu/dsl/interface_test.rb +470 -0
- data/test/lib/vedeu/dsl/line_test.rb +60 -0
- data/test/lib/vedeu/dsl/shared/colour_test.rb +100 -0
- data/test/lib/vedeu/dsl/shared/style_test.rb +22 -0
- data/test/lib/vedeu/dsl/shared/text_test.rb +15 -0
- data/test/lib/vedeu/dsl/shared/use_test.rb +27 -0
- data/test/lib/vedeu/dsl/stream_test.rb +26 -0
- data/test/lib/vedeu/dsl/view_test.rb +73 -0
- data/test/lib/vedeu/events/all_test.rb +11 -0
- data/test/lib/vedeu/events/event_test.rb +109 -0
- data/test/lib/vedeu/events/trigger_test.rb +60 -0
- data/test/lib/vedeu/input/all_test.rb +11 -0
- data/test/lib/vedeu/input/input_test.rb +7 -3
- data/test/lib/vedeu/input/key_test.rb +72 -0
- data/test/lib/vedeu/input/keymap_test.rb +89 -0
- data/test/lib/vedeu/input/mapper_test.rb +94 -0
- data/test/lib/vedeu/launcher_test.rb +19 -20
- data/test/lib/vedeu/models/collection_test.rb +114 -0
- data/test/lib/vedeu/{repositories → models}/focus_test.rb +46 -13
- data/test/lib/vedeu/models/geometry_test.rb +35 -39
- data/test/lib/vedeu/models/group_test.rb +100 -0
- data/test/lib/vedeu/models/menu_test.rb +288 -0
- data/test/lib/vedeu/models/model_test.rb +31 -0
- data/test/lib/vedeu/models/view/char_test.rb +166 -0
- data/test/lib/vedeu/models/view/chars_test.rb +18 -0
- data/test/lib/vedeu/models/view/composition_test.rb +41 -0
- data/test/lib/vedeu/models/view/interface_test.rb +128 -0
- data/test/lib/vedeu/models/view/interfaces_test.rb +18 -0
- data/test/lib/vedeu/models/view/line_test.rb +214 -0
- data/test/lib/vedeu/models/view/lines_test.rb +18 -0
- data/test/lib/vedeu/models/view/stream_test.rb +106 -0
- data/test/lib/vedeu/models/view/streams_test.rb +18 -0
- data/test/lib/vedeu/output/border_test.rb +357 -0
- data/test/lib/vedeu/output/compositor_test.rb +61 -15
- data/test/lib/vedeu/output/output_test.rb +25 -84
- data/test/lib/vedeu/output/viewport_test.rb +171 -45
- data/test/lib/vedeu/output/writer_test.rb +45 -0
- data/test/lib/vedeu/{colours → presentation}/background_test.rb +0 -0
- data/test/lib/vedeu/{colours → presentation}/colour_test.rb +5 -5
- data/test/lib/vedeu/{colours → presentation}/foreground_test.rb +0 -0
- data/test/lib/vedeu/presentation/presentation_test.rb +56 -0
- data/test/lib/vedeu/presentation/style_test.rb +69 -0
- data/test/lib/vedeu/presentation/translator_test.rb +63 -0
- data/test/lib/vedeu/repositories/all_test.rb +7 -0
- data/test/lib/vedeu/repositories/menus_test.rb +3 -156
- data/test/lib/vedeu/repositories/repository_test.rb +271 -0
- data/test/lib/vedeu/support/bounding_area_test.rb +3 -3
- data/test/lib/vedeu/support/coercions_test.rb +39 -0
- data/test/lib/vedeu/support/common_test.rb +31 -16
- data/test/lib/vedeu/support/console_test.rb +85 -0
- data/test/lib/vedeu/support/content_geometry_test.rb +107 -0
- data/test/lib/vedeu/support/coordinate_test.rb +190 -0
- data/test/lib/vedeu/support/esc_test.rb +18 -0
- data/test/lib/vedeu/support/grid_test.rb +15 -10
- data/test/lib/vedeu/support/log_test.rb +3 -0
- data/test/lib/vedeu/support/position_test.rb +22 -2
- data/test/lib/vedeu/support/position_validator_test.rb +11 -0
- data/test/lib/vedeu/support/read_test.rb +88 -0
- data/test/lib/vedeu/support/refresh_test.rb +44 -12
- data/test/lib/vedeu/support/sentence_test.rb +6 -4
- data/test/lib/vedeu/support/terminal_test.rb +81 -70
- data/test/lib/vedeu/support/text_test.rb +93 -0
- data/test/lib/vedeu/support/trace_test.rb +21 -9
- data/test/lib/vedeu/support/visible_test.rb +148 -0
- data/test/lib/vedeu/support/write_test.rb +136 -0
- data/test/lib/vedeu/traps_test.rb +11 -0
- data/test/lib/vedeu_test.rb +2 -0
- data/test/support/helpers/all.rb +7 -0
- data/test/support/helpers/dsl_model_test_class.rb +25 -0
- data/test/support/{test_classes → helpers}/helpers.rb +0 -2
- data/test/support/helpers/misc.rb +15 -0
- data/test/support/helpers/model_test_class.rb +34 -0
- data/test/support/{test_classes → helpers}/presentation.rb +0 -0
- data/test/support/{test_classes → helpers}/repositories.rb +3 -3
- data/test/support/{test_modules/repository.rb → helpers/repository_test_module.rb} +5 -1
- data/test/test_helper.rb +19 -22
- data/vedeu.gemspec +11 -6
- metadata +322 -181
- data/lib/vedeu/api/api.rb +0 -239
- data/lib/vedeu/api/composition.rb +0 -38
- data/lib/vedeu/api/defined.rb +0 -52
- data/lib/vedeu/api/helpers.rb +0 -161
- data/lib/vedeu/api/interface.rb +0 -287
- data/lib/vedeu/api/keymap.rb +0 -75
- data/lib/vedeu/api/line.rb +0 -107
- data/lib/vedeu/api/menu.rb +0 -111
- data/lib/vedeu/api/stream.rb +0 -96
- data/lib/vedeu/models/border.rb +0 -238
- data/lib/vedeu/models/char.rb +0 -43
- data/lib/vedeu/models/composition.rb +0 -72
- data/lib/vedeu/models/line.rb +0 -100
- data/lib/vedeu/models/stream.rb +0 -130
- data/lib/vedeu/models/style.rb +0 -52
- data/lib/vedeu/repositories/buffers.rb +0 -52
- data/lib/vedeu/repositories/cursors.rb +0 -64
- data/lib/vedeu/repositories/events.rb +0 -147
- data/lib/vedeu/repositories/groups.rb +0 -47
- data/lib/vedeu/repositories/interfaces.rb +0 -78
- data/lib/vedeu/repositories/keymaps.rb +0 -196
- data/lib/vedeu/repositories/models/cursor.rb +0 -209
- data/lib/vedeu/repositories/models/interface.rb +0 -163
- data/lib/vedeu/repositories/models/keymap.rb +0 -111
- data/lib/vedeu/repositories/models/offset.rb +0 -91
- data/lib/vedeu/repositories/offsets.rb +0 -69
- data/lib/vedeu/support/exceptions.rb +0 -34
- data/lib/vedeu/support/keymap_validator.rb +0 -100
- data/lib/vedeu/support/model.rb +0 -14
- data/lib/vedeu/support/presentation.rb +0 -86
- data/lib/vedeu/support/registrar.rb +0 -53
- data/test/integration/api/api_test.rb +0 -97
- data/test/integration/api_dsl/dsl_api_test.rb +0 -4
- data/test/integration/api_dsl/dsl_composition_test.rb +0 -4
- data/test/integration/api_dsl/dsl_defined_test.rb +0 -4
- data/test/integration/api_dsl/dsl_helpers_test.rb +0 -4
- data/test/integration/api_dsl/dsl_interface_test.rb +0 -4
- data/test/integration/api_dsl/dsl_keymap.rb +0 -4
- data/test/integration/api_dsl/dsl_line_test.rb +0 -4
- data/test/integration/api_dsl/dsl_menu_test.rb +0 -4
- data/test/integration/api_dsl/dsl_stream_test.rb +0 -138
- data/test/integration/cursors_test.rb +0 -9
- data/test/integration/defining_interfaces_test.rb +0 -26
- data/test/integration/run_once_test.rb +0 -26
- data/test/integration/views/basic_view_test.rb +0 -807
- data/test/lib/vedeu/api/api_test.rb +0 -204
- data/test/lib/vedeu/api/composition_test.rb +0 -31
- data/test/lib/vedeu/api/defined_test.rb +0 -79
- data/test/lib/vedeu/api/helpers_test.rb +0 -111
- data/test/lib/vedeu/api/interface_test.rb +0 -410
- data/test/lib/vedeu/api/keymap_test.rb +0 -65
- data/test/lib/vedeu/api/line_test.rb +0 -83
- data/test/lib/vedeu/api/menu_test.rb +0 -85
- data/test/lib/vedeu/api/stream_test.rb +0 -59
- data/test/lib/vedeu/colours/translator_test.rb +0 -22
- data/test/lib/vedeu/models/border_test.rb +0 -197
- data/test/lib/vedeu/models/char_test.rb +0 -52
- data/test/lib/vedeu/models/composition_test.rb +0 -45
- data/test/lib/vedeu/models/key_test.rb +0 -43
- data/test/lib/vedeu/models/line_test.rb +0 -123
- data/test/lib/vedeu/models/stream_test.rb +0 -233
- data/test/lib/vedeu/models/style_test.rb +0 -59
- data/test/lib/vedeu/repositories/buffers_test.rb +0 -37
- data/test/lib/vedeu/repositories/cursors_test.rb +0 -62
- data/test/lib/vedeu/repositories/events_test.rb +0 -57
- data/test/lib/vedeu/repositories/groups_test.rb +0 -28
- data/test/lib/vedeu/repositories/interfaces_test.rb +0 -51
- data/test/lib/vedeu/repositories/keymaps_test.rb +0 -223
- data/test/lib/vedeu/repositories/models/buffer_test.rb +0 -174
- data/test/lib/vedeu/repositories/models/cursor_test.rb +0 -158
- data/test/lib/vedeu/repositories/models/event_test.rb +0 -53
- data/test/lib/vedeu/repositories/models/group_test.rb +0 -98
- data/test/lib/vedeu/repositories/models/interface_test.rb +0 -130
- data/test/lib/vedeu/repositories/models/keymap_test.rb +0 -27
- data/test/lib/vedeu/repositories/models/menu_test.rb +0 -246
- data/test/lib/vedeu/repositories/models/offset_test.rb +0 -128
- data/test/lib/vedeu/repositories/offsets_test.rb +0 -39
- data/test/lib/vedeu/support/keymap_validator_test.rb +0 -62
- data/test/lib/vedeu/support/model_test.rb +0 -23
- data/test/lib/vedeu/support/presentation_test.rb +0 -53
- data/test/lib/vedeu/support/registrar_test.rb +0 -94
- data/test/lib/vedeu/support/repository_test.rb +0 -208
- data/test/support/test_classes/all.rb +0 -5
- data/test/support/test_classes/coercions.rb +0 -16
- data/test/support/test_classes/model.rb +0 -23
- data/test/support/test_modules/all.rb +0 -1
@@ -1,130 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
|
5
|
-
describe Interface do
|
6
|
-
let(:described) { Interface.new(attributes) }
|
7
|
-
let(:attributes) { {} }
|
8
|
-
|
9
|
-
let(:interface) { Vedeu.use('#initialize') }
|
10
|
-
|
11
|
-
before do
|
12
|
-
Interfaces.reset
|
13
|
-
Vedeu.interface('#initialize') do
|
14
|
-
group 'my_group'
|
15
|
-
colour foreground: '#ff0000', background: '#000000'
|
16
|
-
y 3
|
17
|
-
x 5
|
18
|
-
width 10
|
19
|
-
height 15
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe '#initialize' do
|
24
|
-
it { return_type_for(described, Interface) }
|
25
|
-
it { assigns(described, '@attributes', {
|
26
|
-
border: {},
|
27
|
-
colour: {},
|
28
|
-
cursor: :hide,
|
29
|
-
delay: 0.0,
|
30
|
-
geometry: {},
|
31
|
-
group: '',
|
32
|
-
lines: [],
|
33
|
-
name: '',
|
34
|
-
parent: nil,
|
35
|
-
style: ''
|
36
|
-
})
|
37
|
-
}
|
38
|
-
it { assigns(described, '@cursor', :hide) }
|
39
|
-
it { assigns(described, '@delay', 0.0) }
|
40
|
-
it { assigns(described, '@group', '') }
|
41
|
-
it { assigns(described, '@name', '') }
|
42
|
-
it { assigns(described, '@parent', nil) }
|
43
|
-
end
|
44
|
-
|
45
|
-
describe '#attributes' do
|
46
|
-
it 'returns the value' do
|
47
|
-
interface.attributes.must_equal(
|
48
|
-
{
|
49
|
-
border: {},
|
50
|
-
colour: {
|
51
|
-
foreground: '#ff0000',
|
52
|
-
background: '#000000'
|
53
|
-
},
|
54
|
-
cursor: :hide,
|
55
|
-
delay: 0.0,
|
56
|
-
geometry: {
|
57
|
-
y: 3,
|
58
|
-
x: 5,
|
59
|
-
width: 10,
|
60
|
-
height: 15,
|
61
|
-
},
|
62
|
-
group: 'my_group',
|
63
|
-
lines: [],
|
64
|
-
name: '#initialize',
|
65
|
-
parent: nil,
|
66
|
-
style: '',
|
67
|
-
}
|
68
|
-
)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe '#border' do
|
73
|
-
it { return_type_for(described.border, Border) }
|
74
|
-
end
|
75
|
-
|
76
|
-
describe '#cursor' do
|
77
|
-
it { return_type_for(described.cursor, Cursor) }
|
78
|
-
end
|
79
|
-
|
80
|
-
describe '#name' do
|
81
|
-
it 'returns the value' do
|
82
|
-
interface.name.must_equal('#initialize')
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
describe '#in_focus?' do
|
87
|
-
context 'when the interface is currently in focus' do
|
88
|
-
before { Focus.stubs(:current?).returns(true) }
|
89
|
-
|
90
|
-
it { interface.in_focus?.must_equal(true) }
|
91
|
-
end
|
92
|
-
|
93
|
-
context 'when the interface is not currently in focus' do
|
94
|
-
before { Focus.stubs(:current?).returns(false) }
|
95
|
-
|
96
|
-
it { interface.in_focus?.must_equal(false) }
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe '#group' do
|
101
|
-
it 'returns the value' do
|
102
|
-
interface.group.must_equal('my_group')
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
describe '#lines' do
|
107
|
-
it 'returns the value' do
|
108
|
-
interface.lines.must_equal([])
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
describe '#geometry' do
|
113
|
-
it { return_type_for(described.geometry, Geometry) }
|
114
|
-
end
|
115
|
-
|
116
|
-
describe '#delay' do
|
117
|
-
it 'returns the value' do
|
118
|
-
interface.delay.must_equal(0.0)
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
describe '#method_missing' do
|
123
|
-
it 'returns nil' do
|
124
|
-
interface.some_missing_method(:test).must_equal(nil)
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
end # Interface
|
129
|
-
|
130
|
-
end # Vedeu
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
|
5
|
-
describe Keymap do
|
6
|
-
|
7
|
-
let(:described) { Keymap.new(attributes) }
|
8
|
-
let(:attributes) { {} }
|
9
|
-
|
10
|
-
describe '.define' do
|
11
|
-
it { return_type_for(Keymap.define, Keymap) }
|
12
|
-
end
|
13
|
-
|
14
|
-
describe '#initialize' do
|
15
|
-
it { return_type_for(described, Keymap) }
|
16
|
-
it { assigns(described, '@attributes', { interfaces: [], keys: [] }) }
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '#method_missing' do
|
20
|
-
it 'returns nil' do
|
21
|
-
Keymap.new.some_missing_method(:test).must_equal(nil)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
end # Keymap
|
26
|
-
|
27
|
-
end # Vedeu
|
@@ -1,246 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
|
5
|
-
describe Menu do
|
6
|
-
|
7
|
-
let(:described) { Menu.new(collection) }
|
8
|
-
let(:collection) { ['hydrogen', 'carbon', 'nitrogen', 'oxygen'] }
|
9
|
-
let(:menu) { Menu.new(collection) }
|
10
|
-
|
11
|
-
describe '#initialize' do
|
12
|
-
it { return_type_for(described, Menu) }
|
13
|
-
it { assigns(described, '@collection', collection) }
|
14
|
-
it { assigns(described, '@name', '') }
|
15
|
-
it { assigns(described, '@current', 0) }
|
16
|
-
it { assigns(described, '@selected', nil) }
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '#current' do
|
20
|
-
it 'returns the current index' do
|
21
|
-
menu.current.must_equal(0)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe '#selected' do
|
26
|
-
it 'returns nil when no item is selected' do
|
27
|
-
menu.selected.must_equal(nil)
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'returns the selected index when an item is selected' do
|
31
|
-
menu.next_item
|
32
|
-
menu.select_item
|
33
|
-
menu.selected.must_equal(1)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe '#current_item' do
|
38
|
-
it 'returns the current item from the collection' do
|
39
|
-
menu.current_item.must_equal('hydrogen')
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'when the current item has changed' do
|
43
|
-
menu.next_item
|
44
|
-
menu.next_item
|
45
|
-
menu.current_item.must_equal('nitrogen')
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe '#selected_item' do
|
50
|
-
it 'returns nil when nothing is selected' do
|
51
|
-
menu.selected_item.must_equal(nil)
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'returns the selected item from the collection' do
|
55
|
-
menu.next_item
|
56
|
-
menu.select_item
|
57
|
-
menu.selected_item.must_equal('carbon')
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe '#items' do
|
62
|
-
it 'returns a collection of items' do
|
63
|
-
menu.items.must_equal(
|
64
|
-
[
|
65
|
-
[false, true, 'hydrogen'],
|
66
|
-
[false, false, 'carbon'],
|
67
|
-
[false, false, 'nitrogen'],
|
68
|
-
[false, false, 'oxygen']
|
69
|
-
]
|
70
|
-
)
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'returns a collection of items when the current has ' \
|
74
|
-
'changed' do
|
75
|
-
menu.next_item
|
76
|
-
menu.items.must_equal(
|
77
|
-
[
|
78
|
-
[false, false, 'hydrogen'],
|
79
|
-
[false, true, 'carbon'],
|
80
|
-
[false, false, 'nitrogen'],
|
81
|
-
[false, false, 'oxygen']
|
82
|
-
]
|
83
|
-
)
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'returns a collection of items when an item is selected' do
|
87
|
-
menu.next_item
|
88
|
-
menu.select_item
|
89
|
-
menu.items.must_equal(
|
90
|
-
[
|
91
|
-
[false, false, 'hydrogen'],
|
92
|
-
[true, true, 'carbon'],
|
93
|
-
[false, false, 'nitrogen'],
|
94
|
-
[false, false, 'oxygen']
|
95
|
-
]
|
96
|
-
)
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'returns a collection of items when the current has ' \
|
100
|
-
'changed and an item is selected' do
|
101
|
-
menu.next_item
|
102
|
-
menu.select_item
|
103
|
-
menu.next_item
|
104
|
-
menu.next_item
|
105
|
-
menu.items.must_equal(
|
106
|
-
[
|
107
|
-
[false, false, 'hydrogen'],
|
108
|
-
[true, false, 'carbon'],
|
109
|
-
[false, false, 'nitrogen'],
|
110
|
-
[false, true, 'oxygen']
|
111
|
-
]
|
112
|
-
)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
describe '#view' do
|
117
|
-
it 'returns a collection of items when the start position ' \
|
118
|
-
'has changed' do
|
119
|
-
menu.top_item
|
120
|
-
menu.next_item
|
121
|
-
menu.view.must_equal(
|
122
|
-
[
|
123
|
-
[false, true, 'carbon'],
|
124
|
-
[false, false, 'nitrogen'],
|
125
|
-
[false, false, 'oxygen']
|
126
|
-
]
|
127
|
-
)
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
describe '#top_item' do
|
132
|
-
it 'sets current to the index of the first item' do
|
133
|
-
menu.next_item
|
134
|
-
menu.top_item
|
135
|
-
menu.current.must_equal(0)
|
136
|
-
end
|
137
|
-
|
138
|
-
it 'returns the items' do
|
139
|
-
menu.top_item.must_equal(menu.items)
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
describe '#bottom_item' do
|
144
|
-
it 'sets current to the index of the last item' do
|
145
|
-
menu.bottom_item
|
146
|
-
menu.current.must_equal(3)
|
147
|
-
end
|
148
|
-
|
149
|
-
it 'returns the items' do
|
150
|
-
menu.bottom_item.must_equal(menu.items)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
describe '#next_item' do
|
155
|
-
it 'sets the current to the index of the next item' do
|
156
|
-
menu.next_item
|
157
|
-
menu.current.must_equal(1)
|
158
|
-
end
|
159
|
-
|
160
|
-
it 'returns the items' do
|
161
|
-
menu.next_item.must_equal(menu.items)
|
162
|
-
end
|
163
|
-
|
164
|
-
it 'does not loop' do
|
165
|
-
menu.next_item
|
166
|
-
menu.next_item
|
167
|
-
menu.next_item
|
168
|
-
menu.next_item
|
169
|
-
menu.next_item
|
170
|
-
menu.current.must_equal(3)
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
describe '#prev_item' do
|
175
|
-
it 'does not loop' do
|
176
|
-
menu.prev_item
|
177
|
-
menu.current.must_equal(0)
|
178
|
-
end
|
179
|
-
|
180
|
-
it 'sets the current to the index of the previous item' do
|
181
|
-
menu.next_item
|
182
|
-
menu.next_item
|
183
|
-
menu.prev_item
|
184
|
-
menu.current.must_equal(1)
|
185
|
-
end
|
186
|
-
|
187
|
-
it 'returns the items' do
|
188
|
-
menu.prev_item.must_equal(menu.items)
|
189
|
-
end
|
190
|
-
|
191
|
-
it 'does not loop' do
|
192
|
-
menu.next_item
|
193
|
-
menu.next_item
|
194
|
-
menu.next_item
|
195
|
-
menu.prev_item
|
196
|
-
menu.prev_item
|
197
|
-
menu.current.must_equal(1)
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
describe '#select_item' do
|
202
|
-
it 'sets the selected index to the current index' do
|
203
|
-
menu.select_item
|
204
|
-
menu.selected.must_equal(0)
|
205
|
-
end
|
206
|
-
|
207
|
-
it 'sets the selected index to the current index' do
|
208
|
-
menu.next_item
|
209
|
-
menu.select_item
|
210
|
-
menu.selected.must_equal(1)
|
211
|
-
end
|
212
|
-
|
213
|
-
it 'returns the items' do
|
214
|
-
menu.select_item.must_equal(menu.items)
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
describe '#deselect_item' do
|
219
|
-
it 'sets the selected index to nil' do
|
220
|
-
menu.next_item
|
221
|
-
menu.next_item
|
222
|
-
menu.select_item
|
223
|
-
menu.deselect_item
|
224
|
-
menu.selected.must_equal(nil)
|
225
|
-
end
|
226
|
-
|
227
|
-
it 'returns the items' do
|
228
|
-
menu.deselect_item.must_equal(menu.items)
|
229
|
-
end
|
230
|
-
end
|
231
|
-
|
232
|
-
describe '#last' do
|
233
|
-
it 'returns the index of the last item' do
|
234
|
-
menu.last.must_equal(3)
|
235
|
-
end
|
236
|
-
end
|
237
|
-
|
238
|
-
describe '#size' do
|
239
|
-
it 'returns the collection size' do
|
240
|
-
menu.size.must_equal(4)
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
end # Menu
|
245
|
-
|
246
|
-
end # Vedeu
|
@@ -1,128 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
|
5
|
-
describe Offset do
|
6
|
-
let(:described) { Offset.new(attributes) }
|
7
|
-
let(:offset) { Offset.new(attributes) }
|
8
|
-
let(:attributes) { {} }
|
9
|
-
|
10
|
-
before { Offsets.reset }
|
11
|
-
|
12
|
-
describe '#initialize' do
|
13
|
-
it { return_type_for(described, Offset) }
|
14
|
-
it { assigns(described, '@attributes', { name: '', x: 0, y: 0 }) }
|
15
|
-
it { assigns(described, '@name', '') }
|
16
|
-
it { assigns(described, '@y', 0) }
|
17
|
-
it { assigns(described, '@x', 0) }
|
18
|
-
end
|
19
|
-
|
20
|
-
describe '#attributes' do
|
21
|
-
let(:attributes) { { name: 'roentgenium', y: 5, x: 12 } }
|
22
|
-
|
23
|
-
it 'returns the attributes' do
|
24
|
-
offset.attributes.must_equal(attributes)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#move' do
|
29
|
-
let(:attributes) { { name: 'roentgenium' } }
|
30
|
-
|
31
|
-
context 'left' do
|
32
|
-
it 'does not move past the leftmost position' do
|
33
|
-
offset.move(0, -1).x.must_equal(0)
|
34
|
-
end
|
35
|
-
|
36
|
-
context 'when it can move left' do
|
37
|
-
let(:attributes) { { name: 'roentgenium', x: 5 } }
|
38
|
-
|
39
|
-
it 'moves left' do
|
40
|
-
offset.move(0, -1).x.must_equal(4)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
context 'right' do
|
46
|
-
it 'moves right' do
|
47
|
-
offset.move(0, 1).x.must_equal(1)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context 'up' do
|
52
|
-
it 'does not move past the upmost position' do
|
53
|
-
offset.move(-1, 0).y.must_equal(0)
|
54
|
-
end
|
55
|
-
|
56
|
-
context 'when it can move up' do
|
57
|
-
let(:attributes) { { name: 'roentgenium', y: 5 } }
|
58
|
-
|
59
|
-
it 'moves up' do
|
60
|
-
offset.move(-1, 0).y.must_equal(4)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
context 'down' do
|
66
|
-
it 'moves down' do
|
67
|
-
offset.move(1, 0).y.must_equal(1)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe '#name' do
|
73
|
-
it 'has a default value of empty string' do
|
74
|
-
offset.name.must_equal('')
|
75
|
-
end
|
76
|
-
|
77
|
-
context 'when a value is set' do
|
78
|
-
let(:attributes) { { name: 'roentgenium' } }
|
79
|
-
|
80
|
-
it 'returns that value' do
|
81
|
-
offset.name.must_equal('roentgenium')
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
describe '#y' do
|
87
|
-
it 'has a default value of 0' do
|
88
|
-
offset.y.must_equal(0)
|
89
|
-
end
|
90
|
-
|
91
|
-
context 'when a value is set' do
|
92
|
-
let(:attributes) { { y: 3 } }
|
93
|
-
|
94
|
-
it 'returns that value' do
|
95
|
-
offset.y.must_equal(3)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
context 'when a value is set that is < 0' do
|
100
|
-
let(:attributes) { { y: -2 } }
|
101
|
-
|
102
|
-
it { offset.y.must_equal(0) }
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
describe '#x' do
|
107
|
-
it 'has a default value of 0' do
|
108
|
-
offset.x.must_equal(0)
|
109
|
-
end
|
110
|
-
|
111
|
-
context 'when a value is set' do
|
112
|
-
let(:attributes) { { x: 2 } }
|
113
|
-
|
114
|
-
it 'returns that value' do
|
115
|
-
offset.x.must_equal(2)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
context 'when a value is set that is < 0' do
|
120
|
-
let(:attributes) { { x: -2 } }
|
121
|
-
|
122
|
-
it { offset.x.must_equal(0) }
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
end # Offset
|
127
|
-
|
128
|
-
end # Vedeu
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
|
5
|
-
describe Offsets do
|
6
|
-
|
7
|
-
before do
|
8
|
-
Interfaces.reset
|
9
|
-
Registrar.record({ name: 'thorium' })
|
10
|
-
Terminal.console.stubs(:print)
|
11
|
-
end
|
12
|
-
|
13
|
-
context 'when no interfaces are defined' do
|
14
|
-
before { Interfaces.reset }
|
15
|
-
|
16
|
-
it { proc { Offsets.down }.must_raise(NoInterfacesDefined) }
|
17
|
-
|
18
|
-
it { proc { Offsets.up }.must_raise(NoInterfacesDefined) }
|
19
|
-
|
20
|
-
it { proc { Offsets.right }.must_raise(NoInterfacesDefined) }
|
21
|
-
|
22
|
-
it { proc { Offsets.left }.must_raise(NoInterfacesDefined) }
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'when there is at least one interface defined' do
|
26
|
-
before { Focus.stubs(:current).returns('thorium') }
|
27
|
-
|
28
|
-
it { Offsets.down.must_be_instance_of(Array) }
|
29
|
-
|
30
|
-
it { Offsets.up.must_be_instance_of(Array) }
|
31
|
-
|
32
|
-
it { Offsets.right.must_be_instance_of(Array) }
|
33
|
-
|
34
|
-
it { Offsets.left.must_be_instance_of(Array) }
|
35
|
-
end
|
36
|
-
|
37
|
-
end # Offsets
|
38
|
-
|
39
|
-
end # Vedeu
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
|
5
|
-
describe KeymapValidator do
|
6
|
-
|
7
|
-
let(:described) { KeymapValidator.new(storage, key, interface) }
|
8
|
-
let(:storage) {
|
9
|
-
{
|
10
|
-
'dubnium' => {
|
11
|
-
'a' => proc { :do_something }
|
12
|
-
},
|
13
|
-
'_global_keymap_' => {
|
14
|
-
'g' => proc { :do_something }
|
15
|
-
}
|
16
|
-
}
|
17
|
-
}
|
18
|
-
let(:key) { 'a' }
|
19
|
-
let(:interface) { 'dubnium' }
|
20
|
-
|
21
|
-
describe '.check' do
|
22
|
-
it 'raises an exception when already in use as a system key' do
|
23
|
-
proc {
|
24
|
-
KeymapValidator.check(storage, :shift_tab, interface)
|
25
|
-
}.must_raise(KeyInUse)
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'raises an exception when already in use as a global key' do
|
29
|
-
proc {
|
30
|
-
KeymapValidator.check(storage, 'g', interface)
|
31
|
-
}.must_raise(KeyInUse)
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'raises an exception when already in use by the interface' do
|
35
|
-
proc {
|
36
|
-
KeymapValidator.check(storage, 'a', interface)
|
37
|
-
}.must_raise(KeyInUse)
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'raises an exception when already in use' do
|
41
|
-
proc { KeymapValidator.check(storage, 'a', '') }.must_raise(KeyInUse)
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'returns true when valid as a global key' do
|
45
|
-
KeymapValidator.check(storage, 'h', '').must_equal(true)
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'returns true when valid as an interface key' do
|
49
|
-
KeymapValidator.check(storage, 'b', 'dubnium').must_equal(true)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe '#initialize' do
|
54
|
-
it { return_type_for(described, KeymapValidator) }
|
55
|
-
it { assigns(described, '@storage', storage) }
|
56
|
-
it { assigns(described, '@key', key) }
|
57
|
-
it { assigns(described, '@interface', interface) }
|
58
|
-
end
|
59
|
-
|
60
|
-
end # KeymapValidator
|
61
|
-
|
62
|
-
end # Vedeu
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
|
5
|
-
describe Model do
|
6
|
-
|
7
|
-
describe '#store' do
|
8
|
-
let(:attributes) {
|
9
|
-
{
|
10
|
-
name: 'hydrogen'
|
11
|
-
}
|
12
|
-
}
|
13
|
-
|
14
|
-
subject { ModelTestClass.new(attributes).store }
|
15
|
-
|
16
|
-
it 'returns the model' do
|
17
|
-
subject.must_be_instance_of(ModelTestClass)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
end # Model
|
22
|
-
|
23
|
-
end # Vedeu
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
|
5
|
-
describe Presentation do
|
6
|
-
|
7
|
-
let(:receiver) { PresentationTestClass.new }
|
8
|
-
|
9
|
-
describe '#colour' do
|
10
|
-
it 'returns a Colour instance' do
|
11
|
-
receiver.colour.must_be_instance_of(Colour)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe '#style' do
|
16
|
-
it 'returns a Style instance' do
|
17
|
-
receiver.style.must_be_instance_of(Style)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe '#to_s' do
|
22
|
-
it 'returns output' do
|
23
|
-
line = Line.new({
|
24
|
-
colour: {
|
25
|
-
foreground: '#00ff00',
|
26
|
-
background: '#000000'
|
27
|
-
},
|
28
|
-
style: 'normal'
|
29
|
-
})
|
30
|
-
stream = Stream.new({
|
31
|
-
colour: {
|
32
|
-
foreground: '#ff0000',
|
33
|
-
background: '#000000'
|
34
|
-
},
|
35
|
-
text: 'Some text',
|
36
|
-
style: 'underline',
|
37
|
-
width: nil,
|
38
|
-
align: :left,
|
39
|
-
parent: line.view_attributes,
|
40
|
-
})
|
41
|
-
stream.to_s.must_equal(
|
42
|
-
"\e[38;2;255;0;0m\e[48;2;0;0;0m" \
|
43
|
-
"\e[4m" \
|
44
|
-
"Some text" \
|
45
|
-
"\e[24m\e[22m\e[27m" \
|
46
|
-
"\e[38;2;0;255;0m\e[48;2;0;0;0m"
|
47
|
-
)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
end # Presentation
|
52
|
-
|
53
|
-
end # Vedeu
|