vedeu 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vedeu/all.rb +1 -1
  3. data/lib/vedeu/application/controller.rb +2 -2
  4. data/lib/vedeu/bindings.rb +1 -1
  5. data/lib/vedeu/bindings/application.rb +2 -2
  6. data/lib/vedeu/bindings/drb.rb +8 -8
  7. data/lib/vedeu/bindings/menus.rb +11 -11
  8. data/lib/vedeu/bindings/movement.rb +12 -12
  9. data/lib/vedeu/bindings/system.rb +18 -18
  10. data/lib/vedeu/bindings/visibility.rb +9 -9
  11. data/lib/vedeu/colours/colour.rb +1 -1
  12. data/lib/vedeu/common.rb +1 -1
  13. data/lib/vedeu/dsl/composition.rb +8 -3
  14. data/lib/vedeu/dsl/interface.rb +41 -17
  15. data/lib/vedeu/log/debug.rb +5 -1
  16. data/lib/vedeu/log/log.rb +1 -0
  17. data/lib/vedeu/models/interface.rb +3 -2
  18. data/lib/vedeu/plugins.rb +1 -1
  19. data/lib/vedeu/runtime/bootstrap.rb +0 -3
  20. data/lib/vedeu/runtime/launcher.rb +3 -2
  21. data/lib/vedeu/runtime/router.rb +49 -47
  22. data/lib/vedeu/{traps.rb → runtime/traps.rb} +0 -0
  23. data/lib/vedeu/templating/decoder.rb +4 -2
  24. data/lib/vedeu/templating/encoder.rb +4 -2
  25. data/lib/vedeu/templating/view_template.rb +35 -2
  26. data/lib/vedeu/version.rb +1 -1
  27. data/test/lib/vedeu/application/application_view_test.rb +1 -1
  28. data/test/lib/vedeu/application/controller_test.rb +4 -0
  29. data/test/lib/vedeu/bindings_test.rb +2 -0
  30. data/test/lib/vedeu/borders/border_test.rb +28 -40
  31. data/test/lib/vedeu/borders/borders_test.rb +0 -2
  32. data/test/lib/vedeu/borders/render_border_test.rb +11 -13
  33. data/test/lib/vedeu/buffers/buffer_test.rb +12 -5
  34. data/test/lib/vedeu/buffers/display_buffer_test.rb +2 -2
  35. data/test/lib/vedeu/cli/generator/application_test.rb +9 -9
  36. data/test/lib/vedeu/cli/generator/view_test.rb +10 -7
  37. data/test/lib/vedeu/cli/main_test.rb +4 -4
  38. data/test/lib/vedeu/colours/colour_translator_test.rb +2 -4
  39. data/test/lib/vedeu/common_test.rb +8 -0
  40. data/test/lib/vedeu/configuration/configuration_test.rb +4 -4
  41. data/test/lib/vedeu/cursor/cursors_test.rb +4 -4
  42. data/test/lib/vedeu/cursor/move_test.rb +11 -8
  43. data/test/lib/vedeu/cursor/refresh_cursor_test.rb +12 -12
  44. data/test/lib/vedeu/cursor/reposition_test.rb +7 -11
  45. data/test/lib/vedeu/distributed/client_test.rb +4 -4
  46. data/test/lib/vedeu/distributed/server_test.rb +4 -5
  47. data/test/lib/vedeu/dsl/border_test.rb +2 -2
  48. data/test/lib/vedeu/dsl/composition_test.rb +5 -4
  49. data/test/lib/vedeu/dsl/geometry_test.rb +6 -4
  50. data/test/lib/vedeu/dsl/interface_test.rb +9 -27
  51. data/test/lib/vedeu/dsl/use_test.rb +2 -2
  52. data/test/lib/vedeu/events/trigger_test.rb +2 -2
  53. data/test/lib/vedeu/geometry/coordinate_test.rb +9 -9
  54. data/test/lib/vedeu/geometry/geometry_test.rb +8 -2
  55. data/test/lib/vedeu/geometry/position_validator_test.rb +11 -14
  56. data/test/lib/vedeu/input/input_test.rb +5 -5
  57. data/test/lib/vedeu/input/keymap_test.rb +2 -2
  58. data/test/lib/vedeu/log/timer_test.rb +2 -2
  59. data/test/lib/vedeu/models/focus_test.rb +20 -25
  60. data/test/lib/vedeu/models/interface_test.rb +2 -2
  61. data/test/lib/vedeu/models/interfaces_test.rb +7 -5
  62. data/test/lib/vedeu/models/line_test.rb +0 -5
  63. data/test/lib/vedeu/models/menu_test.rb +0 -2
  64. data/test/lib/vedeu/null/geometry_test.rb +1 -4
  65. data/test/lib/vedeu/output/clear/named_interface_test.rb +2 -2
  66. data/test/lib/vedeu/output/esc_test.rb +7 -4
  67. data/test/lib/vedeu/output/output_test.rb +3 -6
  68. data/test/lib/vedeu/output/refresh_test.rb +2 -2
  69. data/test/lib/vedeu/output/renderers/file_test.rb +1 -3
  70. data/test/lib/vedeu/output/renderers/html_test.rb +1 -3
  71. data/test/lib/vedeu/output/renderers/json_test.rb +1 -3
  72. data/test/lib/vedeu/output/renderers_test.rb +2 -2
  73. data/test/lib/vedeu/output/viewport_test.rb +70 -71
  74. data/test/lib/vedeu/repositories/model_test.rb +0 -19
  75. data/test/lib/vedeu/repositories/repository_test.rb +8 -8
  76. data/test/lib/vedeu/runtime/application_test.rb +2 -2
  77. data/test/lib/vedeu/runtime/launcher_test.rb +7 -7
  78. data/test/lib/vedeu/runtime/router_test.rb +33 -33
  79. data/test/lib/vedeu/{traps_test.rb → runtime/traps_test.rb} +2 -2
  80. data/test/lib/vedeu/templating/decoder_test.rb +1 -0
  81. data/test/lib/vedeu/templating/encoder_test.rb +1 -0
  82. data/test/lib/vedeu/templating/template_test.rb +8 -1
  83. data/test/lib/vedeu/templating/view_template_test.rb +108 -22
  84. data/test/lib/vedeu/terminal_mode_test.rb +2 -2
  85. data/test/lib/vedeu/terminal_test.rb +6 -6
  86. data/test/support/helpers/model_test_class.rb +19 -0
  87. metadata +5 -17
  88. data/test/support/templates/background.erb +0 -1
  89. data/test/support/templates/colour.erb +0 -1
  90. data/test/support/templates/foreground.erb +0 -1
  91. data/test/support/templates/multiple.erb +0 -2
  92. data/test/support/templates/plain.erb +0 -1
  93. data/test/support/templates/style.erb +0 -1
@@ -8,10 +8,6 @@ module Vedeu
8
8
  let(:instance) { described.new(colour) }
9
9
  let(:colour) { '#ff0000' }
10
10
 
11
- before do
12
- instance.stubs(:registered?).returns(false)
13
- end
14
-
15
11
  describe 'alias methods' do
16
12
  it { instance.must_respond_to(:value) }
17
13
  end
@@ -113,6 +109,8 @@ module Vedeu
113
109
  context 'when the colour is not supported' do
114
110
  let(:colour) { [:not_supported] }
115
111
 
112
+ before { instance.stubs(:registered?).returns(false) }
113
+
116
114
  it { subject.must_equal('') }
117
115
  end
118
116
  end
@@ -17,6 +17,14 @@ module Vedeu
17
17
  let(:described) { Vedeu::VedeuCommonClass }
18
18
  let(:instance) { described.new }
19
19
 
20
+ describe '#demodulize' do
21
+ let(:klass) { described }
22
+
23
+ subject { instance.demodulize(klass) }
24
+
25
+ it { subject.must_equal('VedeuCommonClass') }
26
+ end
27
+
20
28
  describe '#present?' do
21
29
  subject { instance.defined_value_test(_value) }
22
30
 
@@ -55,11 +55,11 @@ module Vedeu
55
55
  end
56
56
 
57
57
  context 'when the log is configured' do
58
- before do
58
+ before {
59
59
  Vedeu.configure do
60
60
  log '/tmp/vedeu.log'
61
61
  end
62
- end
62
+ }
63
63
 
64
64
  it { described.log.must_equal('/tmp/vedeu.log') }
65
65
  end
@@ -71,11 +71,11 @@ module Vedeu
71
71
  end
72
72
 
73
73
  context 'when the log is configured' do
74
- before do
74
+ before {
75
75
  Vedeu.configure do
76
76
  log '/tmp/vedeu.log'
77
77
  end
78
- end
78
+ }
79
79
 
80
80
  it { described.log?.must_equal(true) }
81
81
  end
@@ -12,19 +12,19 @@ module Vedeu
12
12
  subject { Vedeu.cursor }
13
13
 
14
14
  context 'when there are cursors are defined' do
15
- before do
15
+ before {
16
16
  Vedeu::Focus.add('Vedeu.cursor')
17
17
  Vedeu::Cursor.new(name: 'Vedeu.cursor').store
18
- end
18
+ }
19
19
 
20
20
  it { subject.must_be_instance_of(Vedeu::Cursor) }
21
21
  end
22
22
 
23
23
  context 'when there are no cursors defined' do
24
- before do
24
+ before {
25
25
  Vedeu::Focus.reset
26
26
  Vedeu.cursors.reset
27
- end
27
+ }
28
28
 
29
29
  it { subject.must_be_instance_of(NilClass) }
30
30
  end
@@ -15,7 +15,7 @@ module Vedeu
15
15
  let(:x) { 1 }
16
16
  let(:y) { 1 }
17
17
 
18
- before do
18
+ before {
19
19
  Vedeu::Cursor.new(name: 'move_with_border',
20
20
  ox: ox,
21
21
  oy: oy,
@@ -45,12 +45,12 @@ module Vedeu
45
45
  end
46
46
  IO.console.stubs(:winsize).returns([25, 80])
47
47
  IO.console.stubs(:print)
48
- end
49
- after do
48
+ }
49
+ after {
50
50
  Vedeu.borders.reset
51
51
  Vedeu.cursors.reset
52
52
  Vedeu.geometries.reset
53
- end
53
+ }
54
54
 
55
55
  describe '#initialize' do
56
56
  it { instance.must_be_instance_of(described) }
@@ -64,9 +64,10 @@ module Vedeu
64
64
  let(:direction) { :down }
65
65
  let(:_name) { 'manganese' }
66
66
 
67
- before do
67
+ before {
68
68
  Vedeu::Cursor.new(name: 'manganese', oy: 2, ox: 3, x: 8, y: 7).store
69
- end
69
+ Vedeu.stubs(:focus).returns('neon')
70
+ }
70
71
 
71
72
  subject { described.by_name(entity, direction, _name) }
72
73
 
@@ -75,8 +76,10 @@ module Vedeu
75
76
  context 'when the name is not specified' do
76
77
  let(:_name) {}
77
78
 
78
- # @todo Add more tests.
79
- # it { skip }
79
+ it 'uses the current focussed interface name' do
80
+ Vedeu::Move.expects(:send).with(:down, Vedeu::Cursor, 'neon')
81
+ subject
82
+ end
80
83
  end
81
84
 
82
85
  context 'when the name is specified' do
@@ -11,24 +11,24 @@ module Vedeu
11
11
  let(:ox) { 0 }
12
12
  let(:oy) { 0 }
13
13
 
14
- before do
15
- Vedeu.geometry 'refresh_cursor' do
16
- x 1
17
- xn 3
18
- y 1
19
- yn 3
20
- end
21
- Vedeu::Cursor.new({ name: 'refresh_cursor', ox: ox, oy: oy }).store
22
-
23
- Vedeu::Terminal.stubs(:output).returns(expected)
24
- end
25
-
26
14
  describe '#initialize' do
27
15
  it { instance.must_be_instance_of(described) }
28
16
  it { instance.instance_variable_get('@name').must_equal(_name) }
29
17
  end
30
18
 
31
19
  describe '.render' do
20
+ before {
21
+ Vedeu.geometry 'refresh_cursor' do
22
+ x 1
23
+ xn 3
24
+ y 1
25
+ yn 3
26
+ end
27
+ Vedeu::Cursor.new({ name: 'refresh_cursor', ox: ox, oy: oy }).store
28
+
29
+ Vedeu::Terminal.stubs(:output).returns(expected)
30
+ }
31
+
32
32
  subject { described.render(_name) }
33
33
 
34
34
  it 'renders the cursor in the terminal' do
@@ -11,15 +11,8 @@ module Vedeu
11
11
  let(:x) { 4 }
12
12
  let(:y) { 7 }
13
13
 
14
- before do
15
- Vedeu::Cursor.new(name: _name, x: 1, y: 1, ox: 1, oy: 1)
16
- Vedeu.stubs(:trigger)
17
- end
18
-
19
- after { Vedeu.cursors.reset }
20
-
21
14
  describe '#initialize' do
22
- it { instance.must_be_instance_of(Vedeu::Reposition) }
15
+ it { instance.must_be_instance_of(described) }
23
16
  it { instance.instance_variable_get('@entity').must_equal(entity) }
24
17
  it { instance.instance_variable_get('@name').must_equal(_name) }
25
18
  it { instance.instance_variable_get('@x').must_equal(x) }
@@ -29,9 +22,12 @@ module Vedeu
29
22
  describe '.to' do
30
23
  # let(:new_entity) { Vedeu::Cursor.new(name: _name, y: 8, x: 5, oy: 7, ox: 4) }
31
24
 
32
- # before do
33
- # entity.stubs(:new).returns(new_entity)
34
- # end
25
+ before {
26
+ # entity.stubs(:new).returns(new_entity)
27
+ Vedeu::Cursor.new(name: _name, x: 1, y: 1, ox: 1, oy: 1)
28
+ Vedeu.stubs(:trigger)
29
+ }
30
+ after { Vedeu.cursors.reset }
35
31
 
36
32
  subject { described.to(entity, _name, y, x) }
37
33
 
@@ -11,10 +11,10 @@ module Vedeu
11
11
  let(:uri) { 'druby://localhost:21420' }
12
12
  let(:server) {}
13
13
 
14
- before do
14
+ before {
15
15
  $stdout.stubs(:puts)
16
16
  DRbObject.stubs(:new_with_uri).returns(server)
17
- end
17
+ }
18
18
 
19
19
  describe '#initialize' do
20
20
  it { instance.must_be_instance_of(described) }
@@ -88,10 +88,10 @@ module Vedeu
88
88
 
89
89
  context 'when the DRb server is available' do
90
90
  # @todo Add more tests.
91
- # before do
91
+ # before {
92
92
  # DRbObject.stubs(:new_with_uri).returns(server)
93
93
  # Process.stubs(:kill)
94
- # end
94
+ # }
95
95
 
96
96
  # it {
97
97
  # Process.expects(:kill).with('KILL', 0)
@@ -12,10 +12,10 @@ module Vedeu
12
12
  let(:enabled) { false }
13
13
  let(:running) { false }
14
14
 
15
- before do
15
+ before {
16
16
  Vedeu::Configuration.stubs(:drb?).returns(enabled)
17
17
  DRb.stubs(:thread).returns(running)
18
- end
18
+ }
19
19
 
20
20
  describe '.input' do
21
21
  let(:data) {}
@@ -69,9 +69,9 @@ module Vedeu
69
69
  context 'when the server is enabled' do
70
70
  let(:enabled) { true }
71
71
 
72
- before do
72
+ before {
73
73
  Vedeu::Terminal.stubs(:restore_screen)
74
- end
74
+ }
75
75
 
76
76
  context 'and the server is running' do
77
77
  # @todo Add more tests.
@@ -86,7 +86,6 @@ module Vedeu
86
86
  end
87
87
 
88
88
  it { Vedeu.expects(:trigger).with(:_exit_); subject }
89
-
90
89
  end
91
90
  end
92
91
 
@@ -195,14 +195,14 @@ module Vedeu
195
195
  end
196
196
 
197
197
  describe '#use' do
198
- before do
198
+ before {
199
199
  Vedeu.border 'some_border' do
200
200
  title 'Some border'
201
201
  end
202
202
  Vedeu.border 'other_border' do
203
203
  title use('some_border').title
204
204
  end
205
- end
205
+ }
206
206
  after { Vedeu.borders.reset }
207
207
 
208
208
  subject { instance.use('other_border').title }
@@ -37,8 +37,9 @@ module Vedeu
37
37
  let(:filename) {}
38
38
  let(:object) {}
39
39
  let(:content) { "Hydrogen\nCarbon\nOxygen\nNitrogen" }
40
+ let(:options) { {} }
40
41
 
41
- subject { instance.template_for(_name, filename, object) }
42
+ subject { instance.template_for(_name, filename, object, options) }
42
43
 
43
44
  context 'when the name of the view is not given' do
44
45
  let(:filename) { 'my_interface.erb' }
@@ -56,10 +57,10 @@ module Vedeu
56
57
  let(:_name) { 'my_interface' }
57
58
  let(:filename) { 'my_interface.erb' }
58
59
 
59
- before do
60
+ before {
60
61
  Vedeu::Templating::ViewTemplate.expects(:parse).
61
- with(object, filename).returns(content)
62
- end
62
+ with(object, filename, options).returns(content)
63
+ }
63
64
 
64
65
  it { subject.must_be_instance_of(Vedeu::InterfaceCollection) }
65
66
  end
@@ -10,8 +10,6 @@ module Vedeu
10
10
  let(:instance) { described.new(model) }
11
11
  let(:model) { Vedeu::Geometry.new }
12
12
 
13
- before { Terminal.stubs(:size).returns([25, 80]) }
14
-
15
13
  describe '#initialize' do
16
14
  it { instance.must_be_instance_of(described) }
17
15
  it { instance.instance_variable_get('@model').must_equal(model) }
@@ -56,6 +54,8 @@ module Vedeu
56
54
  end
57
55
 
58
56
  describe '#columns' do
57
+ before { Terminal.stubs(:size).returns([25, 80]) }
58
+
59
59
  subject { instance.columns(3) }
60
60
 
61
61
  it { subject.must_equal(18) }
@@ -96,6 +96,8 @@ module Vedeu
96
96
  end
97
97
 
98
98
  describe '#rows' do
99
+ before { Terminal.stubs(:size).returns([25, 80]) }
100
+
99
101
  subject { instance.rows(3) }
100
102
 
101
103
  it { subject.must_equal(6) }
@@ -114,14 +116,14 @@ module Vedeu
114
116
  end
115
117
 
116
118
  describe '#use' do
117
- before do
119
+ before {
118
120
  Vedeu.geometry 'some_geometry' do
119
121
  x 5
120
122
  end
121
123
  Vedeu.geometry 'other_geometry' do
122
124
  x use('some_geometry').x
123
125
  end
124
- end
126
+ }
125
127
  after { Vedeu.geometries.reset }
126
128
 
127
129
  subject { instance.use('other_geometry').x }
@@ -9,15 +9,10 @@ module Vedeu
9
9
  let(:described) { Vedeu::DSL::Interface }
10
10
  let(:instance) { described.new(model) }
11
11
  let(:model) {
12
- Vedeu.interface 'actinium' do
13
- # ...
14
- end
12
+ Vedeu::Interface.new(name: 'actinium')
15
13
  }
16
14
  let(:client) {}
17
15
 
18
- before { Vedeu.interfaces.reset }
19
- after { Vedeu.interfaces.reset }
20
-
21
16
  describe '#initialize' do
22
17
  it { instance.must_be_instance_of(described) }
23
18
  it { instance.instance_variable_get('@model').must_equal(model) }
@@ -27,12 +22,6 @@ module Vedeu
27
22
  describe '#border' do
28
23
  after { Vedeu.borders.reset }
29
24
 
30
- subject {
31
- instance.border do
32
- # ...
33
- end
34
- }
35
-
36
25
  context 'when the block is not given' do
37
26
  subject { instance.border }
38
27
 
@@ -143,10 +132,10 @@ module Vedeu
143
132
 
144
133
  describe '#focus!' do
145
134
  context 'when a single call is made' do
146
- before do
135
+ before {
147
136
  Vedeu::Focus.reset
148
137
  Vedeu.interface('curium') { focus! }
149
- end
138
+ }
150
139
 
151
140
  it 'sets the interface as current' do
152
141
  Vedeu.focus.must_equal('curium')
@@ -154,11 +143,11 @@ module Vedeu
154
143
  end
155
144
 
156
145
  context 'when no calls are made' do
157
- before do
146
+ before {
158
147
  Vedeu::Focus.reset
159
148
  Vedeu.interface('curium') {}
160
149
  Vedeu.interface('dysprosium') {}
161
- end
150
+ }
162
151
 
163
152
  it 'the first interface defined will be current' do
164
153
  Vedeu.focus.must_equal('curium')
@@ -167,12 +156,6 @@ module Vedeu
167
156
  end
168
157
 
169
158
  describe '#geometry' do
170
- subject {
171
- instance.geometry do
172
- # ...
173
- end
174
- }
175
-
176
159
  context 'when the required block is not provided' do
177
160
  subject { instance.geometry }
178
161
 
@@ -218,9 +201,9 @@ module Vedeu
218
201
  context 'when the named group exists' do
219
202
  let(:members) { Set['actinium', 'lanthanum'] }
220
203
 
221
- before do
204
+ before {
222
205
  Vedeu::Group.new(name: 'elements', members: ['lanthanum']).store
223
- end
206
+ }
224
207
 
225
208
  it {
226
209
  subject
@@ -301,14 +284,14 @@ module Vedeu
301
284
  end
302
285
 
303
286
  describe '#use' do
304
- before do
287
+ before {
305
288
  Vedeu.interface 'some_interface' do
306
289
  delay 0.75
307
290
  end
308
291
  Vedeu.interface 'other_interface' do
309
292
  delay use('some_interface').delay
310
293
  end
311
- end
294
+ }
312
295
  after { Vedeu.interfaces.reset }
313
296
 
314
297
  subject { instance.use('other_interface').delay }
@@ -332,7 +315,6 @@ module Vedeu
332
315
  subject { instance.zindex(_value) }
333
316
 
334
317
  it { subject.must_equal(1) }
335
-
336
318
  it { instance.must_respond_to(:z_index) }
337
319
  it { instance.must_respond_to(:z) }
338
320
  end