vedeu 0.5.6 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vedeu/application/controller.rb +2 -2
  3. data/lib/vedeu/cursor/refresh_cursor.rb +1 -1
  4. data/lib/vedeu/dsl/presentation.rb +3 -3
  5. data/lib/vedeu/dsl/use.rb +0 -34
  6. data/lib/vedeu/events/event.rb +2 -2
  7. data/lib/vedeu/events/trigger.rb +1 -1
  8. data/lib/vedeu/geometry/area.rb +1 -1
  9. data/lib/vedeu/geometry/dimension.rb +2 -2
  10. data/lib/vedeu/input/input.rb +1 -1
  11. data/lib/vedeu/log/log.rb +5 -3
  12. data/lib/vedeu/models/focus.rb +1 -1
  13. data/lib/vedeu/models/interfaces.rb +1 -1
  14. data/lib/vedeu/models/toggleable.rb +5 -5
  15. data/lib/vedeu/null/interface.rb +1 -8
  16. data/lib/vedeu/null/view.rb +1 -8
  17. data/lib/vedeu/output/refresh_group.rb +1 -1
  18. data/lib/vedeu/output/renderers/json.rb +1 -1
  19. data/lib/vedeu/repositories/model.rb +1 -1
  20. data/lib/vedeu/repositories/registerable.rb +1 -1
  21. data/lib/vedeu/templating/view_template.rb +3 -3
  22. data/lib/vedeu/terminal.rb +3 -3
  23. data/lib/vedeu/version.rb +1 -1
  24. data/test/lib/vedeu/bindings_test.rb +2 -2
  25. data/test/lib/vedeu/borders/border_test.rb +2 -6
  26. data/test/lib/vedeu/borders/render_border_test.rb +2 -2
  27. data/test/lib/vedeu/cli/generator/application_test.rb +2 -2
  28. data/test/lib/vedeu/cli/generator/view_test.rb +2 -2
  29. data/test/lib/vedeu/cli/main_test.rb +4 -4
  30. data/test/lib/vedeu/configuration/configuration_test.rb +6 -6
  31. data/test/lib/vedeu/cursor/cursor_test.rb +6 -6
  32. data/test/lib/vedeu/cursor/cursors_test.rb +4 -4
  33. data/test/lib/vedeu/cursor/move_test.rb +2 -2
  34. data/test/lib/vedeu/cursor/refresh_cursor_test.rb +2 -2
  35. data/test/lib/vedeu/cursor/reposition_test.rb +2 -2
  36. data/test/lib/vedeu/distributed/client_test.rb +2 -2
  37. data/test/lib/vedeu/distributed/server_test.rb +3 -5
  38. data/test/lib/vedeu/dsl/border_test.rb +2 -2
  39. data/test/lib/vedeu/dsl/composition_test.rb +3 -3
  40. data/test/lib/vedeu/dsl/interface_test.rb +8 -8
  41. data/test/lib/vedeu/dsl/line_test.rb +2 -2
  42. data/test/lib/vedeu/dsl/use_test.rb +0 -24
  43. data/test/lib/vedeu/events/event_aliases_test.rb +9 -0
  44. data/test/lib/vedeu/events/event_test.rb +5 -5
  45. data/test/lib/vedeu/geometry/coordinate_test.rb +2 -2
  46. data/test/lib/vedeu/input/input_test.rb +2 -2
  47. data/test/lib/vedeu/input/keymap_test.rb +2 -2
  48. data/test/lib/vedeu/log/timer_test.rb +2 -2
  49. data/test/lib/vedeu/models/focus_test.rb +16 -24
  50. data/test/lib/vedeu/models/interfaces_test.rb +2 -2
  51. data/test/lib/vedeu/null/view_test.rb +44 -0
  52. data/test/lib/vedeu/output/clear/named_interface_test.rb +2 -2
  53. data/test/lib/vedeu/output/output_test.rb +2 -2
  54. data/test/lib/vedeu/output/renderers_test.rb +2 -2
  55. data/test/lib/vedeu/output/viewport_test.rb +2 -2
  56. data/test/lib/vedeu/plugins/plugin_test.rb +9 -0
  57. data/test/lib/vedeu/runtime/application_test.rb +2 -2
  58. data/test/lib/vedeu/runtime/launcher_test.rb +2 -2
  59. data/test/lib/vedeu/runtime/router_test.rb +8 -8
  60. data/test/lib/vedeu/templating/template_test.rb +2 -2
  61. data/test/lib/vedeu/templating/view_template_test.rb +4 -3
  62. data/test/lib/vedeu/terminal_mode_test.rb +2 -2
  63. data/test/lib/vedeu/terminal_test.rb +6 -10
  64. data/vedeu.gemspec +1 -1
  65. metadata +4 -4
@@ -25,10 +25,10 @@ module Vedeu
25
25
  let(:interface) {
26
26
  Vedeu::Interface.new(name: _name, visible: visible)
27
27
  }
28
- before {
28
+ before do
29
29
  Vedeu.geometries.stubs(:by_name).returns(geometry)
30
30
  Vedeu.interfaces.stubs(:by_name).returns(interface)
31
- }
31
+ end
32
32
 
33
33
  subject { instance.render }
34
34
 
@@ -16,10 +16,10 @@ module Vedeu
16
16
  end
17
17
 
18
18
  describe '.generate' do
19
- # before {
19
+ # before do
20
20
  # FileUtils.stubs(:cp_r)
21
21
  # FileUtils.stubs(:mkdir)
22
- # }
22
+ # end
23
23
 
24
24
  subject { instance.generate(_name) }
25
25
 
@@ -16,10 +16,10 @@ module Vedeu
16
16
  end
17
17
 
18
18
  describe '.generate' do
19
- # before {
19
+ # before do
20
20
  # FileUtils.stubs(:cp_r)
21
21
  # FileUtils.stubs(:mkdir)
22
- # }
22
+ # end
23
23
 
24
24
  subject { described.generate(_name) }
25
25
 
@@ -12,10 +12,10 @@ module Vedeu
12
12
  describe '#new' do
13
13
  let(:_name) { 'app_name' }
14
14
 
15
- before {
15
+ before do
16
16
  instance.stubs(:say)
17
17
  Vedeu::Generator::Application.stubs(:generate).returns('')
18
- }
18
+ end
19
19
 
20
20
  subject { instance.new(_name) }
21
21
 
@@ -28,10 +28,10 @@ module Vedeu
28
28
  describe '#view' do
29
29
  let(:_name) { 'view_name' }
30
30
 
31
- before {
31
+ before do
32
32
  instance.stubs(:say)
33
33
  Vedeu::Generator::View.stubs(:generate).returns('')
34
- }
34
+ end
35
35
 
36
36
  subject { instance.view(_name) }
37
37
 
@@ -55,11 +55,11 @@ module Vedeu
55
55
  end
56
56
 
57
57
  context 'when the log is configured' do
58
- before {
58
+ before do
59
59
  Vedeu.configure do
60
60
  log '/tmp/vedeu.log'
61
61
  end
62
- }
62
+ end
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 {
74
+ before do
75
75
  Vedeu.configure do
76
76
  log '/tmp/vedeu.log'
77
77
  end
78
- }
78
+ end
79
79
 
80
80
  it { described.log?.must_equal(true) }
81
81
  end
@@ -87,11 +87,11 @@ module Vedeu
87
87
  end
88
88
 
89
89
  context 'when log_only is configured' do
90
- before {
90
+ before do
91
91
  Vedeu.configure do
92
92
  log_only :timer, :event
93
93
  end
94
- }
94
+ end
95
95
 
96
96
  it { described.log_only.must_equal([:timer, :event]) }
97
97
  end
@@ -36,10 +36,10 @@ module Vedeu
36
36
  }
37
37
  let(:enabled) { true }
38
38
 
39
- before {
39
+ before do
40
40
  Vedeu.borders.stubs(:by_name).returns(border)
41
41
  Vedeu.geometries.stubs(:by_name).returns(geometry)
42
- }
42
+ end
43
43
 
44
44
  describe '#initialize' do
45
45
  subject { instance }
@@ -70,10 +70,10 @@ module Vedeu
70
70
  let(:visible) { true }
71
71
  let(:hide_cursor) { Vedeu::Escape.new(value: Vedeu::Esc.hide_cursor) }
72
72
 
73
- before {
73
+ before do
74
74
  Vedeu::Output.stubs(:render).
75
75
  with(hide_cursor).returns(hide_cursor)
76
- }
76
+ end
77
77
 
78
78
  subject { instance.hide }
79
79
 
@@ -90,10 +90,10 @@ module Vedeu
90
90
  let(:visible) { false }
91
91
  let(:show_cursor) { Vedeu::Escape.new(value: Vedeu::Esc.show_cursor) }
92
92
 
93
- before {
93
+ before do
94
94
  Vedeu::Output.stubs(:render).
95
95
  with(show_cursor).returns(show_cursor)
96
- }
96
+ end
97
97
 
98
98
  subject { instance.show }
99
99
 
@@ -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 {
15
+ before do
16
16
  Vedeu::Focus.add('Vedeu.cursor')
17
17
  Vedeu::Cursor.new(name: 'Vedeu.cursor').store
18
- }
18
+ end
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 {
24
+ before do
25
25
  Vedeu::Focus.reset
26
26
  Vedeu.cursors.reset
27
- }
27
+ end
28
28
 
29
29
  it { subject.must_be_instance_of(NilClass) }
30
30
  end
@@ -29,7 +29,7 @@ module Vedeu
29
29
  Vedeu::Geometry.new(name: _name, x: 5, xn: 10, y: 5, yn: 10)
30
30
  }
31
31
 
32
- before {
32
+ before do
33
33
  IO.console.stubs(:winsize).returns([25, 80])
34
34
  IO.console.stubs(:print)
35
35
 
@@ -38,7 +38,7 @@ module Vedeu
38
38
  Vedeu.geometries.stubs(:by_name).returns(geometry)
39
39
 
40
40
  Vedeu.stubs(:trigger).with(:_refresh_cursor_, _name)
41
- }
41
+ end
42
42
 
43
43
  describe '#initialize' do
44
44
  it { instance.must_be_instance_of(described) }
@@ -17,7 +17,7 @@ module Vedeu
17
17
  end
18
18
 
19
19
  describe '.render' do
20
- before {
20
+ before do
21
21
  Vedeu.geometry 'refresh_cursor' do
22
22
  x 1
23
23
  xn 3
@@ -27,7 +27,7 @@ module Vedeu
27
27
  Vedeu::Cursor.new(name: 'refresh_cursor', ox: ox, oy: oy).store
28
28
 
29
29
  Vedeu::Terminal.stubs(:output).returns(expected)
30
- }
30
+ end
31
31
 
32
32
  subject { described.render(_name) }
33
33
 
@@ -22,11 +22,11 @@ module Vedeu
22
22
  describe '.to' do
23
23
  # let(:new_entity) { Vedeu::Cursor.new(name: _name, y: 8, x: 5, oy: 7, ox: 4) }
24
24
 
25
- before {
25
+ before do
26
26
  # entity.stubs(:new).returns(new_entity)
27
27
  Vedeu::Cursor.new(name: _name, x: 1, y: 1, ox: 1, oy: 1)
28
28
  Vedeu.stubs(:trigger)
29
- }
29
+ end
30
30
  after { Vedeu.cursors.reset }
31
31
 
32
32
  subject { described.to(entity, _name, y, x) }
@@ -11,10 +11,10 @@ module Vedeu
11
11
  let(:uri) { 'druby://localhost:21420' }
12
12
  let(:server) {}
13
13
 
14
- before {
14
+ before do
15
15
  $stdout.stubs(:puts)
16
16
  DRbObject.stubs(:new_with_uri).returns(server)
17
- }
17
+ end
18
18
 
19
19
  describe '#initialize' do
20
20
  it { instance.must_be_instance_of(described) }
@@ -12,10 +12,10 @@ module Vedeu
12
12
  let(:enabled) { false }
13
13
  let(:running) { false }
14
14
 
15
- before {
15
+ before do
16
16
  Vedeu::Configuration.stubs(:drb?).returns(enabled)
17
17
  DRb.stubs(:thread).returns(running)
18
- }
18
+ end
19
19
 
20
20
  describe '.input' do
21
21
  let(:data) {}
@@ -69,9 +69,7 @@ module Vedeu
69
69
  context 'when the server is enabled' do
70
70
  let(:enabled) { true }
71
71
 
72
- before {
73
- Vedeu::Terminal.stubs(:restore_screen)
74
- }
72
+ before { Vedeu::Terminal.stubs(:restore_screen) }
75
73
 
76
74
  context 'and the server is running' do
77
75
  # @todo Add more tests.
@@ -195,14 +195,14 @@ module Vedeu
195
195
  end
196
196
 
197
197
  describe '#use' do
198
- before {
198
+ before do
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
- }
205
+ end
206
206
  after { Vedeu.borders.reset }
207
207
 
208
208
  subject { instance.use('other_border').title }
@@ -25,7 +25,7 @@ module Vedeu
25
25
  }
26
26
 
27
27
  it { subject.must_be_instance_of(Vedeu::Views::ViewCollection) }
28
- it { subject.first.must_be_instance_of(Vedeu::Views::View) }
28
+ it { subject[0].must_be_instance_of(Vedeu::Views::View) }
29
29
 
30
30
  context 'when the block is not given' do
31
31
  it { proc { instance.view }.must_raise(Vedeu::InvalidSyntax) }
@@ -57,10 +57,10 @@ module Vedeu
57
57
  let(:_name) { 'my_interface' }
58
58
  let(:filename) { 'my_interface.erb' }
59
59
 
60
- before {
60
+ before do
61
61
  Vedeu::Templating::ViewTemplate.expects(:parse).
62
62
  with(object, filename, options).returns(content)
63
- }
63
+ end
64
64
 
65
65
  it { subject.must_be_instance_of(Vedeu::Views::ViewCollection) }
66
66
  end
@@ -160,10 +160,10 @@ module Vedeu
160
160
 
161
161
  describe '#focus!' do
162
162
  context 'when a single call is made' do
163
- before {
163
+ before do
164
164
  Vedeu::Focus.reset
165
165
  Vedeu.interface('curium') { focus! }
166
- }
166
+ end
167
167
 
168
168
  it 'sets the interface as current' do
169
169
  Vedeu.focus.must_equal('curium')
@@ -171,11 +171,11 @@ module Vedeu
171
171
  end
172
172
 
173
173
  context 'when no calls are made' do
174
- before {
174
+ before do
175
175
  Vedeu::Focus.reset
176
176
  Vedeu.interface('curium') {}
177
177
  Vedeu.interface('dysprosium') {}
178
- }
178
+ end
179
179
 
180
180
  it 'the first interface defined will be current' do
181
181
  Vedeu.focus.must_equal('curium')
@@ -229,9 +229,9 @@ module Vedeu
229
229
  context 'when the named group exists' do
230
230
  let(:members) { Set['actinium', 'lanthanum'] }
231
231
 
232
- before {
232
+ before do
233
233
  Vedeu::Group.new(name: 'elements', members: ['lanthanum']).store
234
- }
234
+ end
235
235
 
236
236
  it {
237
237
  subject
@@ -294,14 +294,14 @@ module Vedeu
294
294
  end
295
295
 
296
296
  describe '#use' do
297
- before {
297
+ before do
298
298
  Vedeu.interface 'some_interface' do
299
299
  delay 0.75
300
300
  end
301
301
  Vedeu.interface 'other_interface' do
302
302
  delay use('some_interface').delay
303
303
  end
304
- }
304
+ end
305
305
  after { Vedeu.interfaces.reset }
306
306
 
307
307
  subject { instance.use('other_interface').delay }
@@ -41,7 +41,7 @@ module Vedeu
41
41
  }
42
42
 
43
43
  it { subject.must_be_instance_of(Vedeu::Views::Lines) }
44
- it { subject.first.must_be_instance_of(Vedeu::Views::Line) }
44
+ it { subject[0].must_be_instance_of(Vedeu::Views::Line) }
45
45
 
46
46
  context 'when the block is given' do
47
47
  end
@@ -70,7 +70,7 @@ module Vedeu
70
70
  }
71
71
 
72
72
  it { subject.must_be_instance_of(Vedeu::Views::Streams) }
73
- it { subject.first.must_be_instance_of(Vedeu::Views::Stream) }
73
+ it { subject[0].must_be_instance_of(Vedeu::Views::Stream) }
74
74
  end
75
75
 
76
76
  context 'when the block is not given' do
@@ -15,30 +15,6 @@ module Vedeu
15
15
  let(:described) { Vedeu::DSL::Use }
16
16
  let(:model_instance) { Vedeu::DSL::TestUseClass }
17
17
 
18
- # before {
19
- # Vedeu.interfaces.reset
20
- # Vedeu.interface('hydrogen') do
21
- # delay 0.75
22
- # end
23
- # Vedeu.interface('helium') do
24
- # duplicate('hydrogen')
25
- # end
26
- # }
27
-
28
- describe '#duplicate' do
29
- subject { model_instance.duplicate(_name) }
30
-
31
- context 'when the model exists' do
32
- # @todo Add more tests.
33
- # it { skip }
34
- end
35
-
36
- context 'when the model does not exist' do
37
- # @todo Add more tests.
38
- # it { skip }
39
- end
40
- end
41
-
42
18
  describe '#use' do
43
19
  context 'when the model exists' do
44
20
  # @todo Add more tests.
@@ -107,6 +107,15 @@ module Vedeu
107
107
  let(:args) {}
108
108
 
109
109
  subject { described.trigger(alias_name, *args) }
110
+
111
+ context 'when the alias name is registered' do
112
+ # @todo Add more tests.
113
+ # it { skip }
114
+ end
115
+
116
+ context 'when the alias name is not registered' do
117
+ it { subject.must_equal([]) }
118
+ end
110
119
  end
111
120
 
112
121
  end # EventAliases
@@ -5,10 +5,10 @@ module Vedeu
5
5
  describe Event do
6
6
 
7
7
  let(:described) { Vedeu::Event }
8
- let(:instance) { described.new(event_name, options, closure) }
8
+ let(:instance) { described.new(event_name, closure, options) }
9
9
  let(:event_name) { :some_event }
10
- let(:options) { {} }
11
10
  let(:closure) { proc { :event_triggered } }
11
+ let(:options) { {} }
12
12
 
13
13
  describe '.bind' do
14
14
  subject { described.bind(event_name, options) { :event_triggered } }
@@ -67,7 +67,7 @@ module Vedeu
67
67
 
68
68
  describe '#trigger' do
69
69
  it 'returns the result of calling the closure when debouncing' do
70
- event = Event.new(event_name, { debounce: 0.001 }, closure)
70
+ event = Event.new(event_name, closure, { debounce: 0.001 })
71
71
  event.trigger.must_equal(nil)
72
72
  sleep 0.0005
73
73
  event.trigger.must_equal(nil)
@@ -78,7 +78,7 @@ module Vedeu
78
78
  end
79
79
 
80
80
  it 'returns the result of calling the closure when throttling' do
81
- event = Event.new(event_name, { delay: 0.001 }, closure)
81
+ event = Event.new(event_name, closure, { delay: 0.001 })
82
82
  event.trigger.must_equal(:event_triggered)
83
83
  sleep 0.0005
84
84
  event.trigger.must_equal(nil)
@@ -87,7 +87,7 @@ module Vedeu
87
87
  end
88
88
 
89
89
  it 'returns the result of calling the closure with its arguments' do
90
- event = Event.new(event_name, options, closure)
90
+ event = Event.new(event_name, closure, options)
91
91
  event.trigger.must_equal(:event_triggered)
92
92
  end
93
93
  end