vedeu 0.4.13 → 0.4.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -1
- data/.travis.yml +2 -1
- data/Guardfile +6 -5
- data/README.md +3 -30
- data/Rakefile +5 -5
- data/bin/vedeu_drb_client +1 -1
- data/bin/vedeu_drb_server +91 -89
- data/bin/vedeu_test +4 -0
- data/config/rubocop_enabled.yml +5 -10
- data/examples/borders_app.rb +2 -1
- data/examples/colours_app.rb +13 -8
- data/examples/configuration_app.rb +3 -2
- data/examples/cursor_app.rb +16 -11
- data/examples/drb_app.rb +88 -89
- data/examples/focus_app.rb +31 -32
- data/examples/geometry_app.rb +2 -1
- data/examples/hello_world.rb +2 -1
- data/examples/lines_app.rb +2 -1
- data/examples/material_colours_app.rb +126 -0
- data/examples/typed_commands/typed_commands_app.rb +5 -1
- data/examples/view_templates_app/view_templates_app.rb +6 -3
- data/lib/vedeu/all.rb +1 -1
- data/lib/vedeu/api.rb +18 -10
- data/lib/vedeu/application.rb +0 -1
- data/lib/vedeu/bindings.rb +77 -16
- data/lib/vedeu/buffers/all.rb +2 -5
- data/lib/vedeu/buffers/buffer.rb +69 -25
- data/lib/vedeu/buffers/display_buffer.rb +3 -7
- data/lib/vedeu/configuration/all.rb +3 -6
- data/lib/vedeu/configuration/api.rb +28 -4
- data/lib/vedeu/configuration/cli.rb +9 -9
- data/lib/vedeu/configuration/configuration.rb +11 -7
- data/lib/vedeu/cursor/all.rb +3 -6
- data/lib/vedeu/cursor/cursor.rb +22 -14
- data/lib/vedeu/cursor/move.rb +32 -22
- data/lib/vedeu/cursor/refresh_cursor.rb +1 -1
- data/lib/vedeu/debug.rb +2 -1
- data/lib/vedeu/distributed/client.rb +1 -7
- data/lib/vedeu/distributed/server.rb +0 -4
- data/lib/vedeu/distributed/subprocess.rb +1 -1
- data/lib/vedeu/distributed/templates/default_configuration.vedeu +1 -1
- data/lib/vedeu/distributed/test_application.rb +3 -5
- data/lib/vedeu/distributed/uri.rb +2 -2
- data/lib/vedeu/dsl/all.rb +6 -6
- data/lib/vedeu/dsl/components/all.rb +0 -3
- data/lib/vedeu/dsl/components/border.rb +20 -12
- data/lib/vedeu/dsl/components/geometry.rb +68 -3
- data/lib/vedeu/dsl/components/keymap.rb +1 -2
- data/lib/vedeu/dsl/composition.rb +8 -1
- data/lib/vedeu/dsl/interface.rb +61 -11
- data/lib/vedeu/dsl/line.rb +12 -12
- data/lib/vedeu/dsl/shared/all.rb +4 -7
- data/lib/vedeu/dsl/shared/colour.rb +2 -2
- data/lib/vedeu/dsl/shared/text.rb +2 -35
- data/lib/vedeu/dsl/shared/use.rb +2 -2
- data/lib/vedeu/dsl/view.rb +4 -4
- data/lib/vedeu/events/all.rb +3 -5
- data/lib/vedeu/events/event.rb +5 -5
- data/lib/vedeu/geometry/all.rb +11 -16
- data/lib/vedeu/geometry/area.rb +2 -5
- data/lib/vedeu/geometry/canvas.rb +12 -16
- data/lib/vedeu/geometry/dimension.rb +20 -22
- data/lib/vedeu/geometry/geometry.rb +28 -30
- data/lib/vedeu/geometry/grid.rb +1 -1
- data/lib/vedeu/geometry/index_position.rb +7 -0
- data/lib/vedeu/geometry/null_geometry.rb +61 -0
- data/lib/vedeu/geometry/position.rb +0 -3
- data/lib/vedeu/geometry/position_index.rb +7 -0
- data/lib/vedeu/geometry/position_validator.rb +44 -33
- data/lib/vedeu/input/all.rb +5 -4
- data/lib/vedeu/input/keymap.rb +0 -1
- data/lib/vedeu/input/mapper.rb +1 -3
- data/lib/vedeu/launcher.rb +6 -7
- data/lib/vedeu/main_loop.rb +1 -2
- data/lib/vedeu/models/all.rb +1 -0
- data/lib/vedeu/models/cell.rb +5 -8
- data/lib/vedeu/models/char.rb +50 -15
- data/lib/vedeu/models/composition.rb +8 -1
- data/lib/vedeu/models/focus.rb +4 -4
- data/lib/vedeu/models/group.rb +3 -3
- data/lib/vedeu/models/interface.rb +62 -46
- data/lib/vedeu/models/line.rb +1 -1
- data/lib/vedeu/models/null.rb +48 -0
- data/lib/vedeu/models/stream.rb +5 -5
- data/lib/vedeu/output/all.rb +20 -30
- data/lib/vedeu/output/border.rb +93 -40
- data/lib/vedeu/output/clear.rb +100 -15
- data/lib/vedeu/output/colour.rb +56 -12
- data/lib/vedeu/output/compressor.rb +59 -0
- data/lib/vedeu/output/html_char.rb +4 -2
- data/lib/vedeu/output/null_border.rb +16 -4
- data/lib/vedeu/output/output.rb +13 -21
- data/lib/vedeu/output/presentation.rb +28 -23
- data/lib/vedeu/output/refresh.rb +2 -2
- data/lib/vedeu/output/renderers/all.rb +80 -3
- data/lib/vedeu/output/renderers/file_renderer.rb +38 -2
- data/lib/vedeu/output/renderers/html_renderer.rb +6 -4
- data/lib/vedeu/output/renderers/json_renderer.rb +52 -0
- data/lib/vedeu/output/renderers/null_renderer.rb +14 -0
- data/lib/vedeu/output/renderers/terminal_renderer.rb +2 -12
- data/lib/vedeu/output/style.rb +33 -3
- data/lib/vedeu/output/text.rb +98 -1
- data/lib/vedeu/output/translator.rb +30 -7
- data/lib/vedeu/output/viewport.rb +43 -79
- data/lib/vedeu/output/wordwrap.rb +4 -4
- data/lib/vedeu/repositories/all.rb +22 -179
- data/lib/vedeu/repositories/collection.rb +11 -13
- data/lib/vedeu/repositories/collections/all.rb +8 -0
- data/lib/vedeu/repositories/collections/chars.rb +9 -0
- data/lib/vedeu/repositories/collections/events.rb +9 -0
- data/lib/vedeu/repositories/collections/interfaces.rb +9 -0
- data/lib/vedeu/repositories/collections/keys.rb +9 -0
- data/lib/vedeu/repositories/collections/lines.rb +9 -0
- data/lib/vedeu/repositories/collections/streams.rb +9 -0
- data/lib/vedeu/repositories/model.rb +7 -2
- data/lib/vedeu/repositories/repositories/all.rb +14 -0
- data/lib/vedeu/repositories/repositories/background_colours.rb +14 -0
- data/lib/vedeu/repositories/repositories/borders.rb +38 -0
- data/lib/vedeu/repositories/repositories/buffers.rb +36 -0
- data/lib/vedeu/repositories/repositories/colours.rb +63 -0
- data/lib/vedeu/repositories/repositories/cursors.rb +29 -0
- data/lib/vedeu/repositories/repositories/events_repository.rb +24 -0
- data/lib/vedeu/repositories/repositories/foreground_colours.rb +14 -0
- data/lib/vedeu/repositories/repositories/geometries.rb +37 -0
- data/lib/vedeu/repositories/repositories/groups.rb +24 -0
- data/lib/vedeu/repositories/repositories/interfaces_repository.rb +24 -0
- data/lib/vedeu/repositories/repositories/keymaps.rb +24 -0
- data/lib/vedeu/repositories/repositories/menus.rb +24 -0
- data/lib/vedeu/repositories/repository.rb +29 -47
- data/lib/vedeu/storage/all.rb +6 -0
- data/lib/vedeu/storage/associative_store.rb +47 -0
- data/lib/vedeu/storage/conveyor_store.rb +69 -0
- data/lib/vedeu/storage/fifo_store.rb +37 -0
- data/lib/vedeu/storage/store.rb +58 -0
- data/lib/vedeu/support/all.rb +5 -10
- data/lib/vedeu/support/common.rb +0 -8
- data/lib/vedeu/support/log.rb +13 -24
- data/lib/vedeu/support/template.rb +4 -1
- data/lib/vedeu/support/terminal.rb +10 -10
- data/lib/vedeu/support/trace.rb +15 -88
- data/lib/vedeu/support/visibility.rb +73 -0
- data/lib/vedeu.rb +37 -0
- data/test/lib/vedeu/api_test.rb +7 -3
- data/test/lib/vedeu/application_test.rb +9 -3
- data/test/lib/vedeu/bindings_test.rb +21 -0
- data/test/lib/vedeu/buffers/buffer_test.rb +110 -134
- data/test/lib/vedeu/buffers/display_buffer_test.rb +8 -0
- data/test/lib/vedeu/configuration/api_test.rb +5 -1
- data/test/lib/vedeu/configuration/configuration_test.rb +4 -6
- data/test/lib/vedeu/cursor/cursor_test.rb +25 -17
- data/test/lib/vedeu/cursor/move_test.rb +7 -7
- data/test/lib/vedeu/distributed/client_test.rb +1 -1
- data/test/lib/vedeu/distributed/subprocess_test.rb +3 -1
- data/test/lib/vedeu/distributed/uri_test.rb +5 -5
- data/test/lib/vedeu/dsl/components/geometry_test.rb +43 -0
- data/test/lib/vedeu/dsl/components/keymap_test.rb +1 -1
- data/test/lib/vedeu/dsl/composition_test.rb +6 -5
- data/test/lib/vedeu/dsl/interface_test.rb +81 -16
- data/test/lib/vedeu/dsl/shared/colour_test.rb +4 -4
- data/test/lib/vedeu/dsl/shared/text_test.rb +87 -9
- data/test/lib/vedeu/dsl/stream_test.rb +1 -1
- data/test/lib/vedeu/events/event_test.rb +3 -1
- data/test/lib/vedeu/events/trigger_test.rb +8 -4
- data/test/lib/vedeu/geometry/dimension_test.rb +1 -1
- data/test/lib/vedeu/geometry/geometry_test.rb +5 -3
- data/test/lib/vedeu/geometry/index_position_test.rb +30 -7
- data/test/lib/vedeu/geometry/null_geometry_test.rb +57 -0
- data/test/lib/vedeu/geometry/position_index_test.rb +14 -0
- data/test/lib/vedeu/geometry/position_validator_test.rb +17 -3
- data/test/lib/vedeu/input/keymap_test.rb +3 -1
- data/test/lib/vedeu/input/mapper_test.rb +8 -4
- data/test/lib/vedeu/launcher_test.rb +1 -1
- data/test/lib/vedeu/models/cell_test.rb +10 -8
- data/test/lib/vedeu/models/char_test.rb +52 -28
- data/test/lib/vedeu/models/composition_test.rb +26 -4
- data/test/lib/vedeu/models/group_test.rb +11 -5
- data/test/lib/vedeu/models/interface_test.rb +32 -19
- data/test/lib/vedeu/models/line_test.rb +21 -25
- data/test/lib/vedeu/models/menu_test.rb +10 -6
- data/test/lib/vedeu/models/null_test.rb +66 -0
- data/test/lib/vedeu/models/stream_test.rb +13 -10
- data/test/lib/vedeu/output/border_test.rb +29 -8
- data/test/lib/vedeu/output/clear_test.rb +23 -4
- data/test/lib/vedeu/output/colour_test.rb +20 -4
- data/test/lib/vedeu/output/compressor_test.rb +43 -0
- data/test/lib/vedeu/output/html_char_test.rb +29 -17
- data/test/lib/vedeu/output/null_border_test.rb +2 -1
- data/test/lib/vedeu/output/output_test.rb +20 -30
- data/test/lib/vedeu/output/presentation_test.rb +39 -16
- data/test/lib/vedeu/output/refresh_test.rb +14 -10
- data/test/lib/vedeu/output/renderers/all_test.rb +96 -0
- data/test/lib/vedeu/output/renderers/file_renderer_test.rb +1 -1
- data/test/lib/vedeu/output/renderers/html_renderer_test.rb +13 -9
- data/test/lib/vedeu/output/renderers/json_renderer_test.rb +52 -0
- data/test/lib/vedeu/output/renderers/null_renderer_test.rb +19 -0
- data/test/lib/vedeu/output/style_test.rb +41 -1
- data/test/lib/vedeu/output/text_test.rb +61 -10
- data/test/lib/vedeu/output/translator_test.rb +14 -0
- data/test/lib/vedeu/output/viewport_test.rb +22 -3
- data/test/lib/vedeu/output/virtual_terminal_test.rb +3 -3
- data/test/lib/vedeu/output/wordwrap_test.rb +58 -45
- data/test/lib/vedeu/repositories/collections/chars_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/events_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/interfaces_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/keys_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/lines_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/streams_test.rb +16 -0
- data/test/lib/vedeu/repositories/repositories/background_colours_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/borders_test.rb +51 -0
- data/test/lib/vedeu/repositories/repositories/buffers_test.rb +52 -0
- data/test/lib/vedeu/repositories/repositories/colours_test.rb +16 -0
- data/test/lib/vedeu/repositories/repositories/cursors_test.rb +39 -0
- data/test/lib/vedeu/repositories/repositories/events_repository_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/foreground_colours_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/geometries_test.rb +42 -0
- data/test/lib/vedeu/repositories/repositories/groups_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/interfaces_repositories_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/keymaps_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/menus_test.rb +17 -0
- data/test/lib/vedeu/repositories/repository_test.rb +16 -36
- data/test/lib/vedeu/storage/associative_store_test.rb +69 -0
- data/test/lib/vedeu/storage/conveyor_store_test.rb +135 -0
- data/test/lib/vedeu/storage/fifo_store_test.rb +47 -0
- data/test/lib/vedeu/storage/store_test.rb +123 -0
- data/test/lib/vedeu/support/common_test.rb +0 -9
- data/test/lib/vedeu/support/terminal_test.rb +78 -55
- data/test/lib/vedeu/support/visibility_test.rb +80 -0
- data/test/test_helper.rb +13 -11
- data/vedeu.gemspec +4 -3
- metadata +92 -32
- data/lib/vedeu/cursor/toggle.rb +0 -55
- data/lib/vedeu/exceptions.rb +0 -37
- data/lib/vedeu/geometry/centre.rb +0 -85
- data/lib/vedeu/geometry/content.rb +0 -70
- data/lib/vedeu/geometry/limit.rb +0 -58
- data/lib/vedeu/output/compositor.rb +0 -62
- data/lib/vedeu/repositories/collections.rb +0 -41
- data/lib/vedeu/support/coercions.rb +0 -60
- data/lib/vedeu/support/sentence.rb +0 -91
- data/lib/vedeu/support/visible.rb +0 -90
- data/test/lib/vedeu/cursor/toggle_test.rb +0 -63
- data/test/lib/vedeu/geometry/centre_test.rb +0 -58
- data/test/lib/vedeu/geometry/content_test.rb +0 -98
- data/test/lib/vedeu/geometry/limit_test.rb +0 -30
- data/test/lib/vedeu/output/compositor_test.rb +0 -48
- data/test/lib/vedeu/repositories/all_test.rb +0 -135
- data/test/lib/vedeu/repositories/collections_test.rb +0 -71
- data/test/lib/vedeu/support/coercions_test.rb +0 -84
- data/test/lib/vedeu/support/sentence_test.rb +0 -56
- data/test/lib/vedeu/support/visible_test.rb +0 -161
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe Buffers do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::Buffers }
|
8
|
+
let(:instance) { described.buffers }
|
9
|
+
|
10
|
+
describe '.buffers' do
|
11
|
+
subject { instance }
|
12
|
+
|
13
|
+
it { subject.must_be_instance_of(described) }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#clear' do
|
17
|
+
let(:_name) { 'silicon' }
|
18
|
+
let(:buffer) { Vedeu::Buffer.new }
|
19
|
+
|
20
|
+
subject { instance.clear(_name) }
|
21
|
+
|
22
|
+
context 'when the buffer exists' do
|
23
|
+
before { instance.stubs(:find!).returns(buffer) }
|
24
|
+
|
25
|
+
it { buffer.expects(:clear); subject }
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'when the buffer does not exist' do
|
29
|
+
it { proc { subject }.must_raise(ModelNotFound) }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#render' do
|
34
|
+
let(:_name) { 'silicon' }
|
35
|
+
let(:buffer) { Vedeu::Buffer.new }
|
36
|
+
|
37
|
+
subject { instance.render(_name) }
|
38
|
+
|
39
|
+
context 'when the buffer exists' do
|
40
|
+
before { instance.stubs(:find!).returns(buffer) }
|
41
|
+
|
42
|
+
it { buffer.expects(:render); subject }
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when the buffer does not exist' do
|
46
|
+
it { proc { subject }.must_raise(ModelNotFound) }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end # Buffers
|
51
|
+
|
52
|
+
end # Vedeu
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe Colours do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::Colours }
|
8
|
+
let(:instance) { described.new }
|
9
|
+
|
10
|
+
describe '#initialize' do
|
11
|
+
it { instance.must_be_instance_of(described) }
|
12
|
+
end
|
13
|
+
|
14
|
+
end # Colours
|
15
|
+
|
16
|
+
end # Vedeu
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe Cursors do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::Cursors }
|
8
|
+
|
9
|
+
describe '.cursors' do
|
10
|
+
subject { described.cursors }
|
11
|
+
|
12
|
+
it { subject.must_be_instance_of(described) }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '.cursor' do
|
16
|
+
subject { Vedeu.cursor }
|
17
|
+
|
18
|
+
context 'when there are cursors are defined' do
|
19
|
+
before do
|
20
|
+
Vedeu::Focus.add('Vedeu.cursor')
|
21
|
+
Vedeu::Cursor.new(name: 'Vedeu.cursor').store
|
22
|
+
end
|
23
|
+
|
24
|
+
it { subject.must_be_instance_of(Vedeu::Cursor) }
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when there are no cursors defined' do
|
28
|
+
before do
|
29
|
+
Vedeu::Focus.reset
|
30
|
+
Vedeu.cursors.reset
|
31
|
+
end
|
32
|
+
|
33
|
+
it { subject.must_be_instance_of(NilClass) }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end # Cursors
|
38
|
+
|
39
|
+
end # Vedeu
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe EventsRepository do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::EventsRepository }
|
8
|
+
|
9
|
+
describe '.events' do
|
10
|
+
subject { described.events }
|
11
|
+
|
12
|
+
it { subject.must_be_instance_of(described) }
|
13
|
+
end
|
14
|
+
|
15
|
+
end # EventsRepository
|
16
|
+
|
17
|
+
end # Vedeu
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe ForegroundColours do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::ForegroundColours }
|
8
|
+
|
9
|
+
describe '.foreground_colours' do
|
10
|
+
subject { described.foreground_colours }
|
11
|
+
|
12
|
+
it { subject.must_be_instance_of(described) }
|
13
|
+
end
|
14
|
+
|
15
|
+
end # ForegroundColours
|
16
|
+
|
17
|
+
end # Vedeu
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe Geometries do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::Geometries }
|
8
|
+
|
9
|
+
describe '.geometries' do
|
10
|
+
subject { described.geometries }
|
11
|
+
|
12
|
+
it { subject.must_be_instance_of(described) }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#by_name' do
|
16
|
+
let(:_name) { 'carbon' }
|
17
|
+
|
18
|
+
subject { described.geometries.by_name(_name) }
|
19
|
+
|
20
|
+
context 'when the geometry exists' do
|
21
|
+
before do
|
22
|
+
Vedeu.geometry 'carbon' do
|
23
|
+
x 1
|
24
|
+
xn 3
|
25
|
+
y 1
|
26
|
+
yn 3
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it { subject.must_be_instance_of(Vedeu::Geometry) }
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when the geometry does not exist' do
|
34
|
+
let(:_name) { 'nitrogen' }
|
35
|
+
|
36
|
+
it { subject.must_be_instance_of(Vedeu::NullGeometry) }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end # Geometries
|
41
|
+
|
42
|
+
end # Vedeu
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe Groups do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::Groups }
|
8
|
+
|
9
|
+
describe '.groups' do
|
10
|
+
subject { described.groups }
|
11
|
+
|
12
|
+
it { subject.must_be_instance_of(described) }
|
13
|
+
end
|
14
|
+
|
15
|
+
end # Groups
|
16
|
+
|
17
|
+
end # Vedeu
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe InterfacesRepository do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::InterfacesRepository }
|
8
|
+
|
9
|
+
describe '.interfaces' do
|
10
|
+
subject { described.interfaces }
|
11
|
+
|
12
|
+
it { subject.must_be_instance_of(described) }
|
13
|
+
end
|
14
|
+
|
15
|
+
end # InterfacesRepository
|
16
|
+
|
17
|
+
end # Vedeu
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe Keymaps do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::Keymaps }
|
8
|
+
|
9
|
+
describe '.keymaps' do
|
10
|
+
subject { described.keymaps }
|
11
|
+
|
12
|
+
it { subject.must_be_instance_of(described) }
|
13
|
+
end
|
14
|
+
|
15
|
+
end # Keymaps
|
16
|
+
|
17
|
+
end # Vedeu
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe Menus do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::Menus }
|
8
|
+
|
9
|
+
describe '.menus' do
|
10
|
+
subject { described.menus }
|
11
|
+
|
12
|
+
it { subject.must_be_instance_of(described) }
|
13
|
+
end
|
14
|
+
|
15
|
+
end # Menus
|
16
|
+
|
17
|
+
end # Vedeu
|
@@ -39,36 +39,28 @@ module Vedeu
|
|
39
39
|
it { instance.instance_variable_get('@storage').must_equal(storage) }
|
40
40
|
end
|
41
41
|
|
42
|
-
describe '#
|
43
|
-
subject { instance.
|
44
|
-
|
45
|
-
it 'returns the whole repository' do
|
46
|
-
subject.must_equal(storage)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe '#each' do
|
51
|
-
subject { instance.each }
|
52
|
-
|
53
|
-
it { subject.must_be_instance_of(Enumerator) }
|
54
|
-
end
|
42
|
+
describe '#find' do
|
43
|
+
subject { instance.find(model_name) }
|
55
44
|
|
56
|
-
|
57
|
-
|
45
|
+
context 'when the model cannot be found' do
|
46
|
+
let(:model_name) { 'not_found' }
|
58
47
|
|
59
|
-
|
60
|
-
it { subject.must_equal(true) }
|
48
|
+
it { subject.must_be_instance_of(NilClass) }
|
61
49
|
end
|
62
50
|
|
63
|
-
context 'when the
|
64
|
-
let(:
|
51
|
+
context 'when the model is found' do
|
52
|
+
let(:model_instance) { model.new('terbium') }
|
65
53
|
|
66
|
-
|
54
|
+
before { instance.store(model_instance) }
|
55
|
+
|
56
|
+
it 'returns the stored model' do
|
57
|
+
subject.must_equal(model_instance)
|
58
|
+
end
|
67
59
|
end
|
68
60
|
end
|
69
61
|
|
70
|
-
describe '#find' do
|
71
|
-
subject { instance.find(model_name) }
|
62
|
+
describe '#find!' do
|
63
|
+
subject { instance.find!(model_name) }
|
72
64
|
|
73
65
|
context 'when the model cannot be found' do
|
74
66
|
let(:model_name) { 'not_found' }
|
@@ -92,8 +84,6 @@ module Vedeu
|
|
92
84
|
|
93
85
|
subject { instance.find_or_create(model_name) }
|
94
86
|
|
95
|
-
it { instance.find_or_create('zinc').must_be_instance_of(Vedeu::TestModel) }
|
96
|
-
|
97
87
|
context 'when the model exists' do
|
98
88
|
let(:model_name) { 'niobium' }
|
99
89
|
|
@@ -119,7 +109,7 @@ module Vedeu
|
|
119
109
|
context 'when the storage is a Hash' do
|
120
110
|
it 'returns a collection of the names of all the registered entities' do
|
121
111
|
repo = RepositoriesTestClass.new
|
122
|
-
repo.add(
|
112
|
+
repo.add('rutherfordium' => { name: 'rutherfordium' })
|
123
113
|
|
124
114
|
repo.registered.must_equal(['rutherfordium'])
|
125
115
|
end
|
@@ -163,7 +153,7 @@ module Vedeu
|
|
163
153
|
|
164
154
|
it 'returns false when the model is not registered' do
|
165
155
|
repo = RepositoriesTestClass.new
|
166
|
-
repo.add(
|
156
|
+
repo.add(name: 'samarium')
|
167
157
|
|
168
158
|
repo.registered?('terbium').must_equal(false)
|
169
159
|
end
|
@@ -200,16 +190,6 @@ module Vedeu
|
|
200
190
|
end
|
201
191
|
end
|
202
192
|
|
203
|
-
describe '#reset' do
|
204
|
-
it 'returns a Hash' do
|
205
|
-
instance.reset.must_be_instance_of(Hash)
|
206
|
-
end
|
207
|
-
|
208
|
-
it 'resets the repository' do
|
209
|
-
instance.reset.must_equal({})
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
193
|
describe '#store' do
|
214
194
|
subject { instance.store(model_instance) }
|
215
195
|
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe AssociativeStore do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::AssociativeStore }
|
8
|
+
let(:instance) { described.new(storage) }
|
9
|
+
let(:storage) { {} }
|
10
|
+
|
11
|
+
describe '#initialize' do
|
12
|
+
it { instance.must_be_instance_of(Vedeu::AssociativeStore) }
|
13
|
+
it { instance.instance_variable_get('@storage').must_equal(storage) }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#load' do
|
17
|
+
let(:_name) {}
|
18
|
+
|
19
|
+
subject { instance.load(_name) }
|
20
|
+
|
21
|
+
context 'when the storage is empty' do
|
22
|
+
it { subject.must_equal(nil) }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when the storage is not empty' do
|
26
|
+
let(:storage) { { hydrogen: '1', helium: '2' } }
|
27
|
+
|
28
|
+
context 'when the named entry exists' do
|
29
|
+
let(:_name) { :helium }
|
30
|
+
|
31
|
+
it { subject.must_equal('2') }
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when the named entry does not exist' do
|
35
|
+
let(:_name) { :beryllium }
|
36
|
+
|
37
|
+
it { subject.must_equal(nil) }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#save' do
|
43
|
+
let(:data) { [:some_data] }
|
44
|
+
let(:_name) {}
|
45
|
+
|
46
|
+
subject { instance.save(data, _name) }
|
47
|
+
|
48
|
+
context 'when a name is given' do
|
49
|
+
let(:_name) { :hydrogen }
|
50
|
+
|
51
|
+
it { subject.must_equal(hydrogen: [:some_data]) }
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'when a name is not given' do
|
55
|
+
context 'when the data respond to name' do
|
56
|
+
let(:data) { ModelTestClass.new(name: 'helium')}
|
57
|
+
|
58
|
+
it { subject.key?('helium').must_equal(true) }
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'when the data does not respond to name' do
|
62
|
+
it { subject.must_equal({}) }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end # AssociativeStore
|
68
|
+
|
69
|
+
end # Vedeu
|
@@ -0,0 +1,135 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe ConveyorStore do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::ConveyorStore }
|
8
|
+
let(:instance) { described.new(storage) }
|
9
|
+
let(:storage) { [] }
|
10
|
+
|
11
|
+
describe 'alias methods' do
|
12
|
+
it { instance.must_respond_to(:current) }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#initialize' do
|
16
|
+
it { instance.must_be_instance_of(Vedeu::ConveyorStore) }
|
17
|
+
it { instance.instance_variable_get('@storage').must_equal(storage) }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#load' do
|
21
|
+
subject { instance.load }
|
22
|
+
|
23
|
+
context 'when the storage is empty' do
|
24
|
+
it { subject.must_equal(nil) }
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when the storage is not empty' do
|
28
|
+
let(:storage) { [:hydrogen] }
|
29
|
+
|
30
|
+
it { subject.must_equal(:hydrogen) }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#load_named' do
|
35
|
+
let(:_name) {}
|
36
|
+
|
37
|
+
subject { instance.load_named(_name) }
|
38
|
+
|
39
|
+
context 'when the storage is empty' do
|
40
|
+
it { subject.must_equal(nil) }
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'when the storage is not empty' do
|
44
|
+
let(:storage) { [:lithium, :helium, :hydrogen] }
|
45
|
+
|
46
|
+
context 'when the named entry exists' do
|
47
|
+
let(:_name) { :helium }
|
48
|
+
|
49
|
+
it { subject.must_equal(:helium) }
|
50
|
+
|
51
|
+
it 'rotates the store to the named entry' do
|
52
|
+
instance.storage.must_equal([:lithium, :helium, :hydrogen])
|
53
|
+
subject
|
54
|
+
instance.storage.must_equal([:helium, :hydrogen, :lithium])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'when the named entry does not exist' do
|
59
|
+
let(:_name) { :beryllium }
|
60
|
+
|
61
|
+
it { subject.must_equal(nil) }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '#load_next' do
|
67
|
+
subject { instance.load_next }
|
68
|
+
|
69
|
+
context 'when the storage is empty' do
|
70
|
+
it { subject.must_equal(nil) }
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'when the storage is not empty' do
|
74
|
+
let(:storage) { [:lithium, :helium, :hydrogen] }
|
75
|
+
|
76
|
+
it { subject.must_equal(:helium) }
|
77
|
+
|
78
|
+
it 'rotates the store' do
|
79
|
+
instance.storage.must_equal([:lithium, :helium, :hydrogen])
|
80
|
+
instance.load_next
|
81
|
+
instance.load_next
|
82
|
+
instance.storage.must_equal([:hydrogen, :lithium, :helium])
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe '#load_previous' do
|
88
|
+
subject { instance.load_previous }
|
89
|
+
|
90
|
+
context 'when the storage is empty' do
|
91
|
+
it { subject.must_equal(nil) }
|
92
|
+
end
|
93
|
+
|
94
|
+
context 'when the storage is not empty' do
|
95
|
+
let(:storage) { [:lithium, :helium, :hydrogen] }
|
96
|
+
|
97
|
+
it { subject.must_equal(:hydrogen) }
|
98
|
+
|
99
|
+
it 'rotates the store' do
|
100
|
+
instance.storage.must_equal([:lithium, :helium, :hydrogen])
|
101
|
+
instance.load_previous
|
102
|
+
instance.load_previous
|
103
|
+
instance.storage.must_equal([:helium, :hydrogen, :lithium])
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe '#save' do
|
109
|
+
let(:data) { :beryllium }
|
110
|
+
let(:front) { false }
|
111
|
+
|
112
|
+
subject { instance.save(data, front) }
|
113
|
+
|
114
|
+
context 'when the storage is empty' do
|
115
|
+
it { subject.must_equal([:beryllium]) }
|
116
|
+
end
|
117
|
+
|
118
|
+
context 'when the storage is not empty' do
|
119
|
+
let(:storage) { [:lithium, :helium, :hydrogen] }
|
120
|
+
|
121
|
+
context 'and `front` is false' do
|
122
|
+
it { subject.must_equal([:beryllium, :lithium, :helium, :hydrogen]) }
|
123
|
+
end
|
124
|
+
|
125
|
+
context 'and `front` is true' do
|
126
|
+
let(:front) { true }
|
127
|
+
|
128
|
+
it { subject.must_equal([:lithium, :helium, :hydrogen, :beryllium]) }
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
end # ConveyorStore
|
134
|
+
|
135
|
+
end # Vedeu
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe FifoStore do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::FifoStore }
|
8
|
+
let(:instance) { described.new(storage) }
|
9
|
+
let(:storage) { [] }
|
10
|
+
|
11
|
+
describe '#initialize' do
|
12
|
+
it { instance.must_be_instance_of(Vedeu::FifoStore) }
|
13
|
+
it { instance.instance_variable_get('@storage').must_equal(storage) }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#load' do
|
17
|
+
subject { instance.load }
|
18
|
+
|
19
|
+
context 'when the storage is empty' do
|
20
|
+
it { subject.must_equal(nil) }
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when the storage is not empty' do
|
24
|
+
let(:storage) { [:lithium, :helium, :hydrogen] }
|
25
|
+
|
26
|
+
it { subject.must_equal(:hydrogen) }
|
27
|
+
|
28
|
+
it 'removes the item from storage on retrieval' do
|
29
|
+
instance.size.must_equal(3)
|
30
|
+
subject
|
31
|
+
instance.size.must_equal(2)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#save' do
|
37
|
+
let(:data) { :beryllium }
|
38
|
+
let(:storage) { [:lithium, :helium, :hydrogen] }
|
39
|
+
|
40
|
+
subject { instance.save(data) }
|
41
|
+
|
42
|
+
it { subject.must_equal([:beryllium, :lithium, :helium, :hydrogen]) }
|
43
|
+
end
|
44
|
+
|
45
|
+
end # FifoStore
|
46
|
+
|
47
|
+
end # Vedeu
|