vedeu 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -5
  3. data/docs/events.md +4 -0
  4. data/examples/borders_app.rb +43 -39
  5. data/examples/focus_app.rb +4 -0
  6. data/examples/hello_world.rb +10 -3
  7. data/lib/vedeu/all.rb +1 -2
  8. data/lib/vedeu/api.rb +4 -1
  9. data/lib/vedeu/application/application_controller.rb +24 -0
  10. data/lib/vedeu/application/application_view.rb +9 -9
  11. data/lib/vedeu/bindings.rb +2 -0
  12. data/lib/vedeu/bindings/movement.rb +9 -9
  13. data/lib/vedeu/bindings/system.rb +3 -3
  14. data/lib/vedeu/buffers/buffer.rb +4 -9
  15. data/lib/vedeu/buffers/display_buffer.rb +2 -48
  16. data/lib/vedeu/cli/generator/application.rb +6 -0
  17. data/lib/vedeu/cli/generator/templates/application/.ruby-version +1 -0
  18. data/lib/vedeu/cli/generator/templates/application/app/controllers/name.erb +2 -11
  19. data/lib/vedeu/configuration/api.rb +6 -0
  20. data/lib/vedeu/configuration/configuration.rb +6 -0
  21. data/lib/vedeu/cursor/cursor.rb +49 -15
  22. data/lib/vedeu/cursor/move.rb +2 -2
  23. data/lib/vedeu/cursor/refresh_cursor.rb +2 -7
  24. data/lib/vedeu/distributed/server.rb +7 -21
  25. data/lib/vedeu/dsl/view.rb +31 -6
  26. data/lib/vedeu/internal_api.rb +7 -0
  27. data/lib/vedeu/log/log.rb +5 -2
  28. data/lib/vedeu/models/escape.rb +24 -6
  29. data/lib/vedeu/models/interface.rb +2 -14
  30. data/lib/vedeu/null/buffer.rb +7 -21
  31. data/lib/vedeu/null/generic.rb +5 -16
  32. data/lib/vedeu/null/interface.rb +6 -18
  33. data/lib/vedeu/runtime/bootstrap.rb +1 -1
  34. data/lib/vedeu/runtime/flags.rb +57 -0
  35. data/lib/vedeu/runtime/router.rb +2 -2
  36. data/lib/vedeu/version.rb +2 -1
  37. data/test/lib/vedeu/api_test.rb +1 -0
  38. data/test/lib/vedeu/application/application_controller_test.rb +26 -2
  39. data/test/lib/vedeu/application/application_view_test.rb +9 -4
  40. data/test/lib/vedeu/bindings_test.rb +9 -0
  41. data/test/lib/vedeu/borders/border_test.rb +25 -42
  42. data/test/lib/vedeu/buffers/display_buffer_test.rb +0 -10
  43. data/test/lib/vedeu/configuration/api_test.rb +7 -1
  44. data/test/lib/vedeu/configuration/cli_test.rb +0 -1
  45. data/test/lib/vedeu/configuration/configuration_test.rb +16 -0
  46. data/test/lib/vedeu/cursor/cursor_test.rb +122 -4
  47. data/test/lib/vedeu/dsl/view_test.rb +2 -2
  48. data/test/lib/vedeu/internal_api_test.rb +2 -0
  49. data/test/lib/vedeu/models/escape_test.rb +16 -6
  50. data/test/lib/vedeu/models/focus_test.rb +2 -1
  51. data/test/lib/vedeu/models/interface_test.rb +9 -5
  52. data/test/lib/vedeu/null/buffer_test.rb +7 -25
  53. data/test/lib/vedeu/null/generic_test.rb +6 -20
  54. data/test/lib/vedeu/null/interface_test.rb +8 -14
  55. data/test/lib/vedeu/output/compressor_test.rb +4 -4
  56. data/test/lib/vedeu/output/renderers_test.rb +1 -1
  57. data/test/lib/vedeu/runtime/flags_test.rb +47 -0
  58. data/test/lib/vedeu/runtime/router_test.rb +4 -4
  59. data/test/test_helper.rb +2 -0
  60. metadata +6 -10
  61. data/examples/geometry_app.rb +0 -147
  62. data/examples/panel_app.rb +0 -71
  63. data/lib/vedeu/geometry/index_position.rb +0 -85
  64. data/lib/vedeu/geometry/position_validator.rb +0 -69
  65. data/test/lib/vedeu/geometry/index_position_test.rb +0 -130
  66. data/test/lib/vedeu/geometry/position_validator_test.rb +0 -149
@@ -20,12 +20,12 @@ module Vedeu
20
20
  it { subject.must_be_instance_of(Vedeu::Interface) }
21
21
 
22
22
  context 'when the block is not given' do
23
- subject { described.interface }
23
+ subject { described.interface('flourine') }
24
24
 
25
25
  it { proc { subject }.must_raise(InvalidSyntax) }
26
26
  end
27
27
 
28
- context 'when the name was not set' do
28
+ context 'when the name is not given' do
29
29
  subject {
30
30
  described.interface('') do
31
31
  # ...
@@ -16,6 +16,8 @@ module Vedeu
16
16
  it { Vedeu.must_respond_to(:interfaces) }
17
17
  it { Vedeu.must_respond_to(:keymaps) }
18
18
  it { Vedeu.must_respond_to(:menus) }
19
+ it { Vedeu.must_respond_to(:ready!) }
20
+ it { Vedeu.must_respond_to(:ready?) }
19
21
  it { Vedeu.must_respond_to(:renderer) }
20
22
  it { Vedeu.must_respond_to(:renderers) }
21
23
  it { Vedeu.must_respond_to(:resize) }
@@ -4,9 +4,16 @@ module Vedeu
4
4
 
5
5
  describe Escape do
6
6
 
7
- let(:described) { Vedeu::Escape }
8
- let(:instance) { described.new(_value) }
9
- let(:_value) { "\e[?25h" }
7
+ let(:described) { Vedeu::Escape }
8
+ let(:instance) { described.new(attributes) }
9
+ let(:attributes) {
10
+ {
11
+ value: _value,
12
+ position: position,
13
+ }
14
+ }
15
+ let(:_value) { "\e[?25h" }
16
+ let(:position) { [2, 6] }
10
17
 
11
18
  describe '#initialize' do
12
19
  it { instance.must_be_instance_of(described) }
@@ -36,13 +43,13 @@ module Vedeu
36
43
  describe '#inspect' do
37
44
  it { instance.inspect.must_equal(
38
45
  "<Vedeu::Escape '" \
39
- "\\e[?25h" \
46
+ "\\e[2;6H\\e[?25h" \
40
47
  "'>"
41
48
  ) }
42
49
  end
43
50
 
44
51
  describe '#position' do
45
- it { instance.position.must_equal('') }
52
+ it { instance.position.must_be_instance_of(Vedeu::Position) }
46
53
  end
47
54
 
48
55
  describe '#style' do
@@ -51,8 +58,11 @@ module Vedeu
51
58
 
52
59
  describe '#value' do
53
60
  it { instance.value.must_be_instance_of(String) }
61
+ end
62
+
63
+ describe '#to_s' do
64
+ subject { instance.to_s }
54
65
 
55
- it { instance.must_respond_to(:to_s) }
56
66
  it { instance.must_respond_to(:to_str) }
57
67
  end
58
68
 
@@ -9,6 +9,8 @@ module Vedeu
9
9
  before {
10
10
  Focus.reset
11
11
  Vedeu.interfaces.reset
12
+
13
+ Vedeu.stubs(:trigger)
12
14
  }
13
15
  after {
14
16
  Vedeu::Focus.reset
@@ -188,7 +190,6 @@ module Vedeu
188
190
 
189
191
  describe '#prev_item' do
190
192
  it 'the previous interface is focussed when the method is called' do
191
-
192
193
  Focus.add('thallium')
193
194
  Focus.add('lead')
194
195
  Focus.add('bismuth')
@@ -76,12 +76,14 @@ module Vedeu
76
76
  end
77
77
 
78
78
  describe '#hide' do
79
- before { Vedeu::Output.stubs(:render) }
79
+ let(:buffer) { Vedeu::Buffer.new }
80
+
81
+ before { Vedeu.buffers.stubs(:by_name).returns(buffer) }
80
82
 
81
83
  subject { instance.hide }
82
84
 
83
85
  it {
84
- Vedeu::Output.expects(:render)
86
+ Vedeu.buffers.by_name('hydrogen').expects(:hide)
85
87
  subject
86
88
  }
87
89
  end
@@ -160,7 +162,7 @@ module Vedeu
160
162
  subject
161
163
  }
162
164
 
163
- it { subject.must_equal([:clear, :view, :border]) }
165
+ it { subject.must_equal([nil, :clear, :view, :border, nil]) }
164
166
  end
165
167
 
166
168
  context 'when the interface is not visible' do
@@ -171,12 +173,14 @@ module Vedeu
171
173
  end
172
174
 
173
175
  describe '#show' do
174
- before { Vedeu::Output.stubs(:render) }
176
+ let(:buffer) { Vedeu::Buffer.new }
177
+
178
+ before { Vedeu.buffers.stubs(:by_name).returns(buffer) }
175
179
 
176
180
  subject { instance.show }
177
181
 
178
182
  it {
179
- Vedeu::Output.expects(:render)
183
+ Vedeu.buffers.by_name('hydrogen').expects(:show)
180
184
  subject
181
185
  }
182
186
  end
@@ -23,16 +23,16 @@ module Vedeu
23
23
  it { instance.instance_variable_get('@name').must_equal(_name) }
24
24
  end
25
25
 
26
- describe '#clear' do
27
- subject { instance.clear }
26
+ describe '#null' do
27
+ subject { instance.null }
28
28
 
29
29
  it { subject.must_be_instance_of(NilClass) }
30
- end
31
-
32
- describe '#hide' do
33
- subject { instance.hide }
34
30
 
35
- it { subject.must_be_instance_of(NilClass) }
31
+ it { instance.must_respond_to(:clear) }
32
+ it { instance.must_respond_to(:hide) }
33
+ it { instance.must_respond_to(:render) }
34
+ it { instance.must_respond_to(:show) }
35
+ it { instance.must_respond_to(:toggle) }
36
36
  end
37
37
 
38
38
  describe '#null?' do
@@ -41,24 +41,6 @@ module Vedeu
41
41
  it { subject.must_be_instance_of(TrueClass) }
42
42
  end
43
43
 
44
- describe '#render' do
45
- subject { instance.render }
46
-
47
- it { subject.must_be_instance_of(NilClass) }
48
- end
49
-
50
- describe '#show' do
51
- subject { instance.show }
52
-
53
- it { subject.must_be_instance_of(NilClass) }
54
- end
55
-
56
- describe '#toggle' do
57
- subject { instance.toggle }
58
-
59
- it { subject.must_be_instance_of(NilClass) }
60
- end
61
-
62
44
  end # Buffer
63
45
 
64
46
  end # Null
@@ -26,16 +26,14 @@ module Vedeu
26
26
  }
27
27
  end
28
28
 
29
- describe '#add' do
30
- subject { instance.add }
31
-
32
- it { subject.must_be_instance_of(NilClass) }
33
- end
34
-
35
- describe '#colour' do
36
- subject { instance.colour }
29
+ describe '#null' do
30
+ subject { instance.null }
37
31
 
38
32
  it { subject.must_be_instance_of(NilClass) }
33
+ it { instance.must_respond_to(:add) }
34
+ it { instance.must_respond_to(:colour) }
35
+ it { instance.must_respond_to(:parent) }
36
+ it { instance.must_respond_to(:style) }
39
37
  end
40
38
 
41
39
  describe '#null?' do
@@ -44,24 +42,12 @@ module Vedeu
44
42
  it { subject.must_be_instance_of(TrueClass) }
45
43
  end
46
44
 
47
- describe '#parent' do
48
- subject { instance.parent }
49
-
50
- it { subject.must_be_instance_of(NilClass) }
51
- end
52
-
53
45
  describe '#store' do
54
46
  subject { instance.store }
55
47
 
56
48
  it { subject.must_be_instance_of(described) }
57
49
  end
58
50
 
59
- describe '#style' do
60
- subject { instance.style }
61
-
62
- it { subject.must_be_instance_of(NilClass) }
63
- end
64
-
65
51
  describe '#visible' do
66
52
  subject { instance.visible }
67
53
 
@@ -31,30 +31,24 @@ module Vedeu
31
31
  it { instance.must_respond_to(:visible?) }
32
32
  end
33
33
 
34
- describe '#hide' do
35
- it { instance.hide.must_be_instance_of(NilClass) }
34
+ describe '#null' do
35
+ it { instance.null.must_be_instance_of(NilClass) }
36
+
37
+ it { instance.must_respond_to(:hide) }
38
+ it { instance.must_respond_to(:parent) }
39
+ it { instance.must_respond_to(:show) }
40
+ it { instance.must_respond_to(:toggle) }
41
+ it { instance.must_respond_to(:zindex) }
36
42
  end
37
43
 
38
44
  describe '#null?' do
39
45
  it { instance.null?.must_be_instance_of(TrueClass) }
40
46
  end
41
47
 
42
- describe '#parent' do
43
- it { instance.parent.must_be_instance_of(NilClass) }
44
- end
45
-
46
- describe '#show' do
47
- it { instance.show.must_be_instance_of(NilClass) }
48
- end
49
-
50
48
  describe '#store' do
51
49
  it { instance.store.must_be_instance_of(Vedeu::Null::Interface) }
52
50
  end
53
51
 
54
- describe '#toggle' do
55
- it { instance.toggle.must_be_instance_of(NilClass) }
56
- end
57
-
58
52
  end # Interface
59
53
 
60
54
  end # Null
@@ -54,12 +54,12 @@ module Vedeu
54
54
  let(:output) {
55
55
  [
56
56
  Vedeu::Char.new(value: 'N'),
57
- Vedeu::Escape.new("\e[?25l"),
57
+ Vedeu::Escape.new(value: "\e[?25l"),
58
58
  Vedeu::Char.new(value: 't'),
59
59
  ]
60
60
  }
61
61
  it 'converts the non-Vedeu::Char elements into String elements' do
62
- subject.must_equal("N\e[?25lt")
62
+ subject.must_equal("N\e[1;1H\e[?25lt")
63
63
  end
64
64
  end
65
65
  end
@@ -102,12 +102,12 @@ module Vedeu
102
102
  let(:output) {
103
103
  [
104
104
  Vedeu::Char.new(value: 'N'),
105
- Vedeu::Escape.new("\e[?25l"),
105
+ Vedeu::Escape.new(value: "\e[?25l"),
106
106
  Vedeu::Char.new(value: 't'),
107
107
  ]
108
108
  }
109
109
  it 'converts the non-Vedeu::Char elements into String elements' do
110
- subject.must_equal("N\e[?25lt")
110
+ subject.must_equal("N\e[1;1H\e[?25lt")
111
111
  end
112
112
  end
113
113
  end
@@ -72,7 +72,7 @@ module Vedeu
72
72
  }
73
73
 
74
74
  context 'when there is content' do
75
- let(:output) { Vedeu::Escape.new(Vedeu::Esc.hide_cursor) }
75
+ let(:output) { Vedeu::Escape.new(value: Vedeu::Esc.hide_cursor) }
76
76
 
77
77
  it { subject.must_be_instance_of(Vedeu::Escape) }
78
78
  end
@@ -0,0 +1,47 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ describe Flags do
6
+
7
+ let(:described) { Vedeu::Flags }
8
+
9
+ describe '.ready!' do
10
+ it { described.ready!.must_equal(true) }
11
+ end
12
+
13
+ describe '.ready?' do
14
+ context 'when Vedeu has triggered the :_initialize_ event' do
15
+ before do
16
+ described.reset!
17
+ described.ready!
18
+ end
19
+
20
+ it { described.ready?.must_equal(true) }
21
+ end
22
+
23
+ context 'when Vedeu has not triggered the :_initialize_ event' do
24
+ before do
25
+ described.reset!
26
+ end
27
+
28
+ it { described.ready?.must_equal(false) }
29
+ end
30
+ end
31
+
32
+ describe '.reset!' do
33
+ subject { described.reset! }
34
+
35
+ it {
36
+ subject
37
+ described.ready?.must_equal(false)
38
+ }
39
+ end
40
+
41
+ describe '#reset!' do
42
+ it { described.instance.must_respond_to(:reset!) }
43
+ end
44
+
45
+ end # Flags
46
+
47
+ end # Vedeu
@@ -2,12 +2,12 @@ require 'test_helper'
2
2
 
3
3
  module Vedeu
4
4
 
5
- class SomeController
5
+ class SomeController < Vedeu::ApplicationController
6
6
 
7
- def some_action(customer_id:, product_id:)
7
+ def some_action
8
8
  {
9
- customer: { name: 'Gavin Laking', customer_id: customer_id },
10
- basket: { product_ids: [product_id] }
9
+ customer: { name: 'Gavin Laking', customer_id: params[:customer_id] },
10
+ basket: { product_ids: [params[:product_id]] }
11
11
  }
12
12
  end
13
13
 
data/test/test_helper.rb CHANGED
@@ -91,6 +91,8 @@ require 'support/helpers/model_test_class'
91
91
  def test_configuration
92
92
  Vedeu::Configuration.reset!
93
93
 
94
+ Vedeu.ready!
95
+
94
96
  Vedeu.configure do
95
97
  colour_mode 16_777_216
96
98
  # adds ~40ms to test run speed
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vedeu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-30 00:00:00.000000000 Z
11
+ date: 2015-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard
@@ -245,11 +245,9 @@ files:
245
245
  - examples/configuration_app.rb
246
246
  - examples/drb_app.rb
247
247
  - examples/focus_app.rb
248
- - examples/geometry_app.rb
249
248
  - examples/hello_world.rb
250
249
  - examples/material_colours_app.rb
251
250
  - examples/material_colours_app_20150721.svg
252
- - examples/panel_app.rb
253
251
  - examples/typed_commands/command.erb
254
252
  - examples/typed_commands/output.erb
255
253
  - examples/typed_commands/status.erb
@@ -284,6 +282,7 @@ files:
284
282
  - lib/vedeu/cli/generator/application.rb
285
283
  - lib/vedeu/cli/generator/helpers.rb
286
284
  - lib/vedeu/cli/generator/templates/application/.gitignore
285
+ - lib/vedeu/cli/generator/templates/application/.ruby-version
287
286
  - lib/vedeu/cli/generator/templates/application/Gemfile
288
287
  - lib/vedeu/cli/generator/templates/application/LICENSE.txt
289
288
  - lib/vedeu/cli/generator/templates/application/README.md
@@ -362,10 +361,8 @@ files:
362
361
  - lib/vedeu/geometry/geometries.rb
363
362
  - lib/vedeu/geometry/geometry.rb
364
363
  - lib/vedeu/geometry/grid.rb
365
- - lib/vedeu/geometry/index_position.rb
366
364
  - lib/vedeu/geometry/position.rb
367
365
  - lib/vedeu/geometry/position_index.rb
368
- - lib/vedeu/geometry/position_validator.rb
369
366
  - lib/vedeu/input/input.rb
370
367
  - lib/vedeu/input/key.rb
371
368
  - lib/vedeu/input/keymap.rb
@@ -438,6 +435,7 @@ files:
438
435
  - lib/vedeu/repositories/store.rb
439
436
  - lib/vedeu/runtime/application.rb
440
437
  - lib/vedeu/runtime/bootstrap.rb
438
+ - lib/vedeu/runtime/flags.rb
441
439
  - lib/vedeu/runtime/launcher.rb
442
440
  - lib/vedeu/runtime/main_loop.rb
443
441
  - lib/vedeu/runtime/router.rb
@@ -522,10 +520,8 @@ files:
522
520
  - test/lib/vedeu/geometry/geometries_test.rb
523
521
  - test/lib/vedeu/geometry/geometry_test.rb
524
522
  - test/lib/vedeu/geometry/grid_test.rb
525
- - test/lib/vedeu/geometry/index_position_test.rb
526
523
  - test/lib/vedeu/geometry/position_index_test.rb
527
524
  - test/lib/vedeu/geometry/position_test.rb
528
- - test/lib/vedeu/geometry/position_validator_test.rb
529
525
  - test/lib/vedeu/input/input_test.rb
530
526
  - test/lib/vedeu/input/key_test.rb
531
527
  - test/lib/vedeu/input/keymap_test.rb
@@ -596,6 +592,7 @@ files:
596
592
  - test/lib/vedeu/repositories_test.rb
597
593
  - test/lib/vedeu/runtime/application_test.rb
598
594
  - test/lib/vedeu/runtime/bootstrap_test.rb
595
+ - test/lib/vedeu/runtime/flags_test.rb
599
596
  - test/lib/vedeu/runtime/launcher_test.rb
600
597
  - test/lib/vedeu/runtime/main_loop_test.rb
601
598
  - test/lib/vedeu/runtime/router_test.rb
@@ -710,10 +707,8 @@ test_files:
710
707
  - test/lib/vedeu/geometry/geometries_test.rb
711
708
  - test/lib/vedeu/geometry/geometry_test.rb
712
709
  - test/lib/vedeu/geometry/grid_test.rb
713
- - test/lib/vedeu/geometry/index_position_test.rb
714
710
  - test/lib/vedeu/geometry/position_index_test.rb
715
711
  - test/lib/vedeu/geometry/position_test.rb
716
- - test/lib/vedeu/geometry/position_validator_test.rb
717
712
  - test/lib/vedeu/input/input_test.rb
718
713
  - test/lib/vedeu/input/key_test.rb
719
714
  - test/lib/vedeu/input/keymap_test.rb
@@ -784,6 +779,7 @@ test_files:
784
779
  - test/lib/vedeu/repositories_test.rb
785
780
  - test/lib/vedeu/runtime/application_test.rb
786
781
  - test/lib/vedeu/runtime/bootstrap_test.rb
782
+ - test/lib/vedeu/runtime/flags_test.rb
787
783
  - test/lib/vedeu/runtime/launcher_test.rb
788
784
  - test/lib/vedeu/runtime/main_loop_test.rb
789
785
  - test/lib/vedeu/runtime/router_test.rb