vedeu 0.6.10 → 0.6.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vedeu/all.rb +17 -103
  3. data/lib/vedeu/api/all.rb +15 -0
  4. data/lib/vedeu/api/internal.rb +4 -0
  5. data/lib/vedeu/application/all.rb +6 -0
  6. data/lib/vedeu/bindings/all.rb +32 -0
  7. data/lib/vedeu/bindings/bindings.rb +0 -14
  8. data/lib/vedeu/bindings/refresh.rb +8 -2
  9. data/lib/vedeu/bindings/system.rb +1 -0
  10. data/lib/vedeu/borders/border.rb +1 -1
  11. data/lib/vedeu/borders/repository.rb +1 -1
  12. data/lib/vedeu/buffers/buffer.rb +2 -4
  13. data/lib/vedeu/buffers/repository.rb +1 -1
  14. data/lib/vedeu/colours/background.rb +1 -1
  15. data/lib/vedeu/colours/backgrounds.rb +1 -1
  16. data/lib/vedeu/colours/foreground.rb +1 -1
  17. data/lib/vedeu/colours/foregrounds.rb +1 -1
  18. data/lib/vedeu/colours/translator.rb +4 -3
  19. data/lib/vedeu/configuration/api.rb +2 -1
  20. data/lib/vedeu/configuration/cli.rb +1 -1
  21. data/lib/vedeu/cursors/cursor.rb +26 -26
  22. data/lib/vedeu/cursors/repository.rb +1 -1
  23. data/lib/vedeu/distributed/all.rb +16 -0
  24. data/lib/vedeu/distributed/test_application.rb +3 -3
  25. data/lib/vedeu/dsl/all.rb +22 -0
  26. data/lib/vedeu/dsl/composition.rb +43 -40
  27. data/lib/vedeu/dsl/dsl.rb +6 -3
  28. data/lib/vedeu/dsl/group.rb +23 -16
  29. data/lib/vedeu/dsl/interface.rb +48 -38
  30. data/lib/vedeu/dsl/keymap.rb +6 -7
  31. data/lib/vedeu/dsl/line.rb +6 -3
  32. data/lib/vedeu/dsl/stream.rb +2 -1
  33. data/lib/vedeu/editor/cursor.rb +1 -3
  34. data/lib/vedeu/editor/document.rb +4 -5
  35. data/lib/vedeu/editor/documents.rb +1 -1
  36. data/lib/vedeu/editor/line.rb +2 -3
  37. data/lib/vedeu/editor/lines.rb +2 -3
  38. data/lib/vedeu/esc/all.rb +14 -0
  39. data/lib/vedeu/esc/colours.rb +8 -4
  40. data/lib/vedeu/esc/esc.rb +89 -84
  41. data/lib/vedeu/events/aliases.rb +1 -2
  42. data/lib/vedeu/events/collection.rb +1 -1
  43. data/lib/vedeu/events/event.rb +1 -1
  44. data/lib/vedeu/events/repository.rb +1 -1
  45. data/lib/vedeu/events/trigger.rb +11 -9
  46. data/lib/vedeu/geometry/dimension.rb +1 -3
  47. data/lib/vedeu/geometry/generic_coordinate.rb +1 -3
  48. data/lib/vedeu/geometry/geometry.rb +1 -1
  49. data/lib/vedeu/geometry/repository.rb +3 -3
  50. data/lib/vedeu/input/all.rb +3 -0
  51. data/lib/vedeu/input/keymap.rb +10 -11
  52. data/lib/vedeu/input/keymaps.rb +1 -1
  53. data/lib/vedeu/input/keys.rb +1 -1
  54. data/lib/vedeu/input/mapper.rb +14 -12
  55. data/lib/vedeu/logging/all.rb +3 -0
  56. data/lib/vedeu/logging/log.rb +4 -2
  57. data/lib/vedeu/menus/menu.rb +2 -4
  58. data/lib/vedeu/menus/repository.rb +1 -1
  59. data/lib/vedeu/models/all.rb +15 -0
  60. data/lib/vedeu/models/cell.rb +1 -1
  61. data/lib/vedeu/models/escape.rb +1 -1
  62. data/lib/vedeu/models/group.rb +4 -3
  63. data/lib/vedeu/models/groups.rb +1 -1
  64. data/lib/vedeu/models/interface.rb +1 -1
  65. data/lib/vedeu/models/interfaces.rb +1 -1
  66. data/lib/vedeu/models/views/char.rb +1 -1
  67. data/lib/vedeu/models/views/collections/chars.rb +1 -1
  68. data/lib/vedeu/models/views/collections/lines.rb +1 -1
  69. data/lib/vedeu/models/views/collections/streams.rb +1 -1
  70. data/lib/vedeu/models/views/collections/view_collection.rb +1 -1
  71. data/lib/vedeu/models/views/composition.rb +1 -1
  72. data/lib/vedeu/models/views/line.rb +8 -6
  73. data/lib/vedeu/models/views/stream.rb +1 -1
  74. data/lib/vedeu/models/views/view.rb +1 -1
  75. data/lib/vedeu/null/all.rb +12 -0
  76. data/lib/vedeu/output/clear/named_group.rb +2 -1
  77. data/lib/vedeu/output/clear/named_interface.rb +5 -4
  78. data/lib/vedeu/output/compressor.rb +1 -0
  79. data/lib/vedeu/output/output.rb +3 -0
  80. data/lib/vedeu/output/presentation/colour.rb +10 -10
  81. data/lib/vedeu/output/presentation/presentation.rb +9 -9
  82. data/lib/vedeu/output/presentation/style.rb +2 -2
  83. data/lib/vedeu/output/refresh/refresh.rb +35 -0
  84. data/lib/vedeu/output/refresh/refresh_group.rb +66 -0
  85. data/lib/vedeu/output/renderers/all.rb +17 -0
  86. data/lib/vedeu/output/renderers/escape_sequence.rb +4 -2
  87. data/lib/vedeu/output/renderers/file.rb +7 -6
  88. data/lib/vedeu/output/renderers/html.rb +9 -7
  89. data/lib/vedeu/output/renderers/null.rb +1 -1
  90. data/lib/vedeu/output/renderers/renderer_options.rb +24 -20
  91. data/lib/vedeu/output/renderers/terminal.rb +1 -1
  92. data/lib/vedeu/output/renderers/text.rb +1 -1
  93. data/lib/vedeu/output/wordwrap.rb +7 -4
  94. data/lib/vedeu/plugins/all.rb +2 -0
  95. data/lib/vedeu/repositories/all.rb +16 -0
  96. data/lib/vedeu/repositories/collection.rb +93 -89
  97. data/lib/vedeu/repositories/model.rb +113 -102
  98. data/lib/vedeu/repositories/registerable.rb +60 -56
  99. data/lib/vedeu/repositories/repository.rb +161 -156
  100. data/lib/vedeu/repositories/store.rb +70 -66
  101. data/lib/vedeu/runtime/all.rb +15 -0
  102. data/lib/vedeu/runtime/launcher.rb +19 -16
  103. data/lib/vedeu/templating/all.rb +6 -0
  104. data/lib/vedeu/terminal/all.rb +14 -0
  105. data/lib/vedeu/terminal/buffer.rb +8 -7
  106. data/lib/vedeu/terminal/mode.rb +11 -10
  107. data/lib/vedeu/terminal/terminal.rb +50 -45
  108. data/lib/vedeu/version.rb +1 -1
  109. data/test/lib/vedeu/cursors/cursor_test.rb +4 -2
  110. data/test/lib/vedeu/editor/cursor_test.rb +0 -3
  111. data/test/lib/vedeu/esc/esc_test.rb +58 -54
  112. data/test/lib/vedeu/events/collection_test.rb +1 -1
  113. data/test/lib/vedeu/input/keys_test.rb +1 -1
  114. data/test/lib/vedeu/input/mapper_test.rb +1 -1
  115. data/test/lib/vedeu/models/views/collections/chars_test.rb +1 -1
  116. data/test/lib/vedeu/models/views/collections/lines_test.rb +1 -1
  117. data/test/lib/vedeu/models/views/collections/streams_test.rb +1 -1
  118. data/test/lib/vedeu/models/views/collections/view_collection_test.rb +1 -1
  119. data/test/lib/vedeu/output/refresh/refresh_group_test.rb +43 -0
  120. data/test/lib/vedeu/output/refresh/refresh_test.rb +50 -0
  121. data/test/lib/vedeu/output/renderers/renderer_options_test.rb +8 -4
  122. data/test/lib/vedeu/output/renderers_test.rb +2 -1
  123. data/test/lib/vedeu/repositories/collection_test.rb +105 -101
  124. data/test/lib/vedeu/repositories/model_test.rb +56 -52
  125. data/test/lib/vedeu/repositories/registerable_test.rb +36 -32
  126. data/test/lib/vedeu/repositories/repository_test.rb +178 -174
  127. data/test/lib/vedeu/repositories/store_test.rb +109 -105
  128. data/test/support/examples/material_colours_app.rb +0 -1
  129. data/test/support/helpers/model_test_class.rb +50 -46
  130. data/test/test_helper.rb +2 -2
  131. metadata +21 -9
  132. data/lib/vedeu/refresh/refresh.rb +0 -31
  133. data/lib/vedeu/refresh/refresh_group.rb +0 -59
  134. data/out_ +0 -50
  135. data/test/lib/vedeu/refresh/refresh_group_test.rb +0 -39
  136. data/test/lib/vedeu/refresh/refresh_test.rb +0 -46
@@ -2,268 +2,272 @@ require 'test_helper'
2
2
 
3
3
  module Vedeu
4
4
 
5
- class RepositoriesTestClass < Vedeu::Repository
5
+ module Repositories
6
6
 
7
- attr_accessor :storage
8
- alias_method :in_memory, :storage
7
+ class RepositoriesTestClass < Vedeu::Repositories::Repository
9
8
 
10
- def initialize(storage = {})
11
- @storage = storage
12
- end
13
-
14
- def add(model)
15
- if storage.is_a?(Hash)
16
- @storage = in_memory.merge!(model)
17
-
18
- else
19
- @storage << model
9
+ attr_accessor :storage
10
+ alias_method :in_memory, :storage
20
11
 
12
+ def initialize(storage = {})
13
+ @storage = storage
21
14
  end
22
- end
23
15
 
24
- end # RepositoriesTestClass
16
+ def add(model)
17
+ if storage.is_a?(Hash)
18
+ @storage = in_memory.merge!(model)
25
19
 
26
- class TestRepository < Vedeu::Repository
27
- end
20
+ else
21
+ @storage << model
28
22
 
29
- class TestModel
30
- include Vedeu::Model
23
+ end
24
+ end
31
25
 
32
- attr_accessor :name
26
+ end # RepositoriesTestClass
33
27
 
34
- def initialize(name = nil)
35
- @name = name
36
- @repository = Vedeu::TestRepository.new(self.class)
28
+ class TestRepository < Vedeu::Repositories::Repository
37
29
  end
38
- end
39
30
 
40
- describe Repository do
31
+ class TestModel
32
+ include Vedeu::Repositories::Model
41
33
 
42
- let(:described) { Vedeu::Repository }
43
- let(:instance) { described.new(model, storage) }
44
- let(:model) { Vedeu::TestModel }
45
- let(:model_instance) { model.new(model_name) }
46
- let(:model_name) { 'terbium' }
47
- let(:storage) { {} }
34
+ attr_accessor :name
48
35
 
49
- describe '#initialize' do
50
- it { instance.must_be_instance_of(described) }
51
- it { instance.instance_variable_get('@model').must_equal(model) }
52
- it { instance.instance_variable_get('@storage').must_equal(storage) }
36
+ def initialize(name = nil)
37
+ @name = name
38
+ @repository = Vedeu::Repositories::TestRepository.new(self.class)
39
+ end
53
40
  end
54
41
 
55
- describe 'accessors' do
56
- it { instance.must_respond_to(:model) }
57
- it { instance.must_respond_to(:storage) }
58
- end
42
+ describe Repository do
59
43
 
60
- describe '#all' do
61
- subject { instance.all }
44
+ let(:described) { Vedeu::Repositories::Repository }
45
+ let(:instance) { described.new(model, storage) }
46
+ let(:model) { Vedeu::Repositories::TestModel }
47
+ let(:model_instance) { model.new(model_name) }
48
+ let(:model_name) { 'terbium' }
49
+ let(:storage) { {} }
62
50
 
63
- context 'when there are no models stored in the repository' do
64
- before { instance.reset }
51
+ describe '#initialize' do
52
+ it { instance.must_be_instance_of(described) }
53
+ it { instance.instance_variable_get('@model').must_equal(model) }
54
+ it { instance.instance_variable_get('@storage').must_equal(storage) }
55
+ end
65
56
 
66
- it { subject.must_equal([]) }
57
+ describe 'accessors' do
58
+ it { instance.must_respond_to(:model) }
59
+ it { instance.must_respond_to(:storage) }
67
60
  end
68
61
 
69
- context 'when there are models stored in the repository' do
70
- context 'when the repository is a glorified Hash' do
71
- let(:storage) {
72
- {
73
- oxygen: :life,
74
- plutonium: :death,
75
- }
76
- }
77
- it { subject.must_equal([:life, :death]) }
78
- end
62
+ describe '#all' do
63
+ subject { instance.all }
79
64
 
80
- context 'when the repository is a glorified Set' do
81
- let(:storage) { Set[:oxygen, :hydrogen] }
65
+ context 'when there are no models stored in the repository' do
66
+ before { instance.reset }
82
67
 
83
- it { subject.must_equal([:oxygen, :hydrogen]) }
68
+ it { subject.must_equal([]) }
84
69
  end
85
70
 
86
- context 'when the repository is unknown' do
87
- let(:storage) { [:hydrogen, :helium] }
71
+ context 'when there are models stored in the repository' do
72
+ context 'when the repository is a glorified Hash' do
73
+ let(:storage) {
74
+ {
75
+ oxygen: :life,
76
+ plutonium: :death,
77
+ }
78
+ }
79
+ it { subject.must_equal([:life, :death]) }
80
+ end
81
+
82
+ context 'when the repository is a glorified Set' do
83
+ let(:storage) { Set[:oxygen, :hydrogen] }
88
84
 
89
- it { subject.must_equal([:hydrogen, :helium]) }
85
+ it { subject.must_equal([:oxygen, :hydrogen]) }
86
+ end
87
+
88
+ context 'when the repository is unknown' do
89
+ let(:storage) { [:hydrogen, :helium] }
90
+
91
+ it { subject.must_equal([:hydrogen, :helium]) }
92
+ end
90
93
  end
91
94
  end
92
- end
93
95
 
94
- describe '#by_name' do
95
- let(:_name) { 'carbon' }
96
+ describe '#by_name' do
97
+ let(:_name) { 'carbon' }
96
98
 
97
- subject { instance.by_name(_name) }
99
+ subject { instance.by_name(_name) }
98
100
 
99
- context 'when the model exists' do
100
- # it { skip }
101
- end
101
+ context 'when the model exists' do
102
+ # it { skip }
103
+ end
102
104
 
103
- context 'when the model does not exist' do
104
- # it { skip }
105
+ context 'when the model does not exist' do
106
+ # it { skip }
107
+ end
105
108
  end
106
- end
107
109
 
108
- describe '#current' do
109
- subject { instance.current }
110
+ describe '#current' do
111
+ subject { instance.current }
110
112
 
111
- context 'when there is nothing in focus' do
112
- before { Vedeu.stubs(:focus) }
113
+ context 'when there is nothing in focus' do
114
+ before { Vedeu.stubs(:focus) }
113
115
 
114
- it { subject.must_be_instance_of(NilClass) }
115
- end
116
+ it { subject.must_be_instance_of(NilClass) }
117
+ end
116
118
 
117
- context 'when there something in focus' do
118
- before { Vedeu.stubs(:focus).returns('zinc') }
119
+ context 'when there something in focus' do
120
+ before { Vedeu.stubs(:focus).returns('zinc') }
119
121
 
120
- it { subject.must_be_instance_of(Vedeu::TestModel) }
122
+ it { subject.must_be_instance_of(Vedeu::Repositories::TestModel) }
123
+ end
121
124
  end
122
- end
123
125
 
124
- describe '#find' do
125
- subject { instance.find(model_name) }
126
+ describe '#find' do
127
+ subject { instance.find(model_name) }
126
128
 
127
- context 'when the model cannot be found' do
128
- let(:model_name) { 'not_found' }
129
+ context 'when the model cannot be found' do
130
+ let(:model_name) { 'not_found' }
129
131
 
130
- it { subject.must_be_instance_of(NilClass) }
131
- end
132
+ it { subject.must_be_instance_of(NilClass) }
133
+ end
132
134
 
133
- context 'when the model is found' do
134
- let(:model_instance) { model.new('terbium') }
135
+ context 'when the model is found' do
136
+ let(:model_instance) { model.new('terbium') }
135
137
 
136
- before { instance.store(model_instance) }
138
+ before { instance.store(model_instance) }
137
139
 
138
- it 'returns the stored model' do
139
- subject.must_equal(model_instance)
140
+ it 'returns the stored model' do
141
+ subject.must_equal(model_instance)
142
+ end
140
143
  end
141
144
  end
142
- end
143
145
 
144
- describe '#find!' do
145
- subject { instance.find!(model_name) }
146
+ describe '#find!' do
147
+ subject { instance.find!(model_name) }
146
148
 
147
- context 'when the model cannot be found' do
148
- let(:model_name) { 'not_found' }
149
+ context 'when the model cannot be found' do
150
+ let(:model_name) { 'not_found' }
149
151
 
150
- it { proc { subject }.must_raise(Vedeu::Error::ModelNotFound) }
151
- end
152
+ it { proc { subject }.must_raise(Vedeu::Error::ModelNotFound) }
153
+ end
152
154
 
153
- context 'when the model is found' do
154
- let(:model_instance) { model.new('terbium') }
155
+ context 'when the model is found' do
156
+ let(:model_instance) { model.new('terbium') }
155
157
 
156
- before { instance.store(model_instance) }
158
+ before { instance.store(model_instance) }
157
159
 
158
- it 'returns the stored model' do
159
- subject.must_equal(model_instance)
160
+ it 'returns the stored model' do
161
+ subject.must_equal(model_instance)
162
+ end
160
163
  end
161
164
  end
162
- end
163
165
 
164
- describe '#find_or_create' do
165
- let(:model_instance) { TestModel.new('niobium') }
166
+ describe '#find_or_create' do
167
+ let(:model_instance) { Vedeu::Repositories::TestModel.new('niobium') }
166
168
 
167
- subject { instance.find_or_create(model_name) }
169
+ subject { instance.find_or_create(model_name) }
168
170
 
169
- context 'when the model exists' do
170
- let(:model_name) { 'niobium' }
171
+ context 'when the model exists' do
172
+ let(:model_name) { 'niobium' }
171
173
 
172
- before { instance.store(model_instance) }
174
+ before { instance.store(model_instance) }
173
175
 
174
- it { subject.must_equal(model_instance) }
175
- end
176
+ it { subject.must_equal(model_instance) }
177
+ end
176
178
 
177
- context 'when the model does not exist' do
178
- let(:model_name) { 'zinc'}
179
+ context 'when the model does not exist' do
180
+ let(:model_name) { 'zinc'}
179
181
 
180
- it 'creates and stores a new instance of the model' do
181
- subject.must_be_instance_of(Vedeu::TestModel)
182
+ it 'creates and stores a new instance of the model' do
183
+ subject.must_be_instance_of(Vedeu::Repositories::TestModel)
184
+ end
182
185
  end
183
186
  end
184
- end
185
-
186
- describe '#inspect' do
187
- subject { instance.inspect }
188
187
 
189
- it { subject.must_be_instance_of(String) }
190
- it { subject.must_equal('<Vedeu::Repository>') }
191
- end
188
+ describe '#inspect' do
189
+ subject { instance.inspect }
192
190
 
193
- describe '#registered?' do
194
- it 'returns false with no name' do
195
- RepositoriesTestClass.new.registered?('').must_equal(false)
191
+ it { subject.must_be_instance_of(String) }
192
+ it { subject.must_equal('<Vedeu::Repositories::Repository>') }
196
193
  end
197
194
 
198
- it 'returns false with no name' do
199
- RepositoriesTestClass.new.registered?(nil).must_equal(false)
200
- end
195
+ describe '#registered?' do
196
+ it 'returns false with no name' do
197
+ RepositoriesTestClass.new.registered?('').must_equal(false)
198
+ end
201
199
 
202
- it 'returns false when the storage is empty' do
203
- RepositoriesTestClass.new.registered?('terbium').must_equal(false)
204
- end
200
+ it 'returns false with no name' do
201
+ RepositoriesTestClass.new.registered?(nil).must_equal(false)
202
+ end
203
+
204
+ it 'returns false when the storage is empty' do
205
+ RepositoriesTestClass.new.registered?('terbium').must_equal(false)
206
+ end
205
207
 
206
- it 'returns false when the model is not registered' do
207
- repo = RepositoriesTestClass.new
208
- repo.add(name: 'samarium')
208
+ it 'returns false when the model is not registered' do
209
+ repo = RepositoriesTestClass.new
210
+ repo.add(name: 'samarium')
209
211
 
210
- repo.registered?('terbium').must_equal(false)
212
+ repo.registered?('terbium').must_equal(false)
213
+ end
211
214
  end
212
- end
213
215
 
214
- describe '#remove' do
215
- subject { instance.remove('francium') }
216
+ describe '#remove' do
217
+ subject { instance.remove('francium') }
216
218
 
217
- it { instance.must_respond_to(:destroy) }
218
- it { instance.must_respond_to(:delete) }
219
- it { instance.must_respond_to(:deregister) }
219
+ it { instance.must_respond_to(:destroy) }
220
+ it { instance.must_respond_to(:delete) }
221
+ it { instance.must_respond_to(:deregister) }
220
222
 
221
- context 'when the storage is empty' do
222
- before { instance.reset }
223
+ context 'when the storage is empty' do
224
+ before { instance.reset }
223
225
 
224
- it { subject.must_be_instance_of(FalseClass) }
225
- end
226
+ it { subject.must_be_instance_of(FalseClass) }
227
+ end
226
228
 
227
- context 'when the model is not registered' do
228
- before {
229
- instance.reset
230
- instance.store(Vedeu::TestModel.new('zinc'))
231
- }
229
+ context 'when the model is not registered' do
230
+ before {
231
+ instance.reset
232
+ instance.store(Vedeu::Repositories::TestModel.new('zinc'))
233
+ }
232
234
 
233
- it { subject.must_be_instance_of(FalseClass) }
234
- end
235
+ it { subject.must_be_instance_of(FalseClass) }
236
+ end
235
237
 
236
- context 'when the model is registered' do
237
- before {
238
- instance.reset
239
- instance.store(Vedeu::TestModel.new('gadolinium'))
240
- instance.store(Vedeu::TestModel.new('francium'))
241
- }
238
+ context 'when the model is registered' do
239
+ before {
240
+ instance.reset
241
+ instance.store(Vedeu::Repositories::TestModel.new('gadolinium'))
242
+ instance.store(Vedeu::Repositories::TestModel.new('francium'))
243
+ }
242
244
 
243
- it 'returns the storage with the model removed' do
244
- subject.size.must_equal(1)
245
+ it 'returns the storage with the model removed' do
246
+ subject.size.must_equal(1)
247
+ end
245
248
  end
246
249
  end
247
- end
248
250
 
249
- describe '#store' do
250
- subject { instance.store(model_instance) }
251
+ describe '#store' do
252
+ subject { instance.store(model_instance) }
251
253
 
252
- it { instance.must_respond_to(:register) }
254
+ it { instance.must_respond_to(:register) }
253
255
 
254
- context 'when a name attribute is empty or nil' do
255
- before { model_instance.name = '' }
256
+ context 'when a name attribute is empty or nil' do
257
+ before { model_instance.name = '' }
256
258
 
257
- it { proc { subject }.must_raise(Vedeu::Error::MissingRequired) }
258
- end
259
+ it { proc { subject }.must_raise(Vedeu::Error::MissingRequired) }
260
+ end
259
261
 
260
- context 'when a name attributes is provided' do
261
- let(:model_name) { 'hydrogen' }
262
+ context 'when a name attributes is provided' do
263
+ let(:model_name) { 'hydrogen' }
262
264
 
263
- it { subject.must_be_instance_of(Vedeu::TestModel) }
265
+ it { subject.must_be_instance_of(Vedeu::Repositories::TestModel) }
266
+ end
264
267
  end
265
- end
266
268
 
267
- end # Repository
269
+ end # Repository
270
+
271
+ end # Repositories
268
272
 
269
273
  end # Vedeu