vedeu 0.6.8 → 0.6.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +9 -0
  3. data/README.md +1 -1
  4. data/docs/api.md +60 -67
  5. data/docs/configuration.md +8 -5
  6. data/docs/events.md +31 -15
  7. data/docs/events/application.md +12 -0
  8. data/docs/events/document.md +57 -0
  9. data/docs/events/drb.md +43 -0
  10. data/docs/events/focus.md +24 -0
  11. data/docs/events/menu.md +57 -0
  12. data/docs/events/movement.md +57 -0
  13. data/docs/events/refresh.md +25 -0
  14. data/docs/events/system.md +90 -0
  15. data/docs/events/visibility.md +68 -0
  16. data/lib/vedeu.rb +2 -2
  17. data/lib/vedeu/all.rb +3 -2
  18. data/lib/vedeu/api.rb +18 -18
  19. data/lib/vedeu/application/controller.rb +1 -1
  20. data/lib/vedeu/application/helper.rb +1 -1
  21. data/lib/vedeu/application/view.rb +1 -1
  22. data/lib/vedeu/bindings/application.rb +1 -12
  23. data/lib/vedeu/bindings/bindings.rb +3 -1
  24. data/lib/vedeu/bindings/document.rb +9 -62
  25. data/lib/vedeu/bindings/drb.rb +12 -56
  26. data/lib/vedeu/bindings/focus.rb +3 -28
  27. data/lib/vedeu/bindings/menus.rb +10 -66
  28. data/lib/vedeu/bindings/movement.rb +4 -69
  29. data/lib/vedeu/bindings/refresh.rb +3 -33
  30. data/lib/vedeu/bindings/system.rb +14 -100
  31. data/lib/vedeu/bindings/visibility.rb +20 -71
  32. data/lib/vedeu/borders/all.rb +4 -3
  33. data/lib/vedeu/borders/border.rb +39 -33
  34. data/lib/vedeu/borders/dsl.rb +40 -33
  35. data/lib/vedeu/borders/null.rb +2 -2
  36. data/lib/vedeu/borders/render.rb +29 -24
  37. data/lib/vedeu/borders/repository.rb +2 -2
  38. data/lib/vedeu/buffers/all.rb +8 -7
  39. data/lib/vedeu/buffers/buffer.rb +47 -39
  40. data/lib/vedeu/buffers/null.rb +2 -2
  41. data/lib/vedeu/buffers/refresh.rb +4 -3
  42. data/lib/vedeu/buffers/virtual_buffer.rb +122 -118
  43. data/lib/vedeu/buffers/virtual_buffers.rb +62 -56
  44. data/lib/vedeu/colours/background.rb +2 -1
  45. data/lib/vedeu/colours/colour.rb +21 -19
  46. data/lib/vedeu/colours/foreground.rb +2 -1
  47. data/lib/vedeu/colours/repository.rb +6 -5
  48. data/lib/vedeu/colours/translator.rb +39 -35
  49. data/lib/vedeu/configuration/api.rb +59 -51
  50. data/lib/vedeu/configuration/cli.rb +9 -7
  51. data/lib/vedeu/configuration/configuration.rb +41 -32
  52. data/lib/vedeu/cursors/cursor.rb +1 -1
  53. data/lib/vedeu/cursors/refresh.rb +20 -16
  54. data/lib/vedeu/distributed/server.rb +8 -6
  55. data/lib/vedeu/distributed/subprocess.rb +90 -86
  56. data/lib/vedeu/distributed/uri.rb +4 -3
  57. data/lib/vedeu/dsl/composition.rb +2 -2
  58. data/lib/vedeu/dsl/group.rb +4 -4
  59. data/lib/vedeu/dsl/interface.rb +5 -5
  60. data/lib/vedeu/dsl/presentation.rb +2 -2
  61. data/lib/vedeu/dsl/text.rb +1 -1
  62. data/lib/vedeu/editor/cropper.rb +4 -4
  63. data/lib/vedeu/editor/cursor.rb +6 -4
  64. data/lib/vedeu/editor/document.rb +20 -18
  65. data/lib/vedeu/editor/editor.rb +2 -2
  66. data/lib/vedeu/editor/line.rb +10 -5
  67. data/lib/vedeu/editor/lines.rb +2 -2
  68. data/lib/vedeu/internal_api.rb +4 -4
  69. data/lib/vedeu/models/focus.rb +197 -191
  70. data/lib/vedeu/models/group.rb +171 -159
  71. data/lib/vedeu/models/groups.rb +14 -10
  72. data/lib/vedeu/models/interface.rb +116 -110
  73. data/lib/vedeu/models/interfaces.rb +24 -20
  74. data/lib/vedeu/models/toggleable.rb +4 -4
  75. data/lib/vedeu/models/views/char.rb +1 -1
  76. data/lib/vedeu/models/views/composition.rb +1 -1
  77. data/lib/vedeu/models/views/line.rb +1 -1
  78. data/lib/vedeu/models/views/stream.rb +1 -1
  79. data/lib/vedeu/models/views/view.rb +1 -1
  80. data/lib/vedeu/null/interface.rb +1 -1
  81. data/lib/vedeu/null/view.rb +1 -1
  82. data/lib/vedeu/output/clear/named_interface.rb +1 -1
  83. data/lib/vedeu/output/compressor.rb +78 -73
  84. data/lib/vedeu/output/direct.rb +61 -57
  85. data/lib/vedeu/output/output.rb +34 -29
  86. data/lib/vedeu/output/{presentation.rb → presentation/presentation.rb} +2 -1
  87. data/lib/vedeu/output/presentation/style.rb +64 -18
  88. data/lib/vedeu/output/presentation/styles.rb +39 -0
  89. data/lib/vedeu/output/renderers/html.rb +2 -2
  90. data/lib/vedeu/output/renderers/json.rb +2 -1
  91. data/lib/vedeu/output/renderers/terminal.rb +3 -3
  92. data/lib/vedeu/output/renderers/text.rb +3 -3
  93. data/lib/vedeu/output/text.rb +186 -180
  94. data/lib/vedeu/output/wordwrap.rb +142 -138
  95. data/lib/vedeu/refresh/refresh.rb +2 -2
  96. data/lib/vedeu/templating/helpers.rb +11 -6
  97. data/lib/vedeu/templating/view_template.rb +1 -1
  98. data/lib/vedeu/terminal/terminal.rb +2 -2
  99. data/lib/vedeu/version.rb +1 -1
  100. data/test/lib/vedeu/borders/render_test.rb +1 -1
  101. data/test/lib/vedeu/buffers/buffer_test.rb +16 -14
  102. data/test/lib/vedeu/buffers/virtual_buffer_test.rb +105 -101
  103. data/test/lib/vedeu/buffers/virtual_buffers_test.rb +43 -39
  104. data/test/lib/vedeu/colours/colour_test.rb +4 -4
  105. data/test/lib/vedeu/cursors/cursor_test.rb +2 -2
  106. data/test/lib/vedeu/cursors/repository_test.rb +3 -3
  107. data/test/lib/vedeu/distributed/subprocess_test.rb +33 -29
  108. data/test/lib/vedeu/dsl/group_test.rb +3 -3
  109. data/test/lib/vedeu/dsl/interface_test.rb +6 -5
  110. data/test/lib/vedeu/dsl/line_test.rb +4 -2
  111. data/test/lib/vedeu/dsl/presentation_test.rb +2 -2
  112. data/test/lib/vedeu/dsl/text_test.rb +8 -8
  113. data/test/lib/vedeu/editor/document_test.rb +10 -6
  114. data/test/lib/vedeu/input/keymap_test.rb +1 -10
  115. data/test/lib/vedeu/models/focus_test.rb +177 -170
  116. data/test/lib/vedeu/models/group_test.rb +99 -95
  117. data/test/lib/vedeu/models/groups_test.rb +13 -9
  118. data/test/lib/vedeu/models/interface_test.rb +93 -87
  119. data/test/lib/vedeu/models/interfaces_test.rb +24 -20
  120. data/test/lib/vedeu/models/views/char_test.rb +2 -2
  121. data/test/lib/vedeu/models/views/line_test.rb +11 -7
  122. data/test/lib/vedeu/models/views/stream_test.rb +1 -1
  123. data/test/lib/vedeu/models/views/view_test.rb +1 -1
  124. data/test/lib/vedeu/output/clear/named_group_test.rb +1 -1
  125. data/test/lib/vedeu/output/clear/named_interface_test.rb +3 -1
  126. data/test/lib/vedeu/output/compressor_test.rb +126 -122
  127. data/test/lib/vedeu/output/direct_test.rb +49 -43
  128. data/test/lib/vedeu/output/output_test.rb +35 -31
  129. data/test/lib/vedeu/output/{presentation_test.rb → presentation/presentation_test.rb} +11 -7
  130. data/test/lib/vedeu/output/presentation/style_test.rb +88 -48
  131. data/test/lib/vedeu/output/presentation/styles_test.rb +84 -0
  132. data/test/lib/vedeu/output/text_test.rb +109 -105
  133. data/test/lib/vedeu/output/viewport_test.rb +3 -1
  134. data/test/lib/vedeu/output/wordwrap_test.rb +209 -205
  135. data/test/lib/vedeu/refresh/refresh_test.rb +3 -1
  136. data/test/lib/vedeu/templating/helpers_test.rb +6 -6
  137. data/test/lib/vedeu/templating/view_template_test.rb +1 -1
  138. metadata +17 -8
  139. data/lib/vedeu/output/style.rb +0 -76
  140. 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: 'elements', members: ['lanthanum']).store
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 { proc { instance.streams }.must_raise(Vedeu::Error::InvalidSyntax) }
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) { Vedeu::Editor::Document }
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, x: 1, y: 1, xn: 5, yn: 5).store
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
- describe Focus do
5
+ module Models
6
6
 
7
- let(:described) { Vedeu::Focus }
7
+ describe Focus do
8
8
 
9
- before do
10
- Vedeu::Focus.reset
11
- Vedeu.interfaces.reset
9
+ let(:described) { Vedeu::Models::Focus }
12
10
 
13
- Vedeu.stubs(:trigger)
14
- end
15
- after do
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
- describe '#add' do
21
- context 'adds an interface to storage' do
22
- it { Vedeu::Focus.add('thallium').must_equal(['thallium']) }
15
+ Vedeu.stubs(:trigger)
16
+ end
17
+ after do
18
+ Vedeu::Models::Focus.reset
19
+ Vedeu.interfaces.reset
23
20
  end
24
21
 
25
- context 'does not add it again if already exists' do
26
- before { Vedeu.interface('thallium') {} }
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::Focus.add('thallium')
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
- it 'does not add it again if already exists' do
35
- Vedeu::Focus.add('thallium')
36
- Vedeu::Focus.add('lead')
37
- Vedeu::Focus.add('bismuth')
38
- Vedeu::Focus.add('bismuth', true)
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
- context 'adds the interface to storage focussed' do
43
- before { Vedeu.interface('thallium') {} }
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
- it {
46
- Vedeu::Focus.add('thallium')
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
- context 'adds the interface to storage unfocussed' do
53
- before { Vedeu.interface('thallium') {} }
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
- it {
56
- Vedeu::Focus.add('thallium')
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
- it 'raises an exception if the interface does not exist' do
72
- proc { Vedeu::Focus.by_name('not_found') }.
73
- must_raise(Vedeu::Error::ModelNotFound)
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
- context 'API methods' do
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.focus_by_name('lead').must_equal('lead')
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.focus_by_name('not_found') }.
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
- describe '#current' do
92
- before { Vedeu::Focus.reset }
93
-
94
- subject { described.current }
95
-
96
- it 'returns the name of the interface currently in focus' do
97
- Vedeu::Focus.add('thallium')
98
- Vedeu::Focus.add('lead')
99
- Vedeu::Focus.add('bismuth')
100
- subject.must_equal('thallium')
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
- context 'when no interfaces are defined' do
104
- it { subject.must_equal(nil) }
105
- end
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
- Vedeu.focus.must_equal('thallium')
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
- describe '#current?' do
118
- before { Vedeu::Focus.stubs(:current).returns('lead') }
107
+ context 'when no interfaces are defined' do
108
+ it { subject.must_equal(nil) }
109
+ end
119
110
 
120
- context 'when the interface is currently in focus' do
121
- it { Vedeu::Focus.current?('lead').must_equal(true) }
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
- context 'when the interface is not currently in focus' do
125
- it { Vedeu::Focus.current?('bismuth').must_equal(false) }
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.focussed?('lead').must_equal(true) }
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.focussed?('bismuth').must_equal(false) }
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
- context 'returns false if storage is empty' do
148
- before { Vedeu::Focus.reset }
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
- it { Vedeu::Focus.next_item.must_equal(false) }
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
- describe '#next_visible_item' do
155
- before do
156
- Vedeu.stubs(:trigger)
157
- Vedeu.interface('gold') { visible true }
158
- Vedeu.interface('silver') { visible true }
159
- Vedeu.interface('platinum') { visible false }
160
- end
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
- it 'the next visible interface is focussed when the method is called' do
163
- Vedeu::Focus.next_visible_item.must_equal('silver')
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
- context 'when there are no visible interfaces' do
167
- before {
168
- Vedeu.interface('gold') { visible false }
169
- Vedeu.interface('silver') { visible false }
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 'puts the first interface defined in focus' do
174
- Vedeu::Focus.next_visible_item.must_equal('gold')
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
- context 'when there are no interfaces' do
179
- before { Vedeu::Focus.reset }
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
- it { Vedeu::Focus.next_visible_item.must_equal(false) }
182
- end
183
- end
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
- context 'returns false if storage is empty' do
194
- before { Vedeu::Focus.reset }
182
+ context 'when there are no interfaces' do
183
+ before { Vedeu::Models::Focus.reset }
195
184
 
196
- it { Vedeu::Focus.prev_item.must_equal(false) }
185
+ it { Vedeu::Models::Focus.next_visible_item.must_equal(false) }
186
+ end
197
187
  end
198
- end
199
188
 
200
- describe '#prev_visible_item' do
201
- before do
202
- Vedeu.stubs(:trigger)
203
- Vedeu.interface('gold') { visible true }
204
- Vedeu.interface('silver') { visible true }
205
- Vedeu.interface('platinum') { visible false }
206
- end
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
- it 'the previous visible interface is focussed when the method is called' do
209
- Vedeu::Focus.prev_visible_item.must_equal('silver')
200
+ it { Vedeu::Models::Focus.prev_item.must_equal(false) }
201
+ end
210
202
  end
211
203
 
212
- context 'when there are no visible interfaces' do
204
+ describe '#prev_visible_item' do
213
205
  before do
214
- Vedeu.interface('gold') { visible false }
215
- Vedeu.interface('silver') { visible false }
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 'puts the first interface defined in focus' do
220
- Vedeu::Focus.prev_visible_item.must_equal('gold')
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
- context 'when there are no interfaces' do
225
- before { Vedeu::Focus.reset }
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
- it { Vedeu::Focus.prev_visible_item.must_equal(false) }
228
- end
229
- end
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
- describe '#refresh' do
232
- before do
233
- Vedeu::Focus.add('thallium')
234
- Vedeu.stubs(:trigger).returns([])
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
- it 'triggers the event to refresh the interface current in focus' do
238
- Vedeu::Focus.refresh.must_equal([])
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
- end # Focus
247
+ end # Focus
248
+
249
+ end # Models
243
250
 
244
251
  end # Vedeu