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,36 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# Allows the storing of view buffers.
|
4
|
+
#
|
5
|
+
class Buffers < Repository
|
6
|
+
|
7
|
+
# @return [Vedeu::Buffers]
|
8
|
+
def self.buffers
|
9
|
+
@buffers ||= reset!
|
10
|
+
end
|
11
|
+
|
12
|
+
# @return [Vedeu::Buffers]
|
13
|
+
def self.repository
|
14
|
+
Vedeu.buffers
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [Vedeu::Buffers]
|
18
|
+
def self.reset!
|
19
|
+
@buffers = Vedeu::Buffers.register_repository(Vedeu::Buffer)
|
20
|
+
end
|
21
|
+
|
22
|
+
# @param name [String] The name of buffer to clear.
|
23
|
+
# @return [void]
|
24
|
+
def clear(name)
|
25
|
+
find!(name).clear
|
26
|
+
end
|
27
|
+
|
28
|
+
# @param name [String] The name of buffer to render.
|
29
|
+
# @return [void]
|
30
|
+
def render(name)
|
31
|
+
find!(name).render
|
32
|
+
end
|
33
|
+
|
34
|
+
end # Buffers
|
35
|
+
|
36
|
+
end # Vedeu
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# Allows the storing of HTML/CSS colours and their respective escape
|
4
|
+
# sequences.
|
5
|
+
#
|
6
|
+
class Colours
|
7
|
+
|
8
|
+
# @!attribute [r] storage
|
9
|
+
# @return [Hash<String => String>]
|
10
|
+
attr_reader :storage
|
11
|
+
|
12
|
+
# Returns a new instance of Vedeu::Colours.
|
13
|
+
#
|
14
|
+
# @return [Vedeu::Colours]
|
15
|
+
def initialize
|
16
|
+
@storage = {}
|
17
|
+
end
|
18
|
+
|
19
|
+
# Registers a colour with respective escape sequence.
|
20
|
+
#
|
21
|
+
# @return [String]
|
22
|
+
def register(colour, escape_sequence)
|
23
|
+
storage.store(colour, escape_sequence)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns a boolean indicating whether the colour has been registered.
|
27
|
+
#
|
28
|
+
# @return [Boolean]
|
29
|
+
def registered?(colour)
|
30
|
+
storage.key?(colour)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Removes all stored colours.
|
34
|
+
#
|
35
|
+
# @return [Hash]
|
36
|
+
def reset!
|
37
|
+
storage.clear
|
38
|
+
end
|
39
|
+
|
40
|
+
# Retrieves a registered colour.
|
41
|
+
#
|
42
|
+
# @return [String]
|
43
|
+
def retrieve(colour)
|
44
|
+
storage.fetch(colour, '')
|
45
|
+
end
|
46
|
+
|
47
|
+
# Retrieves a registered colour, or registers the colour with its respective
|
48
|
+
# escape sequence.
|
49
|
+
#
|
50
|
+
# @return [String]
|
51
|
+
def retrieve_or_register(colour, escape_sequence)
|
52
|
+
if registered?(colour)
|
53
|
+
retrieve(colour)
|
54
|
+
|
55
|
+
else
|
56
|
+
register(colour, escape_sequence)
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end # Colours
|
62
|
+
|
63
|
+
end # Vedeu
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# Allows the storing of each interface's cursor.
|
4
|
+
#
|
5
|
+
class Cursors < Repository
|
6
|
+
|
7
|
+
# @return [Vedeu::Cursors]
|
8
|
+
def self.cursors
|
9
|
+
@cursors ||= reset!
|
10
|
+
end
|
11
|
+
|
12
|
+
# @return [Vedeu::Cursor]
|
13
|
+
def self.cursor
|
14
|
+
cursors.current
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [Vedeu::Cursors]
|
18
|
+
def self.repository
|
19
|
+
Vedeu.cursors
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Vedeu::Cursors]
|
23
|
+
def self.reset!
|
24
|
+
@cursors = Vedeu::Cursors.register_repository(Vedeu::Cursor)
|
25
|
+
end
|
26
|
+
|
27
|
+
end # Cursors
|
28
|
+
|
29
|
+
end # Vedeu
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# Allows the storing of events.
|
4
|
+
#
|
5
|
+
class EventsRepository < Repository
|
6
|
+
|
7
|
+
# @return [Vedeu::EventsRepository]
|
8
|
+
def self.events
|
9
|
+
@events ||= reset!
|
10
|
+
end
|
11
|
+
|
12
|
+
# @return [Vedeu::EventsRepository]
|
13
|
+
def self.repository
|
14
|
+
Vedeu.events
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [Vedeu::EventsRepository]
|
18
|
+
def self.reset!
|
19
|
+
@events = Vedeu::EventsRepository.new(Vedeu::Events)
|
20
|
+
end
|
21
|
+
|
22
|
+
end # EventsRepository
|
23
|
+
|
24
|
+
end # Vedeu
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# Store foreground colour escape sequences by HTML/CSS code.
|
4
|
+
#
|
5
|
+
class ForegroundColours < Colours
|
6
|
+
|
7
|
+
# @return [Vedeu::ForegroundColours]
|
8
|
+
def self.foreground_colours
|
9
|
+
@foreground_colours ||= new
|
10
|
+
end
|
11
|
+
|
12
|
+
end # ForegroundColours
|
13
|
+
|
14
|
+
end # Vedeu
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# Allows the storing of interface/view geometry independent of the interface
|
4
|
+
# instance.
|
5
|
+
#
|
6
|
+
class Geometries < Repository
|
7
|
+
|
8
|
+
# @return [Vedeu::Geometries]
|
9
|
+
def self.geometries
|
10
|
+
@geometries ||= reset!
|
11
|
+
end
|
12
|
+
|
13
|
+
# @return [Vedeu::Geometries]
|
14
|
+
def self.repository
|
15
|
+
Vedeu.geometries
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [Vedeu::Geometries]
|
19
|
+
def self.reset!
|
20
|
+
@geometries = Vedeu::Geometries.new(Vedeu::Geometry)
|
21
|
+
end
|
22
|
+
|
23
|
+
# @param name [String] The name of the stored geometry.
|
24
|
+
# @return [Vedeu::Geometry|Vedeu::NullGeometry]
|
25
|
+
def by_name(name)
|
26
|
+
if registered?(name)
|
27
|
+
find(name)
|
28
|
+
|
29
|
+
else
|
30
|
+
Vedeu::NullGeometry.new
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end # Geometries
|
36
|
+
|
37
|
+
end # Vedeu
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# Allows the storing of view groups.
|
4
|
+
#
|
5
|
+
class Groups < Repository
|
6
|
+
|
7
|
+
# @return [Vedeu::Groups]
|
8
|
+
def self.groups
|
9
|
+
@groups ||= reset!
|
10
|
+
end
|
11
|
+
|
12
|
+
# @return [Vedeu::Groups]
|
13
|
+
def self.repository
|
14
|
+
Vedeu.groups
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [Vedeu::Groups]
|
18
|
+
def self.reset!
|
19
|
+
@groups = Vedeu::Groups.new(Vedeu::Group)
|
20
|
+
end
|
21
|
+
|
22
|
+
end # Groups
|
23
|
+
|
24
|
+
end # Vedeu
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# Allows the storing of interfaces and views.
|
4
|
+
#
|
5
|
+
class InterfacesRepository < Repository
|
6
|
+
|
7
|
+
# @return [Vedeu::InterfacesRepository]
|
8
|
+
def self.interfaces
|
9
|
+
@interfaces ||= reset!
|
10
|
+
end
|
11
|
+
|
12
|
+
# @return [Vedeu::InterfacesRepository]
|
13
|
+
def self.repository
|
14
|
+
Vedeu.interfaces
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [Vedeu::InterfacesRepository]
|
18
|
+
def self.reset!
|
19
|
+
@interfaces = Vedeu::InterfacesRepository.new(Vedeu::Interface)
|
20
|
+
end
|
21
|
+
|
22
|
+
end # InterfacesRepository
|
23
|
+
|
24
|
+
end # Vedeu
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# Allows the storing of keymaps.
|
4
|
+
#
|
5
|
+
class Keymaps < Repository
|
6
|
+
|
7
|
+
# @return [Vedeu::Keymaps]
|
8
|
+
def self.keymaps
|
9
|
+
@keymaps ||= reset!
|
10
|
+
end
|
11
|
+
|
12
|
+
# @return [Vedeu::Keymaps]
|
13
|
+
def self.repository
|
14
|
+
Vedeu.keymaps
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [Vedeu::Keymaps]
|
18
|
+
def self.reset!
|
19
|
+
@keymaps = Vedeu::Keymaps.new(Vedeu::Keymap)
|
20
|
+
end
|
21
|
+
|
22
|
+
end # Keymaps
|
23
|
+
|
24
|
+
end # Vedeu
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# Allows the storing of menus by name.
|
4
|
+
#
|
5
|
+
class Menus < Repository
|
6
|
+
|
7
|
+
# @return [Vedeu::Menus]
|
8
|
+
def self.menus
|
9
|
+
@menus ||= reset!
|
10
|
+
end
|
11
|
+
|
12
|
+
# @return [Vedeu::Menus]
|
13
|
+
def self.repository
|
14
|
+
Vedeu.menus
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [Vedeu::Menus]
|
18
|
+
def self.reset!
|
19
|
+
@menus = Vedeu::Menus.new(Vedeu::Menu)
|
20
|
+
end
|
21
|
+
|
22
|
+
end # Menus
|
23
|
+
|
24
|
+
end # Vedeu
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require 'vedeu/exceptions'
|
2
1
|
require 'vedeu/models/all'
|
2
|
+
require 'vedeu/storage/store'
|
3
3
|
require 'vedeu/support/common'
|
4
4
|
|
5
5
|
module Vedeu
|
@@ -14,7 +14,7 @@ module Vedeu
|
|
14
14
|
class Repository
|
15
15
|
|
16
16
|
include Vedeu::Common
|
17
|
-
include
|
17
|
+
include Vedeu::Store
|
18
18
|
|
19
19
|
# @!attribute [r] model
|
20
20
|
# @return [void]
|
@@ -24,21 +24,24 @@ module Vedeu
|
|
24
24
|
# @return [void]
|
25
25
|
attr_reader :storage
|
26
26
|
|
27
|
+
def self.register_repository(model = nil, storage = {})
|
28
|
+
new(model, storage).tap do |klass|
|
29
|
+
Vedeu::Repositories.register(klass.repository)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
27
33
|
# Returns a new instance of Vedeu::Repository.
|
28
34
|
#
|
29
35
|
# @param model [Class]
|
30
36
|
# @param storage [Class|Hash]
|
31
37
|
# @return [Vedeu::Repository]
|
32
38
|
def initialize(model = nil, storage = {})
|
33
|
-
@model
|
34
|
-
@storage
|
39
|
+
@model = model
|
40
|
+
@storage = storage
|
35
41
|
end
|
36
42
|
|
37
|
-
|
38
|
-
|
39
|
-
# @return [Array|Hash|Set]
|
40
|
-
def all
|
41
|
-
storage
|
43
|
+
def repository
|
44
|
+
self.class # .name
|
42
45
|
end
|
43
46
|
|
44
47
|
# Return the model for the interface currently in focus.
|
@@ -48,27 +51,22 @@ module Vedeu
|
|
48
51
|
find_or_create(Vedeu.focus) if Vedeu.focus
|
49
52
|
end
|
50
53
|
|
51
|
-
#
|
52
|
-
def each(&block)
|
53
|
-
storage.each(&block)
|
54
|
-
end
|
55
|
-
|
56
|
-
# Return a boolean indicating whether the storage is empty.
|
54
|
+
# Find the model by name.
|
57
55
|
#
|
58
|
-
# @
|
59
|
-
|
60
|
-
|
56
|
+
# @param name [String]
|
57
|
+
# @return [Hash<String => Object>|NilClass]
|
58
|
+
def find(name)
|
59
|
+
storage[name]
|
61
60
|
end
|
62
61
|
|
63
|
-
# Find the model attributes by name
|
62
|
+
# Find the model attributes by name, raises an exception if the model cannot
|
63
|
+
# be found.
|
64
64
|
#
|
65
65
|
# @param name [String]
|
66
66
|
# @raise [ModelNotFound] When the model cannot be found with this name.
|
67
67
|
# @return [Hash<String => Object>]
|
68
|
-
def find(name)
|
69
|
-
|
70
|
-
fail ModelNotFound, "Cannot find model by name: '#{name}'"
|
71
|
-
end
|
68
|
+
def find!(name)
|
69
|
+
find(name) || fail(ModelNotFound, "Cannot find model by name: '#{name}'")
|
72
70
|
end
|
73
71
|
|
74
72
|
# Find a model by name, registers the model by name if not found.
|
@@ -80,7 +78,8 @@ module Vedeu
|
|
80
78
|
find(name)
|
81
79
|
|
82
80
|
else
|
83
|
-
Vedeu.log(type: :store,
|
81
|
+
Vedeu.log(type: :store,
|
82
|
+
message: "Model (#{model}) not found, registering: '#{name}'")
|
84
83
|
|
85
84
|
model.new(name).store
|
86
85
|
end
|
@@ -131,13 +130,6 @@ module Vedeu
|
|
131
130
|
alias_method :delete, :remove
|
132
131
|
alias_method :deregister, :remove
|
133
132
|
|
134
|
-
# Reset the repository.
|
135
|
-
#
|
136
|
-
# @return [Array|Hash|Set]
|
137
|
-
def reset
|
138
|
-
@storage = in_memory
|
139
|
-
end
|
140
|
-
|
141
133
|
# Stores the model instance by name in the repository of the model.
|
142
134
|
#
|
143
135
|
# @param model [void] A model instance.
|
@@ -145,9 +137,9 @@ module Vedeu
|
|
145
137
|
# @return [void] The model instance which was stored.
|
146
138
|
def store(model)
|
147
139
|
fail MissingRequired, "Cannot store model '#{model.class}' without a " \
|
148
|
-
|
140
|
+
'name attribute.' unless defined_value?(model.name)
|
149
141
|
|
150
|
-
|
142
|
+
log_store(model)
|
151
143
|
|
152
144
|
storage[model.name] = model
|
153
145
|
end
|
@@ -158,13 +150,7 @@ module Vedeu
|
|
158
150
|
# @param name [String]
|
159
151
|
# @return [|NilClass]
|
160
152
|
def use(name)
|
161
|
-
if registered?(name)
|
162
|
-
find(name)
|
163
|
-
|
164
|
-
else
|
165
|
-
nil
|
166
|
-
|
167
|
-
end
|
153
|
+
find(name) if registered?(name)
|
168
154
|
end
|
169
155
|
|
170
156
|
private
|
@@ -175,14 +161,10 @@ module Vedeu
|
|
175
161
|
end
|
176
162
|
|
177
163
|
# @return [String]
|
178
|
-
def
|
179
|
-
|
180
|
-
:update
|
164
|
+
def log_store(model)
|
165
|
+
type = registered?(model.name) ? :update : :create
|
181
166
|
|
182
|
-
|
183
|
-
:create
|
184
|
-
|
185
|
-
end
|
167
|
+
Vedeu.log(type: type, message: "#{model.class.name}: '#{model.name}'")
|
186
168
|
end
|
187
169
|
|
188
170
|
end # Repository
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# Name/Value storage.
|
4
|
+
#
|
5
|
+
# name: [value]
|
6
|
+
#
|
7
|
+
class AssociativeStore
|
8
|
+
|
9
|
+
include Vedeu::Store
|
10
|
+
|
11
|
+
# @param storage [Hash]
|
12
|
+
# @return [Vedeu::AssociativeStore]
|
13
|
+
def initialize(storage = {})
|
14
|
+
@storage = storage
|
15
|
+
end
|
16
|
+
|
17
|
+
# @param name [String]
|
18
|
+
def load(name)
|
19
|
+
return nil if empty?
|
20
|
+
|
21
|
+
storage[name]
|
22
|
+
end
|
23
|
+
|
24
|
+
# @param data [Object]
|
25
|
+
# @param name [String|Symbol]
|
26
|
+
def save(data, name = nil)
|
27
|
+
if name
|
28
|
+
storage[name] = data
|
29
|
+
|
30
|
+
elsif data.respond_to?(:name)
|
31
|
+
storage[data.name] = data
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
storage
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
# @return [Hash]
|
41
|
+
def in_memory
|
42
|
+
{}
|
43
|
+
end
|
44
|
+
|
45
|
+
end # AssociativeStore
|
46
|
+
|
47
|
+
end # Vedeu
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# Conveyor belt like storage. The belt can move forward (`load_next`) or
|
4
|
+
# backwards (`load_previous`), or a named entry can be retrieved.
|
5
|
+
#
|
6
|
+
class ConveyorStore
|
7
|
+
|
8
|
+
include Vedeu::Store
|
9
|
+
|
10
|
+
# @param storage [Array]
|
11
|
+
# @return [Vedeu::ConveyorStore]
|
12
|
+
def initialize(storage = [])
|
13
|
+
@storage = storage
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [Object]
|
17
|
+
def load
|
18
|
+
storage.first
|
19
|
+
end
|
20
|
+
alias_method :current, :load
|
21
|
+
|
22
|
+
# @param name [String]
|
23
|
+
# @return [Object]
|
24
|
+
def load_named(name)
|
25
|
+
return nil if empty?
|
26
|
+
|
27
|
+
return nil unless storage.include?(name)
|
28
|
+
|
29
|
+
storage.rotate!(storage.index(name))
|
30
|
+
|
31
|
+
load
|
32
|
+
end
|
33
|
+
|
34
|
+
# @return [Object]
|
35
|
+
def load_next
|
36
|
+
storage.rotate!
|
37
|
+
|
38
|
+
load
|
39
|
+
end
|
40
|
+
|
41
|
+
# @return [Object]
|
42
|
+
def load_previous
|
43
|
+
storage.rotate!(-1)
|
44
|
+
|
45
|
+
load
|
46
|
+
end
|
47
|
+
|
48
|
+
# @param data [Object]
|
49
|
+
# @param front [Boolean]
|
50
|
+
def save(data, front = false)
|
51
|
+
if front
|
52
|
+
storage.push(data)
|
53
|
+
|
54
|
+
else
|
55
|
+
storage.unshift(data)
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
# @return [Array]
|
63
|
+
def in_memory
|
64
|
+
[]
|
65
|
+
end
|
66
|
+
|
67
|
+
end # ConveyorStore
|
68
|
+
|
69
|
+
end # Vedeu
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# First-in first-out storage.
|
4
|
+
#
|
5
|
+
# in -> [3] -> [2] -> [1] -> out
|
6
|
+
#
|
7
|
+
class FifoStore
|
8
|
+
|
9
|
+
include Vedeu::Store
|
10
|
+
|
11
|
+
# @param storage [Array]
|
12
|
+
# @return [Vedeu::FifoStore]
|
13
|
+
def initialize(storage = [])
|
14
|
+
@storage = storage
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [Object]
|
18
|
+
def load
|
19
|
+
storage.pop
|
20
|
+
end
|
21
|
+
|
22
|
+
# @param data [Object]
|
23
|
+
# @return [Array<Object>]
|
24
|
+
def save(data)
|
25
|
+
storage.unshift(data)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
# @return [Array]
|
31
|
+
def in_memory
|
32
|
+
[]
|
33
|
+
end
|
34
|
+
|
35
|
+
end # FifoStore
|
36
|
+
|
37
|
+
end # Vedeu
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# Provides generic repository related behaviour.
|
4
|
+
#
|
5
|
+
module Store
|
6
|
+
|
7
|
+
include Enumerable
|
8
|
+
|
9
|
+
# @param block [Proc]
|
10
|
+
# @return [Enumerator]
|
11
|
+
def each(&block)
|
12
|
+
storage.each(&block)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Returns a boolean indicating whether the named model is registered.
|
16
|
+
#
|
17
|
+
# @param name [String]
|
18
|
+
# @return [Boolean]
|
19
|
+
def exists?(name)
|
20
|
+
return false if empty? || name.nil? || name.empty?
|
21
|
+
|
22
|
+
storage.include?(name)
|
23
|
+
end
|
24
|
+
alias_method :registered?, :exists?
|
25
|
+
|
26
|
+
# Return a boolean indicating whether the storage is empty.
|
27
|
+
#
|
28
|
+
# @return [Boolean]
|
29
|
+
def empty?
|
30
|
+
storage.empty?
|
31
|
+
end
|
32
|
+
|
33
|
+
# Remove all currently stored data.
|
34
|
+
#
|
35
|
+
# @return [Array|Hash|Set]
|
36
|
+
def reset
|
37
|
+
@storage = in_memory
|
38
|
+
end
|
39
|
+
|
40
|
+
# Return the number of entries stored.
|
41
|
+
#
|
42
|
+
# @return [Fixnum]
|
43
|
+
def size
|
44
|
+
storage.size
|
45
|
+
end
|
46
|
+
|
47
|
+
# Return whole repository; provides raw access to the storage for this
|
48
|
+
# repository.
|
49
|
+
#
|
50
|
+
# @return [Array|Hash|Set]
|
51
|
+
def storage
|
52
|
+
@storage ||= in_memory
|
53
|
+
end
|
54
|
+
alias_method :all, :storage
|
55
|
+
|
56
|
+
end # Store
|
57
|
+
|
58
|
+
end # Vedeu
|
data/lib/vedeu/support/all.rb
CHANGED
@@ -1,10 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
require 'vedeu/support/trace'
|
7
|
-
require 'vedeu/support/visible'
|
8
|
-
|
9
|
-
module Vedeu
|
10
|
-
end # Vedeu
|
1
|
+
require_relative 'common'
|
2
|
+
require_relative 'template'
|
3
|
+
require_relative 'terminal'
|
4
|
+
require_relative 'trace'
|
5
|
+
require_relative 'visibility'
|