vedeu 0.6.8 → 0.6.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +9 -0
- data/README.md +1 -1
- data/docs/api.md +60 -67
- data/docs/configuration.md +8 -5
- data/docs/events.md +31 -15
- data/docs/events/application.md +12 -0
- data/docs/events/document.md +57 -0
- data/docs/events/drb.md +43 -0
- data/docs/events/focus.md +24 -0
- data/docs/events/menu.md +57 -0
- data/docs/events/movement.md +57 -0
- data/docs/events/refresh.md +25 -0
- data/docs/events/system.md +90 -0
- data/docs/events/visibility.md +68 -0
- data/lib/vedeu.rb +2 -2
- data/lib/vedeu/all.rb +3 -2
- data/lib/vedeu/api.rb +18 -18
- data/lib/vedeu/application/controller.rb +1 -1
- data/lib/vedeu/application/helper.rb +1 -1
- data/lib/vedeu/application/view.rb +1 -1
- data/lib/vedeu/bindings/application.rb +1 -12
- data/lib/vedeu/bindings/bindings.rb +3 -1
- data/lib/vedeu/bindings/document.rb +9 -62
- data/lib/vedeu/bindings/drb.rb +12 -56
- data/lib/vedeu/bindings/focus.rb +3 -28
- data/lib/vedeu/bindings/menus.rb +10 -66
- data/lib/vedeu/bindings/movement.rb +4 -69
- data/lib/vedeu/bindings/refresh.rb +3 -33
- data/lib/vedeu/bindings/system.rb +14 -100
- data/lib/vedeu/bindings/visibility.rb +20 -71
- data/lib/vedeu/borders/all.rb +4 -3
- data/lib/vedeu/borders/border.rb +39 -33
- data/lib/vedeu/borders/dsl.rb +40 -33
- data/lib/vedeu/borders/null.rb +2 -2
- data/lib/vedeu/borders/render.rb +29 -24
- data/lib/vedeu/borders/repository.rb +2 -2
- data/lib/vedeu/buffers/all.rb +8 -7
- data/lib/vedeu/buffers/buffer.rb +47 -39
- data/lib/vedeu/buffers/null.rb +2 -2
- data/lib/vedeu/buffers/refresh.rb +4 -3
- data/lib/vedeu/buffers/virtual_buffer.rb +122 -118
- data/lib/vedeu/buffers/virtual_buffers.rb +62 -56
- data/lib/vedeu/colours/background.rb +2 -1
- data/lib/vedeu/colours/colour.rb +21 -19
- data/lib/vedeu/colours/foreground.rb +2 -1
- data/lib/vedeu/colours/repository.rb +6 -5
- data/lib/vedeu/colours/translator.rb +39 -35
- data/lib/vedeu/configuration/api.rb +59 -51
- data/lib/vedeu/configuration/cli.rb +9 -7
- data/lib/vedeu/configuration/configuration.rb +41 -32
- data/lib/vedeu/cursors/cursor.rb +1 -1
- data/lib/vedeu/cursors/refresh.rb +20 -16
- data/lib/vedeu/distributed/server.rb +8 -6
- data/lib/vedeu/distributed/subprocess.rb +90 -86
- data/lib/vedeu/distributed/uri.rb +4 -3
- data/lib/vedeu/dsl/composition.rb +2 -2
- data/lib/vedeu/dsl/group.rb +4 -4
- data/lib/vedeu/dsl/interface.rb +5 -5
- data/lib/vedeu/dsl/presentation.rb +2 -2
- data/lib/vedeu/dsl/text.rb +1 -1
- data/lib/vedeu/editor/cropper.rb +4 -4
- data/lib/vedeu/editor/cursor.rb +6 -4
- data/lib/vedeu/editor/document.rb +20 -18
- data/lib/vedeu/editor/editor.rb +2 -2
- data/lib/vedeu/editor/line.rb +10 -5
- data/lib/vedeu/editor/lines.rb +2 -2
- data/lib/vedeu/internal_api.rb +4 -4
- data/lib/vedeu/models/focus.rb +197 -191
- data/lib/vedeu/models/group.rb +171 -159
- data/lib/vedeu/models/groups.rb +14 -10
- data/lib/vedeu/models/interface.rb +116 -110
- data/lib/vedeu/models/interfaces.rb +24 -20
- data/lib/vedeu/models/toggleable.rb +4 -4
- data/lib/vedeu/models/views/char.rb +1 -1
- data/lib/vedeu/models/views/composition.rb +1 -1
- data/lib/vedeu/models/views/line.rb +1 -1
- data/lib/vedeu/models/views/stream.rb +1 -1
- data/lib/vedeu/models/views/view.rb +1 -1
- data/lib/vedeu/null/interface.rb +1 -1
- data/lib/vedeu/null/view.rb +1 -1
- data/lib/vedeu/output/clear/named_interface.rb +1 -1
- data/lib/vedeu/output/compressor.rb +78 -73
- data/lib/vedeu/output/direct.rb +61 -57
- data/lib/vedeu/output/output.rb +34 -29
- data/lib/vedeu/output/{presentation.rb → presentation/presentation.rb} +2 -1
- data/lib/vedeu/output/presentation/style.rb +64 -18
- data/lib/vedeu/output/presentation/styles.rb +39 -0
- data/lib/vedeu/output/renderers/html.rb +2 -2
- data/lib/vedeu/output/renderers/json.rb +2 -1
- data/lib/vedeu/output/renderers/terminal.rb +3 -3
- data/lib/vedeu/output/renderers/text.rb +3 -3
- data/lib/vedeu/output/text.rb +186 -180
- data/lib/vedeu/output/wordwrap.rb +142 -138
- data/lib/vedeu/refresh/refresh.rb +2 -2
- data/lib/vedeu/templating/helpers.rb +11 -6
- data/lib/vedeu/templating/view_template.rb +1 -1
- data/lib/vedeu/terminal/terminal.rb +2 -2
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/borders/render_test.rb +1 -1
- data/test/lib/vedeu/buffers/buffer_test.rb +16 -14
- data/test/lib/vedeu/buffers/virtual_buffer_test.rb +105 -101
- data/test/lib/vedeu/buffers/virtual_buffers_test.rb +43 -39
- data/test/lib/vedeu/colours/colour_test.rb +4 -4
- data/test/lib/vedeu/cursors/cursor_test.rb +2 -2
- data/test/lib/vedeu/cursors/repository_test.rb +3 -3
- data/test/lib/vedeu/distributed/subprocess_test.rb +33 -29
- data/test/lib/vedeu/dsl/group_test.rb +3 -3
- data/test/lib/vedeu/dsl/interface_test.rb +6 -5
- data/test/lib/vedeu/dsl/line_test.rb +4 -2
- data/test/lib/vedeu/dsl/presentation_test.rb +2 -2
- data/test/lib/vedeu/dsl/text_test.rb +8 -8
- data/test/lib/vedeu/editor/document_test.rb +10 -6
- data/test/lib/vedeu/input/keymap_test.rb +1 -10
- data/test/lib/vedeu/models/focus_test.rb +177 -170
- data/test/lib/vedeu/models/group_test.rb +99 -95
- data/test/lib/vedeu/models/groups_test.rb +13 -9
- data/test/lib/vedeu/models/interface_test.rb +93 -87
- data/test/lib/vedeu/models/interfaces_test.rb +24 -20
- data/test/lib/vedeu/models/views/char_test.rb +2 -2
- data/test/lib/vedeu/models/views/line_test.rb +11 -7
- data/test/lib/vedeu/models/views/stream_test.rb +1 -1
- data/test/lib/vedeu/models/views/view_test.rb +1 -1
- data/test/lib/vedeu/output/clear/named_group_test.rb +1 -1
- data/test/lib/vedeu/output/clear/named_interface_test.rb +3 -1
- data/test/lib/vedeu/output/compressor_test.rb +126 -122
- data/test/lib/vedeu/output/direct_test.rb +49 -43
- data/test/lib/vedeu/output/output_test.rb +35 -31
- data/test/lib/vedeu/output/{presentation_test.rb → presentation/presentation_test.rb} +11 -7
- data/test/lib/vedeu/output/presentation/style_test.rb +88 -48
- data/test/lib/vedeu/output/presentation/styles_test.rb +84 -0
- data/test/lib/vedeu/output/text_test.rb +109 -105
- data/test/lib/vedeu/output/viewport_test.rb +3 -1
- data/test/lib/vedeu/output/wordwrap_test.rb +209 -205
- data/test/lib/vedeu/refresh/refresh_test.rb +3 -1
- data/test/lib/vedeu/templating/helpers_test.rb +6 -6
- data/test/lib/vedeu/templating/view_template_test.rb +1 -1
- metadata +17 -8
- data/lib/vedeu/output/style.rb +0 -76
- data/test/lib/vedeu/output/style_test.rb +0 -120
@@ -8,7 +8,7 @@ module Vedeu
|
|
8
8
|
|
9
9
|
let(:described) { Vedeu::DSL::Group }
|
10
10
|
let(:instance) { described.new(model, client) }
|
11
|
-
let(:model) { Vedeu::Group.new }
|
11
|
+
let(:model) { Vedeu::Models::Group.new }
|
12
12
|
let(:client) {}
|
13
13
|
let(:group_name) { 'main_screen' }
|
14
14
|
|
@@ -42,7 +42,7 @@ module Vedeu
|
|
42
42
|
end
|
43
43
|
}
|
44
44
|
|
45
|
-
it { subject.must_be_instance_of(Vedeu::Group) }
|
45
|
+
it { subject.must_be_instance_of(Vedeu::Models::Group) }
|
46
46
|
|
47
47
|
it { subject.members.must_equal(Set['editor_interface']) }
|
48
48
|
end
|
@@ -58,7 +58,7 @@ module Vedeu
|
|
58
58
|
end
|
59
59
|
}
|
60
60
|
|
61
|
-
it { subject.must_be_instance_of(Vedeu::Group) }
|
61
|
+
it { subject.must_be_instance_of(Vedeu::Models::Group) }
|
62
62
|
|
63
63
|
it { subject.members.must_equal(expected) }
|
64
64
|
end
|
@@ -9,7 +9,7 @@ module Vedeu
|
|
9
9
|
let(:described) { Vedeu::DSL::Interface }
|
10
10
|
let(:instance) { described.new(model, client) }
|
11
11
|
let(:model) {
|
12
|
-
Vedeu::Interface.new(name: _name)
|
12
|
+
Vedeu::Models::Interface.new(name: _name)
|
13
13
|
}
|
14
14
|
let(:_name) { 'actinium' }
|
15
15
|
let(:client) {}
|
@@ -29,7 +29,7 @@ module Vedeu
|
|
29
29
|
end
|
30
30
|
}
|
31
31
|
|
32
|
-
it { subject.must_be_instance_of(Vedeu::Interface) }
|
32
|
+
it { subject.must_be_instance_of(Vedeu::Models::Interface) }
|
33
33
|
|
34
34
|
context 'when the block is not given' do
|
35
35
|
subject { described.interface('fluorine') }
|
@@ -172,7 +172,7 @@ module Vedeu
|
|
172
172
|
end
|
173
173
|
|
174
174
|
context 'when the interface has a name' do
|
175
|
-
before { Vedeu::Focus.reset }
|
175
|
+
before { Vedeu::Models::Focus.reset }
|
176
176
|
|
177
177
|
it { subject.must_equal(['actinium']) }
|
178
178
|
end
|
@@ -213,7 +213,7 @@ module Vedeu
|
|
213
213
|
|
214
214
|
subject { instance.group(_value) }
|
215
215
|
|
216
|
-
it { subject.must_be_instance_of(Vedeu::Group) }
|
216
|
+
it { subject.must_be_instance_of(Vedeu::Models::Group) }
|
217
217
|
|
218
218
|
context 'when the value is empty or nil' do
|
219
219
|
let(:_value) { '' }
|
@@ -225,7 +225,8 @@ module Vedeu
|
|
225
225
|
let(:members) { Set['actinium', 'lanthanum'] }
|
226
226
|
|
227
227
|
before do
|
228
|
-
Vedeu::Group.new(name:
|
228
|
+
Vedeu::Models::Group.new(name: 'elements',
|
229
|
+
members: ['lanthanum']).store
|
229
230
|
end
|
230
231
|
|
231
232
|
it {
|
@@ -12,7 +12,7 @@ module Vedeu
|
|
12
12
|
let(:client) {}
|
13
13
|
let(:colour) { Vedeu::Colours::Colour.new }
|
14
14
|
let(:parent) { Vedeu::Views::View.new }
|
15
|
-
let(:style) { Vedeu::Style.new }
|
15
|
+
let(:style) { Vedeu::Presentation::Style.new }
|
16
16
|
let(:_value) { [] }
|
17
17
|
let(:attributes) {
|
18
18
|
{
|
@@ -75,7 +75,9 @@ module Vedeu
|
|
75
75
|
end
|
76
76
|
|
77
77
|
context 'when the block is not given' do
|
78
|
-
it {
|
78
|
+
it {
|
79
|
+
proc { instance.streams }.must_raise(Vedeu::Error::InvalidSyntax)
|
80
|
+
}
|
79
81
|
end
|
80
82
|
|
81
83
|
it { instance.must_respond_to(:stream) }
|
@@ -8,7 +8,7 @@ module Vedeu
|
|
8
8
|
|
9
9
|
let(:described) { Vedeu::DSL::Presentation }
|
10
10
|
let(:instance) { Vedeu::DSL::Interface.new(model) }
|
11
|
-
let(:model) { Vedeu::Interface.new }
|
11
|
+
let(:model) { Vedeu::Models::Interface.new }
|
12
12
|
let(:background) { '#00ff00' }
|
13
13
|
let(:foreground) { '#ff00ff' }
|
14
14
|
|
@@ -92,7 +92,7 @@ module Vedeu
|
|
92
92
|
it { instance.must_respond_to(:styles) }
|
93
93
|
it { instance.must_respond_to(:styles=) }
|
94
94
|
|
95
|
-
it { subject.must_be_instance_of(Vedeu::Style) }
|
95
|
+
it { subject.must_be_instance_of(Vedeu::Presentation::Style) }
|
96
96
|
end
|
97
97
|
|
98
98
|
end # Presentation
|
@@ -35,7 +35,7 @@ module Vedeu
|
|
35
35
|
it { subject.must_be_instance_of(Vedeu::Views::Lines) }
|
36
36
|
|
37
37
|
it 'adds the text to the model' do
|
38
|
-
Vedeu::Text.expects(:add).with(_value, modified_options)
|
38
|
+
Vedeu::Output::Text.expects(:add).with(_value, modified_options)
|
39
39
|
subject
|
40
40
|
end
|
41
41
|
end
|
@@ -47,7 +47,7 @@ module Vedeu
|
|
47
47
|
it { subject.must_be_instance_of(Vedeu::Views::Streams) }
|
48
48
|
|
49
49
|
it 'adds the text to the model' do
|
50
|
-
Vedeu::Text.expects(:add).with(_value, modified_options)
|
50
|
+
Vedeu::Output::Text.expects(:add).with(_value, modified_options)
|
51
51
|
subject
|
52
52
|
end
|
53
53
|
end
|
@@ -60,7 +60,7 @@ module Vedeu
|
|
60
60
|
it { subject.must_be_instance_of(Vedeu::Views::Streams) }
|
61
61
|
|
62
62
|
it 'adds the text to the model' do
|
63
|
-
Vedeu::Text.expects(:add).with(_value, modified_options)
|
63
|
+
Vedeu::Output::Text.expects(:add).with(_value, modified_options)
|
64
64
|
subject
|
65
65
|
end
|
66
66
|
end
|
@@ -70,7 +70,7 @@ module Vedeu
|
|
70
70
|
let(:anchor) { :align }
|
71
71
|
|
72
72
|
it 'adds the text to the model' do
|
73
|
-
Vedeu::Text.expects(:add).with(_value, modified_options)
|
73
|
+
Vedeu::Output::Text.expects(:add).with(_value, modified_options)
|
74
74
|
instance.align(_value, options)
|
75
75
|
end
|
76
76
|
end
|
@@ -79,7 +79,7 @@ module Vedeu
|
|
79
79
|
let(:anchor) { :center }
|
80
80
|
|
81
81
|
it 'adds the text to the model' do
|
82
|
-
Vedeu::Text.expects(:add).with(_value, modified_options)
|
82
|
+
Vedeu::Output::Text.expects(:add).with(_value, modified_options)
|
83
83
|
instance.center(_value, options)
|
84
84
|
end
|
85
85
|
end
|
@@ -88,7 +88,7 @@ module Vedeu
|
|
88
88
|
let(:anchor) { :centre }
|
89
89
|
|
90
90
|
it 'adds the text to the model' do
|
91
|
-
Vedeu::Text.expects(:add).with(_value, modified_options)
|
91
|
+
Vedeu::Output::Text.expects(:add).with(_value, modified_options)
|
92
92
|
instance.centre(_value, options)
|
93
93
|
end
|
94
94
|
end
|
@@ -97,7 +97,7 @@ module Vedeu
|
|
97
97
|
let(:anchor) { :left }
|
98
98
|
|
99
99
|
it 'adds the text to the model' do
|
100
|
-
Vedeu::Text.expects(:add).with(_value, modified_options)
|
100
|
+
Vedeu::Output::Text.expects(:add).with(_value, modified_options)
|
101
101
|
instance.left(_value, options)
|
102
102
|
end
|
103
103
|
end
|
@@ -106,7 +106,7 @@ module Vedeu
|
|
106
106
|
let(:anchor) { :right }
|
107
107
|
|
108
108
|
it 'adds the text to the model' do
|
109
|
-
Vedeu::Text.expects(:add).with(_value, modified_options)
|
109
|
+
Vedeu::Output::Text.expects(:add).with(_value, modified_options)
|
110
110
|
instance.right(_value, options)
|
111
111
|
end
|
112
112
|
end
|
@@ -6,7 +6,7 @@ module Vedeu
|
|
6
6
|
|
7
7
|
describe Document do
|
8
8
|
|
9
|
-
let(:described)
|
9
|
+
let(:described) { Vedeu::Editor::Document }
|
10
10
|
let(:instance) { described.new(attributes) }
|
11
11
|
let(:attributes) {
|
12
12
|
{
|
@@ -21,7 +21,7 @@ module Vedeu
|
|
21
21
|
}
|
22
22
|
let(:_name) { 'Vedeu::Editor::Document' }
|
23
23
|
|
24
|
-
before { Vedeu::Direct.stubs(:write) }
|
24
|
+
before { Vedeu::Output::Direct.stubs(:write) }
|
25
25
|
|
26
26
|
describe '#initialize' do
|
27
27
|
it { instance.must_be_instance_of(described) }
|
@@ -52,9 +52,13 @@ module Vedeu
|
|
52
52
|
}
|
53
53
|
|
54
54
|
before do
|
55
|
-
Vedeu::Geometry::Geometry.new(name: _name,
|
55
|
+
Vedeu::Geometry::Geometry.new(name: _name,
|
56
|
+
x: 1,
|
57
|
+
y: 1,
|
58
|
+
xn: 5,
|
59
|
+
yn: 5).store
|
56
60
|
Vedeu::Terminal.stubs(:output)
|
57
|
-
Vedeu::Direct.stubs(:write).returns(expected)
|
61
|
+
Vedeu::Output::Direct.stubs(:write).returns(expected)
|
58
62
|
end
|
59
63
|
|
60
64
|
subject { instance.clear }
|
@@ -175,12 +179,12 @@ module Vedeu
|
|
175
179
|
}
|
176
180
|
let(:output) { "\e[1;1HA\e[2;1HB\e[3;1HC\e[1;1H\e[?25h" }
|
177
181
|
|
178
|
-
before { Vedeu::Direct.stubs(:write) }
|
182
|
+
before { Vedeu::Output::Direct.stubs(:write) }
|
179
183
|
|
180
184
|
subject { instance.render }
|
181
185
|
|
182
186
|
it {
|
183
|
-
Vedeu::Direct.expects(:write).with(value: output, x: 1, y: 1)
|
187
|
+
Vedeu::Output::Direct.expects(:write).with(value: output, x: 1, y: 1)
|
184
188
|
subject
|
185
189
|
}
|
186
190
|
end
|
@@ -29,6 +29,7 @@ module Vedeu
|
|
29
29
|
|
30
30
|
describe 'accessors' do
|
31
31
|
it { instance.must_respond_to(:name) }
|
32
|
+
it { instance.must_respond_to(:name=) }
|
32
33
|
end
|
33
34
|
|
34
35
|
describe '#add' do
|
@@ -90,16 +91,6 @@ module Vedeu
|
|
90
91
|
it { subject.must_be_instance_of(Vedeu::Input::Keys) }
|
91
92
|
end
|
92
93
|
|
93
|
-
describe '#name' do
|
94
|
-
subject { instance.name }
|
95
|
-
|
96
|
-
it { subject.must_be_instance_of(String) }
|
97
|
-
end
|
98
|
-
|
99
|
-
describe '#name=' do
|
100
|
-
it { instance.must_respond_to(:name=) }
|
101
|
-
end
|
102
|
-
|
103
94
|
end # Keymap
|
104
95
|
|
105
96
|
end # Input
|
@@ -2,243 +2,250 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
|
5
|
+
module Models
|
6
6
|
|
7
|
-
|
7
|
+
describe Focus do
|
8
8
|
|
9
|
-
|
10
|
-
Vedeu::Focus.reset
|
11
|
-
Vedeu.interfaces.reset
|
9
|
+
let(:described) { Vedeu::Models::Focus }
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
Vedeu::Focus.reset
|
17
|
-
Vedeu.interfaces.reset
|
18
|
-
end
|
11
|
+
before do
|
12
|
+
Vedeu::Models::Focus.reset
|
13
|
+
Vedeu.interfaces.reset
|
19
14
|
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
Vedeu.stubs(:trigger)
|
16
|
+
end
|
17
|
+
after do
|
18
|
+
Vedeu::Models::Focus.reset
|
19
|
+
Vedeu.interfaces.reset
|
23
20
|
end
|
24
21
|
|
25
|
-
|
26
|
-
|
22
|
+
describe '#add' do
|
23
|
+
context 'adds an interface to storage' do
|
24
|
+
it { Vedeu::Models::Focus.add('thallium').must_equal(['thallium']) }
|
25
|
+
end
|
27
26
|
|
28
|
-
it
|
29
|
-
Vedeu
|
30
|
-
Vedeu::Focus.registered.must_equal(['thallium'])
|
31
|
-
}
|
32
|
-
end
|
27
|
+
context 'does not add it again if already exists' do
|
28
|
+
before { Vedeu.interface('thallium') {} }
|
33
29
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
Vedeu::Focus.registered.must_equal(['bismuth', 'thallium', 'lead'])
|
40
|
-
end
|
30
|
+
it {
|
31
|
+
Vedeu::Models::Focus.add('thallium')
|
32
|
+
Vedeu::Models::Focus.registered.must_equal(['thallium'])
|
33
|
+
}
|
34
|
+
end
|
41
35
|
|
42
|
-
|
43
|
-
|
36
|
+
it 'does not add it again if already exists' do
|
37
|
+
Vedeu::Models::Focus.add('thallium')
|
38
|
+
Vedeu::Models::Focus.add('lead')
|
39
|
+
Vedeu::Models::Focus.add('bismuth')
|
40
|
+
Vedeu::Models::Focus.add('bismuth', true)
|
41
|
+
Vedeu::Models::Focus.registered.must_equal(
|
42
|
+
['bismuth', 'thallium', 'lead']
|
43
|
+
)
|
44
|
+
end
|
44
45
|
|
45
|
-
|
46
|
-
Vedeu
|
47
|
-
Vedeu::Focus.add('lead', true)
|
48
|
-
Vedeu::Focus.registered.must_equal(['lead', 'thallium'])
|
49
|
-
}
|
50
|
-
end
|
46
|
+
context 'adds the interface to storage focussed' do
|
47
|
+
before { Vedeu.interface('thallium') {} }
|
51
48
|
|
52
|
-
|
53
|
-
|
49
|
+
it {
|
50
|
+
Vedeu::Models::Focus.add('thallium')
|
51
|
+
Vedeu::Models::Focus.add('lead', true)
|
52
|
+
Vedeu::Models::Focus.registered.must_equal(['lead', 'thallium'])
|
53
|
+
}
|
54
|
+
end
|
54
55
|
|
55
|
-
|
56
|
-
Vedeu
|
57
|
-
Vedeu::Focus.add('lead')
|
58
|
-
Vedeu::Focus.registered.must_equal(['thallium', 'lead'])
|
59
|
-
}
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
describe '#by_name' do
|
64
|
-
it 'the named interface is focussed when the method is called' do
|
65
|
-
Vedeu::Focus.add('thallium')
|
66
|
-
Vedeu::Focus.add('lead')
|
67
|
-
Vedeu::Focus.add('bismuth')
|
68
|
-
Vedeu::Focus.by_name('lead').must_equal('lead')
|
69
|
-
end
|
56
|
+
context 'adds the interface to storage unfocussed' do
|
57
|
+
before { Vedeu.interface('thallium') {} }
|
70
58
|
|
71
|
-
|
72
|
-
|
73
|
-
|
59
|
+
it {
|
60
|
+
Vedeu::Models::Focus.add('thallium')
|
61
|
+
Vedeu::Models::Focus.add('lead')
|
62
|
+
Vedeu::Models::Focus.registered.must_equal(['thallium', 'lead'])
|
63
|
+
}
|
64
|
+
end
|
74
65
|
end
|
75
66
|
|
76
|
-
|
67
|
+
describe '#by_name' do
|
77
68
|
it 'the named interface is focussed when the method is called' do
|
78
|
-
Vedeu::Focus.add('thallium')
|
79
|
-
Vedeu::Focus.add('lead')
|
80
|
-
Vedeu::Focus.add('bismuth')
|
81
|
-
Vedeu.
|
69
|
+
Vedeu::Models::Focus.add('thallium')
|
70
|
+
Vedeu::Models::Focus.add('lead')
|
71
|
+
Vedeu::Models::Focus.add('bismuth')
|
72
|
+
Vedeu::Models::Focus.by_name('lead').must_equal('lead')
|
82
73
|
end
|
83
74
|
|
84
75
|
it 'raises an exception if the interface does not exist' do
|
85
|
-
proc { Vedeu.
|
76
|
+
proc { Vedeu::Models::Focus.by_name('not_found') }.
|
86
77
|
must_raise(Vedeu::Error::ModelNotFound)
|
87
78
|
end
|
88
|
-
end
|
89
|
-
end
|
90
79
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
80
|
+
context 'API methods' do
|
81
|
+
it 'the named interface is focussed when the method is called' do
|
82
|
+
Vedeu::Models::Focus.add('thallium')
|
83
|
+
Vedeu::Models::Focus.add('lead')
|
84
|
+
Vedeu::Models::Focus.add('bismuth')
|
85
|
+
Vedeu.focus_by_name('lead').must_equal('lead')
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'raises an exception if the interface does not exist' do
|
89
|
+
proc { Vedeu.focus_by_name('not_found') }.
|
90
|
+
must_raise(Vedeu::Error::ModelNotFound)
|
91
|
+
end
|
92
|
+
end
|
101
93
|
end
|
102
94
|
|
103
|
-
|
104
|
-
|
105
|
-
|
95
|
+
describe '#current' do
|
96
|
+
before { Vedeu::Models::Focus.reset }
|
97
|
+
|
98
|
+
subject { described.current }
|
106
99
|
|
107
|
-
context 'API methods' do
|
108
100
|
it 'returns the name of the interface currently in focus' do
|
109
|
-
Vedeu::Focus.add('thallium')
|
110
|
-
Vedeu::Focus.add('lead')
|
111
|
-
Vedeu::Focus.add('bismuth')
|
112
|
-
|
101
|
+
Vedeu::Models::Focus.add('thallium')
|
102
|
+
Vedeu::Models::Focus.add('lead')
|
103
|
+
Vedeu::Models::Focus.add('bismuth')
|
104
|
+
subject.must_equal('thallium')
|
113
105
|
end
|
114
|
-
end
|
115
|
-
end
|
116
106
|
|
117
|
-
|
118
|
-
|
107
|
+
context 'when no interfaces are defined' do
|
108
|
+
it { subject.must_equal(nil) }
|
109
|
+
end
|
119
110
|
|
120
|
-
|
121
|
-
|
111
|
+
context 'API methods' do
|
112
|
+
it 'returns the name of the interface currently in focus' do
|
113
|
+
Vedeu::Models::Focus.add('thallium')
|
114
|
+
Vedeu::Models::Focus.add('lead')
|
115
|
+
Vedeu::Models::Focus.add('bismuth')
|
116
|
+
Vedeu.focus.must_equal('thallium')
|
117
|
+
end
|
118
|
+
end
|
122
119
|
end
|
123
120
|
|
124
|
-
|
125
|
-
|
126
|
-
end
|
121
|
+
describe '#current?' do
|
122
|
+
before { Vedeu::Models::Focus.stubs(:current).returns('lead') }
|
127
123
|
|
128
|
-
context 'API methods' do
|
129
124
|
context 'when the interface is currently in focus' do
|
130
|
-
it { Vedeu.
|
125
|
+
it { Vedeu::Models::Focus.current?('lead').must_equal(true) }
|
131
126
|
end
|
132
127
|
|
133
128
|
context 'when the interface is not currently in focus' do
|
134
|
-
it { Vedeu.
|
129
|
+
it { Vedeu::Models::Focus.current?('bismuth').must_equal(false) }
|
135
130
|
end
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
describe '#next_item' do
|
140
|
-
it 'the next interface is focussed when the method is called' do
|
141
|
-
Vedeu::Focus.add('thallium')
|
142
|
-
Vedeu::Focus.add('lead')
|
143
|
-
Vedeu::Focus.add('bismuth')
|
144
|
-
Vedeu::Focus.next_item.must_equal('lead')
|
145
|
-
end
|
146
131
|
|
147
|
-
|
148
|
-
|
132
|
+
context 'API methods' do
|
133
|
+
context 'when the interface is currently in focus' do
|
134
|
+
it { Vedeu.focussed?('lead').must_equal(true) }
|
135
|
+
end
|
149
136
|
|
150
|
-
|
137
|
+
context 'when the interface is not currently in focus' do
|
138
|
+
it { Vedeu.focussed?('bismuth').must_equal(false) }
|
139
|
+
end
|
140
|
+
end
|
151
141
|
end
|
152
|
-
end
|
153
142
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
143
|
+
describe '#next_item' do
|
144
|
+
it 'the next interface is focussed when the method is called' do
|
145
|
+
Vedeu::Models::Focus.add('thallium')
|
146
|
+
Vedeu::Models::Focus.add('lead')
|
147
|
+
Vedeu::Models::Focus.add('bismuth')
|
148
|
+
Vedeu::Models::Focus.next_item.must_equal('lead')
|
149
|
+
end
|
161
150
|
|
162
|
-
|
163
|
-
|
151
|
+
context 'returns false if storage is empty' do
|
152
|
+
before { Vedeu::Models::Focus.reset }
|
153
|
+
|
154
|
+
it { Vedeu::Models::Focus.next_item.must_equal(false) }
|
155
|
+
end
|
164
156
|
end
|
165
157
|
|
166
|
-
|
167
|
-
before
|
168
|
-
Vedeu.
|
169
|
-
Vedeu.interface('
|
158
|
+
describe '#next_visible_item' do
|
159
|
+
before do
|
160
|
+
Vedeu.stubs(:trigger)
|
161
|
+
Vedeu.interface('gold') { visible true }
|
162
|
+
Vedeu.interface('silver') { visible true }
|
170
163
|
Vedeu.interface('platinum') { visible false }
|
171
|
-
|
164
|
+
end
|
172
165
|
|
173
|
-
it '
|
174
|
-
Vedeu::Focus.next_visible_item.must_equal('
|
166
|
+
it 'the next visible interface is focussed when the method is called' do
|
167
|
+
Vedeu::Models::Focus.next_visible_item.must_equal('silver')
|
175
168
|
end
|
176
|
-
end
|
177
169
|
|
178
|
-
|
179
|
-
|
170
|
+
context 'when there are no visible interfaces' do
|
171
|
+
before {
|
172
|
+
Vedeu.interface('gold') { visible false }
|
173
|
+
Vedeu.interface('silver') { visible false }
|
174
|
+
Vedeu.interface('platinum') { visible false }
|
175
|
+
}
|
180
176
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
describe '#prev_item' do
|
186
|
-
it 'the previous interface is focussed when the method is called' do
|
187
|
-
Vedeu::Focus.add('thallium')
|
188
|
-
Vedeu::Focus.add('lead')
|
189
|
-
Vedeu::Focus.add('bismuth')
|
190
|
-
Vedeu::Focus.prev_item.must_equal('bismuth')
|
191
|
-
end
|
177
|
+
it 'puts the first interface defined in focus' do
|
178
|
+
Vedeu::Models::Focus.next_visible_item.must_equal('gold')
|
179
|
+
end
|
180
|
+
end
|
192
181
|
|
193
|
-
|
194
|
-
|
182
|
+
context 'when there are no interfaces' do
|
183
|
+
before { Vedeu::Models::Focus.reset }
|
195
184
|
|
196
|
-
|
185
|
+
it { Vedeu::Models::Focus.next_visible_item.must_equal(false) }
|
186
|
+
end
|
197
187
|
end
|
198
|
-
end
|
199
188
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
189
|
+
describe '#prev_item' do
|
190
|
+
it 'the previous interface is focussed when the method is called' do
|
191
|
+
Vedeu::Models::Focus.add('thallium')
|
192
|
+
Vedeu::Models::Focus.add('lead')
|
193
|
+
Vedeu::Models::Focus.add('bismuth')
|
194
|
+
Vedeu::Models::Focus.prev_item.must_equal('bismuth')
|
195
|
+
end
|
196
|
+
|
197
|
+
context 'returns false if storage is empty' do
|
198
|
+
before { Vedeu::Models::Focus.reset }
|
207
199
|
|
208
|
-
|
209
|
-
|
200
|
+
it { Vedeu::Models::Focus.prev_item.must_equal(false) }
|
201
|
+
end
|
210
202
|
end
|
211
203
|
|
212
|
-
|
204
|
+
describe '#prev_visible_item' do
|
213
205
|
before do
|
214
|
-
Vedeu.
|
215
|
-
Vedeu.interface('
|
206
|
+
Vedeu.stubs(:trigger)
|
207
|
+
Vedeu.interface('gold') { visible true }
|
208
|
+
Vedeu.interface('silver') { visible true }
|
216
209
|
Vedeu.interface('platinum') { visible false }
|
217
210
|
end
|
218
211
|
|
219
|
-
it '
|
220
|
-
|
212
|
+
it 'the previous visible interface is focussed when the method is ' \
|
213
|
+
'called' do
|
214
|
+
Vedeu::Models::Focus.prev_visible_item.must_equal('silver')
|
221
215
|
end
|
222
|
-
end
|
223
216
|
|
224
|
-
|
225
|
-
|
217
|
+
context 'when there are no visible interfaces' do
|
218
|
+
before do
|
219
|
+
Vedeu.interface('gold') { visible false }
|
220
|
+
Vedeu.interface('silver') { visible false }
|
221
|
+
Vedeu.interface('platinum') { visible false }
|
222
|
+
end
|
226
223
|
|
227
|
-
|
228
|
-
|
229
|
-
|
224
|
+
it 'puts the first interface defined in focus' do
|
225
|
+
Vedeu::Models::Focus.prev_visible_item.must_equal('gold')
|
226
|
+
end
|
227
|
+
end
|
230
228
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
229
|
+
context 'when there are no interfaces' do
|
230
|
+
before { Vedeu::Models::Focus.reset }
|
231
|
+
|
232
|
+
it { Vedeu::Models::Focus.prev_visible_item.must_equal(false) }
|
233
|
+
end
|
235
234
|
end
|
236
235
|
|
237
|
-
|
238
|
-
|
236
|
+
describe '#refresh' do
|
237
|
+
before do
|
238
|
+
Vedeu::Models::Focus.add('thallium')
|
239
|
+
Vedeu.stubs(:trigger).returns([])
|
240
|
+
end
|
241
|
+
|
242
|
+
it 'triggers the event to refresh the interface current in focus' do
|
243
|
+
Vedeu::Models::Focus.refresh.must_equal([])
|
244
|
+
end
|
239
245
|
end
|
240
|
-
end
|
241
246
|
|
242
|
-
|
247
|
+
end # Focus
|
248
|
+
|
249
|
+
end # Models
|
243
250
|
|
244
251
|
end # Vedeu
|