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