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
File without changes
@@ -2,7 +2,7 @@ module Vedeu
2
2
 
3
3
  module Templating
4
4
 
5
- # Converts an encoded string back into an object or objects.
5
+ # Converts an encoded string back into an object or collection of objects.
6
6
  #
7
7
  class Decoder
8
8
 
@@ -20,6 +20,8 @@ module Vedeu
20
20
  @data = data
21
21
  end
22
22
 
23
+ # Converts an encoded string back into an object or collection of objects.
24
+ #
23
25
  # @return [Object]
24
26
  def process
25
27
  demarshal
@@ -55,7 +57,7 @@ module Vedeu
55
57
  Base64.strict_decode64(unwrap)
56
58
  end
57
59
 
58
- # Removes '{{' and '}}' from the start and end of the data.
60
+ # Removes delimiters from the start and end of the data.
59
61
  #
60
62
  # @return [String]
61
63
  def unwrap
@@ -2,7 +2,7 @@ module Vedeu
2
2
 
3
3
  module Templating
4
4
 
5
- # Converts an object or objects into an encoded string.
5
+ # Converts an object or collection of objects into an encoded String.
6
6
  #
7
7
  class Encoder
8
8
 
@@ -20,6 +20,8 @@ module Vedeu
20
20
  @data = data
21
21
  end
22
22
 
23
+ # Converts an object or collection of objects into an encoded String.
24
+ #
23
25
  # @return [String]
24
26
  def process
25
27
  wrap
@@ -33,7 +35,7 @@ module Vedeu
33
35
 
34
36
  private
35
37
 
36
- # Adds '{{' and '}}' to the start and end of the data.
38
+ # Adds delimiters to the start and end of the data.
37
39
  #
38
40
  # @return [String]
39
41
  def wrap
@@ -23,7 +23,9 @@ module Vedeu
23
23
  Vedeu::Templating::Decoder.process(stream)
24
24
 
25
25
  else
26
- Vedeu::Stream.new(value: stream)
26
+ Vedeu::Stream.new(colour: default_colour,
27
+ style: default_style,
28
+ value: stream)
27
29
 
28
30
  end
29
31
  end
@@ -46,10 +48,41 @@ module Vedeu
46
48
 
47
49
  private
48
50
 
51
+ # @return [Vedeu::Colour|Hash<Symbol => Symbol>]
52
+ def default_colour
53
+ if interface?
54
+ interface.colour
55
+
56
+ else
57
+ {
58
+ background: :default,
59
+ foreground: :default,
60
+ }
61
+
62
+ end
63
+ end
64
+
65
+ # @return [Symbol]
66
+ def default_style
67
+ if interface?
68
+ interface.style
69
+
70
+ else
71
+ :normal
72
+
73
+ end
74
+ end
75
+
76
+ # @return [Vedeu::Interface]
77
+ def interface
78
+ Vedeu.interfaces.by_name(options[:name]) if options[:name]
79
+ end
80
+ alias_method :interface?, :interface
81
+
49
82
  # @param line [String]
50
83
  # @return [Array<String>]
51
84
  def streams_for(line)
52
- line.split(/({{.*}})/)
85
+ line.split(/({{\s*[^}]+\s*}})/)
53
86
  end
54
87
 
55
88
  # @return [Array<String>]
data/lib/vedeu/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # The current version of Vedeu.
4
- VERSION = '0.5.0'
4
+ VERSION = '0.5.1'
5
5
 
6
6
  end
@@ -9,7 +9,7 @@ module Vedeu
9
9
  let(:object) {}
10
10
 
11
11
  describe '#initialize' do
12
- it { instance.must_be_instance_of(Vedeu::ApplicationView) }
12
+ it { instance.must_be_instance_of(described) }
13
13
  it { instance.instance_variable_get('@object').must_equal(object) }
14
14
  end
15
15
 
@@ -34,6 +34,8 @@ module Vedeu
34
34
  with(:some_controller, 'Vedeu::ControllerTestKlass')
35
35
  subject
36
36
  }
37
+
38
+ it { subject.must_be_instance_of(Hash) }
37
39
  end
38
40
 
39
41
  describe '.action' do
@@ -46,6 +48,8 @@ module Vedeu
46
48
  with(:some_controller, :other_action)
47
49
  subject
48
50
  }
51
+
52
+ it { subject.must_be_instance_of(Array) }
49
53
  end
50
54
 
51
55
  end # ClassMethods
@@ -38,6 +38,8 @@ module Vedeu
38
38
  Vedeu::Bindings::System.expects(:setup!)
39
39
  subject
40
40
  }
41
+
42
+ it { subject.must_equal(true) }
41
43
  end
42
44
 
43
45
  end # Bindings
@@ -113,18 +113,13 @@ module Vedeu
113
113
  let(:bottom) { false }
114
114
  let(:left) { false }
115
115
  let(:right) { false }
116
+ let(:geometry) {
117
+ Vedeu::Geometry.new(name: 'Border#bxbxnbybyn', x: 2, xn: 6, y: 2, yn: 6)
118
+ }
116
119
 
117
- before do
118
- Vedeu.interface('Border#bxbxnbybyn') do
119
- geometry do
120
- x 2
121
- xn 6
122
- y 2
123
- yn 6
124
- end
125
- end
126
- end
127
- after { Vedeu.interfaces.reset }
120
+ before {
121
+ Vedeu.geometries.stubs(:by_name).returns(geometry)
122
+ }
128
123
 
129
124
  describe '#bx' do
130
125
  subject { instance.bx }
@@ -216,14 +211,12 @@ module Vedeu
216
211
  end
217
212
 
218
213
  describe '#width' do
219
- before do
220
- Vedeu.interface 'borders' do
221
- geometry do
222
- width 8
223
- end
224
- end
225
- end
226
- after { Vedeu.interfaces.reset }
214
+ let(:geometry) {
215
+ Vedeu::Geometry.new(name: 'borders', width: 8)
216
+ }
217
+ before {
218
+ Vedeu.geometries.stubs(:by_name).returns(geometry)
219
+ }
227
220
 
228
221
  subject { instance.width }
229
222
 
@@ -273,14 +266,12 @@ module Vedeu
273
266
  end
274
267
 
275
268
  describe '#height' do
276
- before do
277
- Vedeu.interface 'borders' do
278
- geometry do
279
- height 5
280
- end
281
- end
282
- end
283
- after { Vedeu.interfaces.reset }
269
+ let(:geometry) {
270
+ Vedeu::Geometry.new(name: 'borders', height: 5)
271
+ }
272
+ before {
273
+ Vedeu.geometries.stubs(:by_name).returns(geometry)
274
+ }
284
275
 
285
276
  subject { instance.height }
286
277
 
@@ -441,19 +432,16 @@ module Vedeu
441
432
  let(:left) { false }
442
433
  let(:right) { false }
443
434
  let(:visibility) { true }
444
-
445
- before do
446
- Vedeu.interface('Border#render') do
447
- geometry do
448
- x 1
449
- xn 4
450
- y 1
451
- yn 4
452
- end
453
- visible(visibility)
454
- end
455
- end
456
- after { Vedeu.interfaces.reset }
435
+ let(:geometry) {
436
+ Vedeu::Geometry.new(name: 'Border#render', x: 1, xn: 4, y: 1, yn: 4)
437
+ }
438
+ let(:interface) {
439
+ Vedeu::Interface.new(visible: visibility)
440
+ }
441
+ before {
442
+ Vedeu.interfaces.stubs(:by_name).returns(interface)
443
+ Vedeu.geometries.stubs(:by_name).returns(geometry)
444
+ }
457
445
 
458
446
  subject { instance.render }
459
447
 
@@ -6,8 +6,6 @@ module Vedeu
6
6
 
7
7
  let(:described) { Vedeu::Borders }
8
8
 
9
- after { Vedeu.borders.reset! }
10
-
11
9
  it { described.must_respond_to(:borders) }
12
10
 
13
11
  end # Borders
@@ -6,10 +6,7 @@ module Vedeu
6
6
 
7
7
  let(:described) { Vedeu::RenderBorder }
8
8
  let(:instance) { described.new(border) }
9
- let(:border) {
10
- Vedeu::Border.new(enabled: enabled,
11
- name: _name).store
12
- }
9
+ let(:border) { Vedeu::Border.new(enabled: enabled, name: _name) }
13
10
  let(:visible) { false }
14
11
  let(:enabled) { false }
15
12
  let(:_name) { 'Vedeu::RenderBorder' }
@@ -22,15 +19,16 @@ module Vedeu
22
19
  end
23
20
 
24
21
  describe '#render' do
25
- before do
26
- Vedeu::Geometry.new(name: _name, x: 1, xn: 3, y: 1, yn: 3).store
27
- Vedeu::Interface.new(name: _name, visible: visible).store
28
- end
29
- after do
30
- Vedeu.geometries.reset!
31
- Vedeu.interfaces.reset!
32
- Vedeu.borders.reset!
33
- end
22
+ let(:geometry) {
23
+ Vedeu::Geometry.new(name: _name, x: 1, xn: 3, y: 1, yn: 3)
24
+ }
25
+ let(:interface) {
26
+ Vedeu::Interface.new(name: _name, visible: visible)
27
+ }
28
+ before {
29
+ Vedeu.geometries.stubs(:by_name).returns(geometry)
30
+ Vedeu.interfaces.stubs(:by_name).returns(interface)
31
+ }
34
32
 
35
33
  subject { instance.render }
36
34
 
@@ -20,11 +20,6 @@ module Vedeu
20
20
  let(:previous) {}
21
21
  let(:interface) {}
22
22
 
23
- before do
24
- Vedeu.stubs(:trigger)
25
- end
26
- after { Vedeu.interfaces.reset }
27
-
28
23
  describe '#initialize' do
29
24
  it { instance.must_be_instance_of(described) }
30
25
  it { instance.instance_variable_get('@name').must_equal(_name) }
@@ -62,6 +57,9 @@ module Vedeu
62
57
  end
63
58
  }
64
59
 
60
+ before { Vedeu.stubs(:trigger) }
61
+ after { Vedeu.interfaces.reset }
62
+
65
63
  subject { instance.add(content) }
66
64
 
67
65
  it { subject.must_equal(true) }
@@ -76,6 +74,9 @@ module Vedeu
76
74
  end
77
75
 
78
76
  describe '#back?' do
77
+ before { Vedeu.stubs(:trigger) }
78
+ after { Vedeu.interfaces.reset }
79
+
79
80
  subject { instance.back? }
80
81
 
81
82
  context 'with content' do
@@ -96,6 +97,9 @@ module Vedeu
96
97
  end
97
98
 
98
99
  describe '#front?' do
100
+ before { Vedeu.stubs(:trigger) }
101
+ after { Vedeu.interfaces.reset }
102
+
99
103
  subject { instance.front? }
100
104
 
101
105
  context 'with content' do
@@ -115,6 +119,9 @@ module Vedeu
115
119
  end
116
120
 
117
121
  describe '#previous?' do
122
+ before { Vedeu.stubs(:trigger) }
123
+ after { Vedeu.interfaces.reset }
124
+
118
125
  subject { instance.previous? }
119
126
 
120
127
  context 'with content' do
@@ -31,11 +31,11 @@ module Vedeu
31
31
  let(:example_model) { Vedeu::TestInterfaceModel }
32
32
  let(:example_instance) { example_model.new }
33
33
 
34
- before do
34
+ before {
35
35
  example_instance.store
36
36
 
37
37
  Vedeu::Refresh.stubs(:by_name)
38
- end
38
+ }
39
39
  after { Vedeu.interfaces.reset }
40
40
 
41
41
  describe '#store_immediate' do
@@ -10,26 +10,26 @@ module Vedeu
10
10
  let(:instance) { described.new(_name) }
11
11
  let(:_name) { 'my_first_app' }
12
12
 
13
- before do
14
- FileUtils.stubs(:cp_r)
15
- FileUtils.stubs(:mkdir)
16
- end
17
-
18
13
  describe '#initialize' do
19
14
  it { instance.must_be_instance_of(described) }
20
15
  it { instance.instance_variable_get('@name').must_equal(_name) }
21
16
  end
22
17
 
23
18
  describe '.generate' do
24
- it { described.must_respond_to(:generate) }
25
- end
19
+ # before {
20
+ # FileUtils.stubs(:cp_r)
21
+ # FileUtils.stubs(:mkdir)
22
+ # }
26
23
 
27
- describe '#generate' do
28
- subject { instance.generate }
24
+ subject { instance.generate(_name) }
29
25
 
30
26
  # @todo Add more tests.
31
27
  end
32
28
 
29
+ describe '#generate' do
30
+ it { instance.must_respond_to(:generate) }
31
+ end
32
+
33
33
  end # Application
34
34
 
35
35
  end # Generator
@@ -10,22 +10,25 @@ module Vedeu
10
10
  let(:instance) { described.new(_name) }
11
11
  let(:_name) { 'my_first_view' }
12
12
 
13
- before do
14
- FileUtils.stubs(:cp_r)
15
- FileUtils.stubs(:mkdir)
16
- end
17
-
18
13
  describe '#initialize' do
19
14
  it { instance.must_be_instance_of(described) }
20
15
  it { instance.instance_variable_get('@name').must_equal(_name) }
21
16
  end
22
17
 
23
18
  describe '.generate' do
24
- it { described.must_respond_to(:generate) }
19
+ # before {
20
+ # FileUtils.stubs(:cp_r)
21
+ # FileUtils.stubs(:mkdir)
22
+ # }
23
+
24
+ subject { described.generate(_name) }
25
+
26
+ # @todo
27
+ # it { skip }
25
28
  end
26
29
 
27
30
  describe '#generate' do
28
- subject { instance.generate }
31
+ it { described.must_respond_to(:generate) }
29
32
  end
30
33
 
31
34
  end # View
@@ -12,10 +12,10 @@ module Vedeu
12
12
  describe '#new' do
13
13
  let(:_name) { 'app_name' }
14
14
 
15
- before do
15
+ before {
16
16
  instance.stubs(:say)
17
17
  Vedeu::Generator::Application.stubs(:generate).returns('')
18
- end
18
+ }
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 do
31
+ before {
32
32
  instance.stubs(:say)
33
33
  Vedeu::Generator::View.stubs(:generate).returns('')
34
- end
34
+ }
35
35
 
36
36
  subject { instance.view(_name) }
37
37