vedeu 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -23
- data/deps.md +15 -19
- data/lib/vedeu.rb +8 -54
- data/lib/vedeu/api/base.rb +5 -3
- data/lib/vedeu/api/events.rb +75 -0
- data/lib/vedeu/api/interface.rb +12 -2
- data/lib/vedeu/api/store.rb +37 -0
- data/lib/vedeu/api/view.rb +12 -4
- data/lib/vedeu/application.rb +7 -3
- data/lib/vedeu/configuration.rb +4 -0
- data/lib/vedeu/instrumentation.rb +1 -9
- data/lib/vedeu/launcher.rb +5 -3
- data/lib/vedeu/models/attributes/background.rb +11 -0
- data/lib/vedeu/models/attributes/collection.rb +1 -7
- data/lib/vedeu/{output → models/attributes}/colour_translator.rb +19 -3
- data/lib/vedeu/models/attributes/foreground.rb +11 -0
- data/lib/vedeu/models/attributes/interface_collection.rb +5 -5
- data/lib/vedeu/models/colour.rb +2 -18
- data/lib/vedeu/models/interface.rb +22 -13
- data/lib/vedeu/models/line.rb +1 -2
- data/lib/vedeu/models/stream.rb +21 -13
- data/lib/vedeu/output/{clear_interface.rb → clear.rb} +5 -5
- data/lib/vedeu/output/{render_interface.rb → render.rb} +4 -4
- data/lib/vedeu/support/esc.rb +3 -0
- data/lib/vedeu/support/menu.rb +1 -1
- data/lib/vedeu/support/terminal.rb +4 -10
- data/test/lib/vedeu/api/base_test.rb +1 -1
- data/test/lib/vedeu/api/events_test.rb +37 -0
- data/test/lib/vedeu/api/grid_test.rb +11 -9
- data/test/lib/vedeu/api/interface_test.rb +10 -13
- data/test/lib/vedeu/api/line_test.rb +0 -2
- data/test/lib/vedeu/api/store_test.rb +49 -0
- data/test/lib/vedeu/api/stream_test.rb +1 -1
- data/test/lib/vedeu/api/view_test.rb +1 -1
- data/test/lib/vedeu/models/attributes/background_test.rb +8 -0
- data/test/lib/vedeu/models/attributes/colour_translator_test.rb +78 -0
- data/test/lib/vedeu/models/attributes/foreground_test.rb +8 -0
- data/test/lib/vedeu/models/attributes/interface_collection_test.rb +22 -6
- data/test/lib/vedeu/models/attributes/line_collection_test.rb +1 -6
- data/test/lib/vedeu/models/attributes/stream_collection_test.rb +1 -1
- data/test/lib/vedeu/models/composition_test.rb +108 -62
- data/test/lib/vedeu/models/geometry_test.rb +48 -0
- data/test/lib/vedeu/models/interface_test.rb +26 -10
- data/test/lib/vedeu/models/line_test.rb +0 -5
- data/test/lib/vedeu/output/{clear_interface_test.rb → clear_test.rb} +8 -8
- data/test/lib/vedeu/output/{render_interface_test.rb → render_test.rb} +7 -7
- data/test/lib/vedeu/support/esc_test.rb +12 -0
- data/test/lib/vedeu/support/terminal_test.rb +2 -1
- data/test/lib/vedeu_test.rb +0 -38
- data/test/support/colours.rb +1 -1
- data/vedeu.gemspec +1 -1
- metadata +23 -23
- data/lib/vedeu/output/text_adaptor.rb +0 -35
- data/lib/vedeu/support/events.rb +0 -51
- data/lib/vedeu/support/interface_store.rb +0 -43
- data/lib/vedeu/support/queue.rb +0 -31
- data/test/lib/vedeu/output/colour_translator_test.rb +0 -42
- data/test/lib/vedeu/output/text_adaptor_test.rb +0 -73
- data/test/lib/vedeu/support/events_test.rb +0 -35
- data/test/lib/vedeu/support/interface_store_test.rb +0 -51
- data/test/lib/vedeu/support/queue_test.rb +0 -44
@@ -9,7 +9,6 @@ module Vedeu
|
|
9
9
|
foreground: '#ff0000',
|
10
10
|
background: '#000000'
|
11
11
|
},
|
12
|
-
model: {},
|
13
12
|
streams: [],
|
14
13
|
style: 'normal'
|
15
14
|
})
|
@@ -19,10 +18,6 @@ module Vedeu
|
|
19
18
|
line.colour.must_be_instance_of(Colour)
|
20
19
|
end
|
21
20
|
|
22
|
-
it 'has a model attribute' do
|
23
|
-
line.model.must_be_instance_of(Hash)
|
24
|
-
end
|
25
|
-
|
26
21
|
it 'has a streams attribute' do
|
27
22
|
line.streams.must_equal([])
|
28
23
|
end
|
@@ -1,22 +1,22 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
require 'vedeu/output/
|
2
|
+
require 'vedeu/output/clear'
|
3
3
|
require 'vedeu/models/interface'
|
4
|
-
require 'vedeu/
|
4
|
+
require 'vedeu/api/store'
|
5
5
|
|
6
6
|
module Vedeu
|
7
|
-
describe
|
8
|
-
before {
|
7
|
+
describe Clear do
|
8
|
+
before { API::Store.reset }
|
9
9
|
|
10
10
|
describe '.call' do
|
11
11
|
it 'returns the escape sequence to clear the whole interface' do
|
12
12
|
interface = Interface.new({
|
13
|
-
name: '
|
13
|
+
name: 'Clear.call',
|
14
14
|
geometry: {
|
15
15
|
width: 5,
|
16
16
|
height: 2
|
17
17
|
}
|
18
18
|
})
|
19
|
-
|
19
|
+
Clear.call(interface).must_equal(
|
20
20
|
"\e[1;1H \e[1;1H" \
|
21
21
|
"\e[2;1H \e[2;1H"
|
22
22
|
)
|
@@ -24,7 +24,7 @@ module Vedeu
|
|
24
24
|
|
25
25
|
it 'returns the escape sequence to clear the whole interface with specified colours' do
|
26
26
|
interface = Interface.new({
|
27
|
-
name: '
|
27
|
+
name: 'Clear.call',
|
28
28
|
geometry: {
|
29
29
|
width: 5,
|
30
30
|
height: 2,
|
@@ -34,7 +34,7 @@ module Vedeu
|
|
34
34
|
background: '#ffff00'
|
35
35
|
}
|
36
36
|
})
|
37
|
-
|
37
|
+
Clear.call(interface).must_equal(
|
38
38
|
"\e[38;5;46m\e[48;5;226m" \
|
39
39
|
"\e[1;1H \e[1;1H" \
|
40
40
|
"\e[2;1H \e[2;1H"
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
require 'vedeu/output/
|
2
|
+
require 'vedeu/output/render'
|
3
3
|
require 'vedeu/models/interface'
|
4
|
-
require 'vedeu/
|
4
|
+
require 'vedeu/api/store'
|
5
5
|
|
6
6
|
module Vedeu
|
7
|
-
describe
|
8
|
-
before {
|
7
|
+
describe Render do
|
8
|
+
before { API::Store.reset }
|
9
9
|
|
10
10
|
describe '.call' do
|
11
11
|
it 'returns the content for the interface' do
|
@@ -31,7 +31,7 @@ module Vedeu
|
|
31
31
|
}
|
32
32
|
]
|
33
33
|
})
|
34
|
-
|
34
|
+
Render.call(interface).must_equal(
|
35
35
|
"\e[1;1H \e[1;1H" \
|
36
36
|
"\e[2;1H \e[2;1H" \
|
37
37
|
"\e[3;1H \e[3;1H" \
|
@@ -50,7 +50,7 @@ module Vedeu
|
|
50
50
|
},
|
51
51
|
lines: []
|
52
52
|
})
|
53
|
-
|
53
|
+
Render.call(interface).must_equal(
|
54
54
|
"\e[1;1H \e[1;1H" \
|
55
55
|
"\e[2;1H \e[2;1H" \
|
56
56
|
"\e[3;1H \e[3;1H"
|
@@ -80,7 +80,7 @@ module Vedeu
|
|
80
80
|
}
|
81
81
|
]
|
82
82
|
})
|
83
|
-
|
83
|
+
Render.call(interface).must_equal(
|
84
84
|
"\e[1;1H \e[1;1H" \
|
85
85
|
"\e[2;1H \e[2;1H" \
|
86
86
|
"\e[3;1H \e[3;1H" \
|
@@ -42,6 +42,10 @@ module Vedeu
|
|
42
42
|
Esc.string('clear').must_equal("\e[38;2;39m\e[48;2;49m\e[2J")
|
43
43
|
end
|
44
44
|
|
45
|
+
it 'returns an escape sequence when the style is clear_line' do
|
46
|
+
Esc.string('clear_line').must_equal("\e[38;2;39m\e[48;2;49m\e[2K")
|
47
|
+
end
|
48
|
+
|
45
49
|
it 'returns an escape sequence when the style is colour_reset' do
|
46
50
|
Esc.string('colour_reset').must_equal("\e[38;2;39m\e[48;2;49m")
|
47
51
|
end
|
@@ -54,6 +58,14 @@ module Vedeu
|
|
54
58
|
Esc.string('hide_cursor').must_equal("\e[?25l")
|
55
59
|
end
|
56
60
|
|
61
|
+
it 'returns an escape sequence when the style is screen_init' do
|
62
|
+
Esc.string('screen_init').must_equal("\e[0m\e[38;2;39m\e[48;2;49m\e[2J\e[?25l")
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'returns an escape sequence when the style is screen_exit' do
|
66
|
+
Esc.string('screen_exit').must_equal("\e[?25h\e[38;2;39m\e[48;2;49m\e[0m")
|
67
|
+
end
|
68
|
+
|
57
69
|
it 'returns an escape sequence when the style is negative' do
|
58
70
|
Esc.string('negative').must_equal("\e[7m")
|
59
71
|
end
|
@@ -22,7 +22,8 @@ module Vedeu
|
|
22
22
|
describe '.clear_last_line' do
|
23
23
|
it 'returns an escape sequence to clear the last line' do
|
24
24
|
console.stub :winsize, [25, 25] do
|
25
|
-
Terminal.clear_last_line
|
25
|
+
Terminal.clear_last_line
|
26
|
+
.must_equal("\e[24;1H\e[38;2;39m\e[48;2;49m\e[2K")
|
26
27
|
end
|
27
28
|
end
|
28
29
|
end
|
data/test/lib/vedeu_test.rb
CHANGED
@@ -3,46 +3,8 @@ require 'vedeu'
|
|
3
3
|
|
4
4
|
module Vedeu
|
5
5
|
describe API do
|
6
|
-
describe '.interface' do
|
7
|
-
end
|
8
|
-
|
9
|
-
describe '.event' do
|
10
|
-
end
|
11
|
-
|
12
|
-
describe '.run' do
|
13
|
-
end
|
14
|
-
|
15
|
-
# describe '.view' do
|
16
|
-
# it 'returns the interface referenced by name' do
|
17
|
-
# Vedeu.interface 'Vedeu.view' do
|
18
|
-
# width 5
|
19
|
-
# height 5
|
20
|
-
# end
|
21
|
-
|
22
|
-
# Vedeu.view('Vedeu.view').must_be_instance_of(Interface)
|
23
|
-
# Vedeu.view('Vedeu.view').name.must_equal('Vedeu.view')
|
24
|
-
# end
|
25
|
-
|
26
|
-
# it 'raises an exception if the interface does not exist' do
|
27
|
-
# proc { Vedeu.view('unknown') }.must_raise(EntityNotFound)
|
28
|
-
# end
|
29
|
-
# end
|
30
6
|
end
|
31
7
|
end
|
32
8
|
|
33
9
|
describe Vedeu do
|
34
|
-
describe '.events' do
|
35
|
-
it 'creates some system events for the client application' do
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe '.log' do
|
40
|
-
it 'returns a logger instance for writing debug messages to' do
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe '.error' do
|
45
|
-
it 'writes an error to the log' do
|
46
|
-
end
|
47
|
-
end
|
48
10
|
end
|
data/test/support/colours.rb
CHANGED
data/vedeu.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'vedeu'
|
7
|
-
spec.version = '0.1.
|
7
|
+
spec.version = '0.1.8'
|
8
8
|
spec.authors = ['Gavin Laking']
|
9
9
|
spec.email = ['gavinlaking@gmail.com']
|
10
10
|
spec.summary = %q{A terminal case of wonderland.}
|
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.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Laking
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -186,16 +186,21 @@ files:
|
|
186
186
|
- deps.md
|
187
187
|
- lib/vedeu.rb
|
188
188
|
- lib/vedeu/api/base.rb
|
189
|
+
- lib/vedeu/api/events.rb
|
189
190
|
- lib/vedeu/api/grid.rb
|
190
191
|
- lib/vedeu/api/interface.rb
|
191
192
|
- lib/vedeu/api/line.rb
|
193
|
+
- lib/vedeu/api/store.rb
|
192
194
|
- lib/vedeu/api/stream.rb
|
193
195
|
- lib/vedeu/api/view.rb
|
194
196
|
- lib/vedeu/application.rb
|
195
197
|
- lib/vedeu/configuration.rb
|
196
198
|
- lib/vedeu/instrumentation.rb
|
197
199
|
- lib/vedeu/launcher.rb
|
200
|
+
- lib/vedeu/models/attributes/background.rb
|
198
201
|
- lib/vedeu/models/attributes/collection.rb
|
202
|
+
- lib/vedeu/models/attributes/colour_translator.rb
|
203
|
+
- lib/vedeu/models/attributes/foreground.rb
|
199
204
|
- lib/vedeu/models/attributes/interface_collection.rb
|
200
205
|
- lib/vedeu/models/attributes/line_collection.rb
|
201
206
|
- lib/vedeu/models/attributes/stream_collection.rb
|
@@ -206,30 +211,30 @@ files:
|
|
206
211
|
- lib/vedeu/models/line.rb
|
207
212
|
- lib/vedeu/models/stream.rb
|
208
213
|
- lib/vedeu/models/style.rb
|
209
|
-
- lib/vedeu/output/
|
210
|
-
- lib/vedeu/output/
|
211
|
-
- lib/vedeu/output/render_interface.rb
|
212
|
-
- lib/vedeu/output/text_adaptor.rb
|
214
|
+
- lib/vedeu/output/clear.rb
|
215
|
+
- lib/vedeu/output/render.rb
|
213
216
|
- lib/vedeu/output/view.rb
|
214
217
|
- lib/vedeu/support/esc.rb
|
215
|
-
- lib/vedeu/support/events.rb
|
216
218
|
- lib/vedeu/support/input.rb
|
217
|
-
- lib/vedeu/support/interface_store.rb
|
218
219
|
- lib/vedeu/support/menu.rb
|
219
|
-
- lib/vedeu/support/queue.rb
|
220
220
|
- lib/vedeu/support/terminal.rb
|
221
221
|
- lib/vedeu/support/wordwrap.rb
|
222
222
|
- logs/.gitkeep
|
223
223
|
- test/lib/vedeu/api/base_test.rb
|
224
|
+
- test/lib/vedeu/api/events_test.rb
|
224
225
|
- test/lib/vedeu/api/grid_test.rb
|
225
226
|
- test/lib/vedeu/api/interface_test.rb
|
226
227
|
- test/lib/vedeu/api/line_test.rb
|
228
|
+
- test/lib/vedeu/api/store_test.rb
|
227
229
|
- test/lib/vedeu/api/stream_test.rb
|
228
230
|
- test/lib/vedeu/api/view_test.rb
|
229
231
|
- test/lib/vedeu/application_test.rb
|
230
232
|
- test/lib/vedeu/configuration_test.rb
|
231
233
|
- test/lib/vedeu/launcher_test.rb
|
234
|
+
- test/lib/vedeu/models/attributes/background_test.rb
|
232
235
|
- test/lib/vedeu/models/attributes/collection_test.rb
|
236
|
+
- test/lib/vedeu/models/attributes/colour_translator_test.rb
|
237
|
+
- test/lib/vedeu/models/attributes/foreground_test.rb
|
233
238
|
- test/lib/vedeu/models/attributes/interface_collection_test.rb
|
234
239
|
- test/lib/vedeu/models/attributes/line_collection_test.rb
|
235
240
|
- test/lib/vedeu/models/attributes/stream_collection_test.rb
|
@@ -240,17 +245,12 @@ files:
|
|
240
245
|
- test/lib/vedeu/models/line_test.rb
|
241
246
|
- test/lib/vedeu/models/stream_test.rb
|
242
247
|
- test/lib/vedeu/models/style_test.rb
|
243
|
-
- test/lib/vedeu/output/
|
244
|
-
- test/lib/vedeu/output/
|
245
|
-
- test/lib/vedeu/output/render_interface_test.rb
|
246
|
-
- test/lib/vedeu/output/text_adaptor_test.rb
|
248
|
+
- test/lib/vedeu/output/clear_test.rb
|
249
|
+
- test/lib/vedeu/output/render_test.rb
|
247
250
|
- test/lib/vedeu/output/view_test.rb
|
248
251
|
- test/lib/vedeu/support/esc_test.rb
|
249
|
-
- test/lib/vedeu/support/events_test.rb
|
250
252
|
- test/lib/vedeu/support/input_test.rb
|
251
|
-
- test/lib/vedeu/support/interface_store_test.rb
|
252
253
|
- test/lib/vedeu/support/menu_test.rb
|
253
|
-
- test/lib/vedeu/support/queue_test.rb
|
254
254
|
- test/lib/vedeu/support/terminal_test.rb
|
255
255
|
- test/lib/vedeu/support/wordwrap_test.rb
|
256
256
|
- test/lib/vedeu_test.rb
|
@@ -304,15 +304,20 @@ specification_version: 4
|
|
304
304
|
summary: A terminal case of wonderland.
|
305
305
|
test_files:
|
306
306
|
- test/lib/vedeu/api/base_test.rb
|
307
|
+
- test/lib/vedeu/api/events_test.rb
|
307
308
|
- test/lib/vedeu/api/grid_test.rb
|
308
309
|
- test/lib/vedeu/api/interface_test.rb
|
309
310
|
- test/lib/vedeu/api/line_test.rb
|
311
|
+
- test/lib/vedeu/api/store_test.rb
|
310
312
|
- test/lib/vedeu/api/stream_test.rb
|
311
313
|
- test/lib/vedeu/api/view_test.rb
|
312
314
|
- test/lib/vedeu/application_test.rb
|
313
315
|
- test/lib/vedeu/configuration_test.rb
|
314
316
|
- test/lib/vedeu/launcher_test.rb
|
317
|
+
- test/lib/vedeu/models/attributes/background_test.rb
|
315
318
|
- test/lib/vedeu/models/attributes/collection_test.rb
|
319
|
+
- test/lib/vedeu/models/attributes/colour_translator_test.rb
|
320
|
+
- test/lib/vedeu/models/attributes/foreground_test.rb
|
316
321
|
- test/lib/vedeu/models/attributes/interface_collection_test.rb
|
317
322
|
- test/lib/vedeu/models/attributes/line_collection_test.rb
|
318
323
|
- test/lib/vedeu/models/attributes/stream_collection_test.rb
|
@@ -323,17 +328,12 @@ test_files:
|
|
323
328
|
- test/lib/vedeu/models/line_test.rb
|
324
329
|
- test/lib/vedeu/models/stream_test.rb
|
325
330
|
- test/lib/vedeu/models/style_test.rb
|
326
|
-
- test/lib/vedeu/output/
|
327
|
-
- test/lib/vedeu/output/
|
328
|
-
- test/lib/vedeu/output/render_interface_test.rb
|
329
|
-
- test/lib/vedeu/output/text_adaptor_test.rb
|
331
|
+
- test/lib/vedeu/output/clear_test.rb
|
332
|
+
- test/lib/vedeu/output/render_test.rb
|
330
333
|
- test/lib/vedeu/output/view_test.rb
|
331
334
|
- test/lib/vedeu/support/esc_test.rb
|
332
|
-
- test/lib/vedeu/support/events_test.rb
|
333
335
|
- test/lib/vedeu/support/input_test.rb
|
334
|
-
- test/lib/vedeu/support/interface_store_test.rb
|
335
336
|
- test/lib/vedeu/support/menu_test.rb
|
336
|
-
- test/lib/vedeu/support/queue_test.rb
|
337
337
|
- test/lib/vedeu/support/terminal_test.rb
|
338
338
|
- test/lib/vedeu/support/wordwrap_test.rb
|
339
339
|
- test/lib/vedeu_test.rb
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module Vedeu
|
2
|
-
class TextAdaptor
|
3
|
-
def self.adapt(text)
|
4
|
-
new(text).adapt
|
5
|
-
end
|
6
|
-
|
7
|
-
def initialize(text)
|
8
|
-
@text = text
|
9
|
-
end
|
10
|
-
|
11
|
-
def adapt
|
12
|
-
return [] if no_content?
|
13
|
-
|
14
|
-
lines.map { |line| { streams: { text: line } } }
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
attr_reader :text
|
20
|
-
|
21
|
-
def lines
|
22
|
-
if text.is_a?(::Array)
|
23
|
-
text
|
24
|
-
|
25
|
-
else
|
26
|
-
text.split(/\n/)
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def no_content?
|
32
|
-
text.nil? || text.empty?
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
data/lib/vedeu/support/events.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
# Todo: mutation (events)
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
class Events
|
5
|
-
def initialize(&block)
|
6
|
-
@handlers = Hash.new do |hash, key|
|
7
|
-
hash[key] = {
|
8
|
-
delay: 0,
|
9
|
-
events: [],
|
10
|
-
last_exec: 0,
|
11
|
-
}
|
12
|
-
end
|
13
|
-
self.instance_eval(&block) if block_given?
|
14
|
-
self
|
15
|
-
end
|
16
|
-
|
17
|
-
def add(object, &block)
|
18
|
-
@self_before_instance_eval = eval 'self', block.binding
|
19
|
-
|
20
|
-
self.instance_eval(&block)
|
21
|
-
end
|
22
|
-
|
23
|
-
def on(event, delay = 0, &block)
|
24
|
-
handlers[event][:events] << block
|
25
|
-
handlers[event][:delay] = delay
|
26
|
-
handlers[event]
|
27
|
-
end
|
28
|
-
|
29
|
-
def trigger(event, *args)
|
30
|
-
elapsed = Time.now.to_f - handlers[event][:last_exec]
|
31
|
-
|
32
|
-
if elapsed > handlers[event][:delay]
|
33
|
-
handlers[event][:last_exec] = Time.now.to_f
|
34
|
-
|
35
|
-
handlers[event][:events].each do |handler|
|
36
|
-
handler.call(*args)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
# :nocov:
|
42
|
-
def method_missing(method, *args, &block)
|
43
|
-
@self_before_instance_eval.send method, *args, &block
|
44
|
-
end
|
45
|
-
# :nocov:
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
attr_reader :handlers, :throttles
|
50
|
-
end
|
51
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'vedeu/models/interface'
|
2
|
-
|
3
|
-
# Todo: mutation (persistence)
|
4
|
-
|
5
|
-
module Vedeu
|
6
|
-
EntityNotFound = Class.new(StandardError)
|
7
|
-
|
8
|
-
module InterfaceStore
|
9
|
-
extend self
|
10
|
-
|
11
|
-
def update(name, attributes = {})
|
12
|
-
interface = query(name)
|
13
|
-
interface.attributes = attributes
|
14
|
-
interface
|
15
|
-
|
16
|
-
rescue EntityNotFound
|
17
|
-
create(attributes)
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
def create(attributes)
|
22
|
-
storage.store(attributes[:name], Interface.new(attributes))
|
23
|
-
end
|
24
|
-
|
25
|
-
def query(interface_name)
|
26
|
-
storage.select do |name, interface|
|
27
|
-
return interface if name == interface_name
|
28
|
-
end unless interface_name.nil? || interface_name.empty?
|
29
|
-
|
30
|
-
fail EntityNotFound, "Interface could not be found."
|
31
|
-
end
|
32
|
-
|
33
|
-
def reset
|
34
|
-
@storage = {}
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def storage
|
40
|
-
@storage ||= {}
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|