vedeu 0.6.9 → 0.6.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/lib/vedeu/all.rb +3 -3
- data/lib/vedeu/api/external.rb +194 -0
- data/lib/vedeu/api/internal.rb +173 -0
- data/lib/vedeu/application/controller.rb +3 -2
- data/lib/vedeu/bindings/application.rb +1 -1
- data/lib/vedeu/bindings/drb.rb +2 -3
- data/lib/vedeu/bindings/movement.rb +1 -1
- data/lib/vedeu/buffers/all.rb +0 -2
- data/lib/vedeu/colours/translator.rb +2 -1
- data/lib/vedeu/common.rb +4 -2
- data/lib/vedeu/configuration/api.rb +1 -1
- data/lib/vedeu/configuration/cli.rb +1 -1
- data/lib/vedeu/cursors/repository.rb +1 -1
- data/lib/vedeu/editor/insert.rb +12 -13
- data/lib/vedeu/geometry/position.rb +1 -1
- data/lib/vedeu/models/cell.rb +35 -21
- data/lib/vedeu/models/escape.rb +18 -1
- data/lib/vedeu/models/page.rb +20 -10
- data/lib/vedeu/models/row.rb +18 -8
- data/lib/vedeu/models/views/char.rb +9 -7
- data/lib/vedeu/models/views/view.rb +1 -1
- data/lib/vedeu/output/compressor.rb +22 -14
- data/lib/vedeu/output/output.rb +1 -10
- data/lib/vedeu/output/renderers/escape_sequence.rb +8 -4
- data/lib/vedeu/output/renderers/file.rb +7 -23
- data/lib/vedeu/output/renderers/html.rb +47 -26
- data/lib/vedeu/output/renderers/json.rb +11 -16
- data/lib/vedeu/output/renderers/null.rb +1 -1
- data/lib/vedeu/output/renderers/renderer_options.rb +2 -1
- data/lib/vedeu/output/renderers/terminal.rb +7 -15
- data/lib/vedeu/output/renderers/text.rb +1 -1
- data/lib/vedeu/output/viewport.rb +154 -143
- data/lib/vedeu/repositories/collection.rb +2 -2
- data/lib/vedeu/repositories/model.rb +25 -26
- data/lib/vedeu/repositories/registerable.rb +9 -8
- data/lib/vedeu/repositories/repository.rb +21 -16
- data/lib/vedeu/repositories/store.rb +6 -4
- data/lib/vedeu/runtime/bootstrap.rb +7 -5
- data/lib/vedeu/runtime/main_loop.rb +2 -0
- data/lib/vedeu/runtime/router.rb +155 -149
- data/lib/vedeu/templating/decoder.rb +8 -5
- data/lib/vedeu/templating/encoder.rb +6 -4
- data/lib/vedeu/templating/template.rb +2 -2
- data/lib/vedeu/templating/view_template.rb +8 -7
- data/lib/vedeu/terminal/buffer.rb +132 -0
- data/lib/vedeu/terminal/terminal.rb +0 -5
- data/lib/vedeu/version.rb +1 -1
- data/lib/vedeu.rb +2 -2
- data/out_ +50 -0
- data/test/lib/vedeu/api/external_test.rb +62 -0
- data/test/lib/vedeu/{internal_api_test.rb → api/internal_test.rb} +6 -2
- data/test/lib/vedeu/application/controller_test.rb +3 -3
- data/test/lib/vedeu/bindings/application_test.rb +2 -2
- data/test/lib/vedeu/models/cell_test.rb +48 -17
- data/test/lib/vedeu/models/escape_test.rb +29 -7
- data/test/lib/vedeu/models/page_test.rb +70 -50
- data/test/lib/vedeu/models/row_test.rb +40 -20
- data/test/lib/vedeu/output/compressor_test.rb +12 -12
- data/test/lib/vedeu/output/output_test.rb +17 -23
- data/test/lib/vedeu/output/renderers/escape_sequence_test.rb +15 -11
- data/test/lib/vedeu/output/renderers/html_test.rb +66 -68
- data/test/lib/vedeu/output/renderers/json_test.rb +36 -83
- data/test/lib/vedeu/output/renderers/terminal_test.rb +22 -2
- data/test/lib/vedeu/output/viewport_test.rb +201 -197
- data/test/lib/vedeu/runtime/router_test.rb +144 -140
- data/test/lib/vedeu/terminal/buffer_test.rb +307 -0
- data/test/support/examples/material_colours_app.rb +2 -2
- data/test/support/templates/html_renderer.vedeu +24 -0
- metadata +14 -17
- data/lib/vedeu/api.rb +0 -190
- data/lib/vedeu/buffers/virtual_buffer.rb +0 -136
- data/lib/vedeu/buffers/virtual_buffers.rb +0 -77
- data/lib/vedeu/internal_api.rb +0 -173
- data/lib/vedeu/terminal/content.rb +0 -88
- data/test/lib/vedeu/api_test.rb +0 -58
- data/test/lib/vedeu/buffers/virtual_buffer_test.rb +0 -148
- data/test/lib/vedeu/buffers/virtual_buffers_test.rb +0 -73
- data/test/lib/vedeu/terminal/content_test.rb +0 -108
|
@@ -1,166 +1,177 @@
|
|
|
1
1
|
module Vedeu
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
#
|
|
5
|
-
# When a buffer has more lines than the defined height, or more columns than
|
|
6
|
-
# the defined width of the interface, the Viewport class provides 'scrolling'
|
|
7
|
-
# via the cursor's position.
|
|
8
|
-
#
|
|
9
|
-
class Viewport
|
|
10
|
-
|
|
11
|
-
extend Forwardable
|
|
12
|
-
|
|
13
|
-
def_delegators :view,
|
|
14
|
-
:lines,
|
|
15
|
-
:name,
|
|
16
|
-
:visible?
|
|
17
|
-
|
|
18
|
-
def_delegators :border,
|
|
19
|
-
:height,
|
|
20
|
-
:width
|
|
21
|
-
|
|
22
|
-
def_delegators :cursor,
|
|
23
|
-
:ox,
|
|
24
|
-
:oy
|
|
25
|
-
|
|
26
|
-
# @param view [Vedeu::Views::View]
|
|
27
|
-
# @return [Array<Array<Vedeu::Views::Char>>]
|
|
28
|
-
def self.render(view)
|
|
29
|
-
new(view).render
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# Returns an instance of Vedeu::Viewport.
|
|
33
|
-
#
|
|
34
|
-
# @param view [Vedeu::Views::View]
|
|
35
|
-
# @return [Vedeu::Viewport]
|
|
36
|
-
def initialize(view)
|
|
37
|
-
@view = view
|
|
38
|
-
end
|
|
3
|
+
module Output
|
|
39
4
|
|
|
40
|
-
#
|
|
5
|
+
# A Viewport is the visible part of the content within an
|
|
6
|
+
# interface.
|
|
7
|
+
#
|
|
8
|
+
# When a buffer has more lines than the defined height, or more
|
|
9
|
+
# columns than the defined width of the interface, this class
|
|
10
|
+
# provides 'scrolling' via the cursor's position.
|
|
41
11
|
#
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
12
|
+
class Viewport
|
|
13
|
+
|
|
14
|
+
extend Forwardable
|
|
15
|
+
|
|
16
|
+
def_delegators :view,
|
|
17
|
+
:lines,
|
|
18
|
+
:name,
|
|
19
|
+
:visible?
|
|
20
|
+
|
|
21
|
+
def_delegators :border,
|
|
22
|
+
:height,
|
|
23
|
+
:width
|
|
24
|
+
|
|
25
|
+
def_delegators :cursor,
|
|
26
|
+
:ox,
|
|
27
|
+
:oy
|
|
28
|
+
|
|
29
|
+
# @param view [Vedeu::Views::View]
|
|
30
|
+
# @return [Array<Array<Vedeu::Views::Char>>]
|
|
31
|
+
def self.render(view)
|
|
32
|
+
new(view).render
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Returns an instance of Vedeu::Output::Viewport.
|
|
36
|
+
#
|
|
37
|
+
# @param view [Vedeu::Views::View]
|
|
38
|
+
# @return [Vedeu::Output::Viewport]
|
|
39
|
+
def initialize(view)
|
|
40
|
+
@view = view
|
|
41
|
+
end
|
|
45
42
|
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
# Returns the content for the view.
|
|
44
|
+
#
|
|
45
|
+
# @return [Array<Array<String>>]
|
|
46
|
+
def render
|
|
47
|
+
return [] unless visible?
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
Vedeu.timer("Rendering: '#{name}'") do
|
|
50
|
+
out = []
|
|
51
|
+
|
|
52
|
+
show.each_with_index do |line, iy|
|
|
53
|
+
line.each_with_index do |column, ix|
|
|
54
|
+
column.position = [by + iy, bx + ix]
|
|
55
|
+
out << column
|
|
56
|
+
end
|
|
53
57
|
end
|
|
58
|
+
|
|
59
|
+
out
|
|
54
60
|
end
|
|
61
|
+
end
|
|
55
62
|
|
|
56
|
-
|
|
63
|
+
# Returns a string representation of the viewport.
|
|
64
|
+
#
|
|
65
|
+
# @return [String]
|
|
66
|
+
def to_s
|
|
67
|
+
render.map(&:to_s).join("\n")
|
|
68
|
+
end
|
|
69
|
+
alias_method :to_str, :to_s
|
|
70
|
+
|
|
71
|
+
protected
|
|
72
|
+
|
|
73
|
+
# @!attribute [r] view
|
|
74
|
+
# @return [Vedeu::Views::View]
|
|
75
|
+
attr_reader :view
|
|
76
|
+
|
|
77
|
+
private
|
|
78
|
+
|
|
79
|
+
# Returns the visible content for the view.
|
|
80
|
+
#
|
|
81
|
+
# @note If there are no lines of content, we return an empty
|
|
82
|
+
# array. If there are no more columns of content we return a
|
|
83
|
+
# space enclosed in an array; this prevents a weird line
|
|
84
|
+
# hopping bug which occurs when the current line has no more
|
|
85
|
+
# content, but subsequent lines do.
|
|
86
|
+
#
|
|
87
|
+
# @return [Array]
|
|
88
|
+
def show
|
|
89
|
+
(lines[rows] || []).map { |line| (line.chars[columns] || []) }
|
|
57
90
|
end
|
|
58
|
-
end
|
|
59
91
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
92
|
+
# Using the current cursor's y position, return a range of
|
|
93
|
+
# visible lines.
|
|
94
|
+
#
|
|
95
|
+
# Scrolls the content vertically when the stored cursor's y
|
|
96
|
+
# position for the interface is outside of the visible area.
|
|
97
|
+
#
|
|
98
|
+
# @note
|
|
99
|
+
# The height is reduced by one as #rows is a range of Array
|
|
100
|
+
# elements.
|
|
101
|
+
#
|
|
102
|
+
# @return [Range]
|
|
103
|
+
def rows
|
|
104
|
+
top...(top + height)
|
|
105
|
+
end
|
|
67
106
|
|
|
68
|
-
|
|
107
|
+
# Using the current cursor's x position, return a range of
|
|
108
|
+
# visible columns.
|
|
109
|
+
#
|
|
110
|
+
# Scrolls the content horizontally when the stored cursor's x
|
|
111
|
+
# position for the interface is outside of the visible area.
|
|
112
|
+
#
|
|
113
|
+
# @note
|
|
114
|
+
# The width is reduced by one as #columns is a range of Array
|
|
115
|
+
# elements.
|
|
116
|
+
#
|
|
117
|
+
# @return [Range]
|
|
118
|
+
def columns
|
|
119
|
+
left...(left + width)
|
|
120
|
+
end
|
|
69
121
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
122
|
+
# @return [Fixnum]
|
|
123
|
+
def left
|
|
124
|
+
@left ||= content_offset(ox, width)
|
|
125
|
+
end
|
|
73
126
|
|
|
74
|
-
|
|
127
|
+
# @return [Fixnum]
|
|
128
|
+
def top
|
|
129
|
+
@top ||= content_offset(oy, height)
|
|
130
|
+
end
|
|
75
131
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
end
|
|
132
|
+
# Returns the offset for the content (the number of rows or
|
|
133
|
+
# columns to change the viewport by on either the y or x axis)
|
|
134
|
+
# determined by the offset (the cursor's y or x offset position.
|
|
135
|
+
#
|
|
136
|
+
# @param offset [Fixnum] The cursor's oy or ox values.
|
|
137
|
+
# @param dimension [Fixnum] Either the height or width.
|
|
138
|
+
# @return [Fixnum]
|
|
139
|
+
def content_offset(offset, dimension)
|
|
140
|
+
if offset >= dimension
|
|
141
|
+
offset - dimension
|
|
87
142
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
# Scrolls the content vertically when the stored cursor's y position for the
|
|
91
|
-
# interface is outside of the visible area.
|
|
92
|
-
#
|
|
93
|
-
# @note
|
|
94
|
-
# The height is reduced by one as #rows is a range of Array elements.
|
|
95
|
-
#
|
|
96
|
-
# @return [Range]
|
|
97
|
-
def rows
|
|
98
|
-
top...(top + height)
|
|
99
|
-
end
|
|
143
|
+
else
|
|
144
|
+
0
|
|
100
145
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
# Scrolls the content horizontally when the stored cursor's x position for
|
|
104
|
-
# the interface is outside of the visible area.
|
|
105
|
-
#
|
|
106
|
-
# @note
|
|
107
|
-
# The width is reduced by one as #columns is a range of Array elements.
|
|
108
|
-
#
|
|
109
|
-
# @return [Range]
|
|
110
|
-
def columns
|
|
111
|
-
left...(left + width)
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
# @return [Fixnum]
|
|
115
|
-
def left
|
|
116
|
-
@left ||= content_offset(ox, width)
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
# @return [Fixnum]
|
|
120
|
-
def top
|
|
121
|
-
@top ||= content_offset(oy, height)
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
# Returns the offset for the content (the number of rows or columns to
|
|
125
|
-
# change the viewport by on either the y or x axis) determined by the offset
|
|
126
|
-
# (the cursor's y or x offset position.
|
|
127
|
-
#
|
|
128
|
-
# @param offset [Fixnum] The cursor's oy or ox values.
|
|
129
|
-
# @param dimension [Fixnum] Either the height or width.
|
|
130
|
-
# @return [Fixnum]
|
|
131
|
-
def content_offset(offset, dimension)
|
|
132
|
-
if offset >= dimension
|
|
133
|
-
offset - dimension
|
|
146
|
+
end
|
|
147
|
+
end
|
|
134
148
|
|
|
135
|
-
|
|
136
|
-
|
|
149
|
+
# Return the border associated with the interface/view we are
|
|
150
|
+
# drawing.
|
|
151
|
+
#
|
|
152
|
+
# @return (see Vedeu::Borders::Repository#by_name)
|
|
153
|
+
def border
|
|
154
|
+
@border ||= Vedeu.borders.by_name(name)
|
|
155
|
+
end
|
|
137
156
|
|
|
157
|
+
# @return [Fixnum]
|
|
158
|
+
def bx
|
|
159
|
+
@bx ||= border.bx
|
|
138
160
|
end
|
|
139
|
-
end
|
|
140
161
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
@by ||= border.by
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
# @return [Vedeu::Cursors::Cursor]
|
|
159
|
-
# @see Vedeu::Cursors::Repository#by_name
|
|
160
|
-
def cursor
|
|
161
|
-
@cursor ||= Vedeu.cursors.by_name(name)
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
end # Viewport
|
|
162
|
+
# @return [Fixnum]
|
|
163
|
+
def by
|
|
164
|
+
@by ||= border.by
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# @return [Vedeu::Cursors::Cursor]
|
|
168
|
+
# @see Vedeu::Cursors::Repository#by_name
|
|
169
|
+
def cursor
|
|
170
|
+
@cursor ||= Vedeu.cursors.by_name(name)
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
end # Viewport
|
|
174
|
+
|
|
175
|
+
end # Output
|
|
165
176
|
|
|
166
177
|
end # Vedeu
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Vedeu
|
|
2
2
|
|
|
3
|
-
# When included into a class, provides the mechanism to store the
|
|
4
|
-
# repository for later retrieval.
|
|
3
|
+
# When included into a class, provides the mechanism to store the
|
|
4
|
+
# class in a repository for later retrieval.
|
|
5
5
|
#
|
|
6
6
|
module Model
|
|
7
7
|
|
|
@@ -11,8 +11,8 @@ module Vedeu
|
|
|
11
11
|
# @return [Vedeu::Repository]
|
|
12
12
|
attr_accessor :repository
|
|
13
13
|
|
|
14
|
-
# When {Vedeu::Model} is included in a class, the methods within
|
|
15
|
-
# are included as class methods on that class.
|
|
14
|
+
# When {Vedeu::Model} is included in a class, the methods within
|
|
15
|
+
# this module are included as class methods on that class.
|
|
16
16
|
#
|
|
17
17
|
module ClassMethods
|
|
18
18
|
|
|
@@ -20,11 +20,12 @@ module Vedeu
|
|
|
20
20
|
# @return [Vedeu::Repository]
|
|
21
21
|
attr_reader :repository
|
|
22
22
|
|
|
23
|
-
# Build models using a simple DSL when a block is given,
|
|
24
|
-
# a new instance of the class including this
|
|
23
|
+
# Build models using a simple DSL when a block is given,
|
|
24
|
+
# otherwise returns a new instance of the class including this
|
|
25
|
+
# module.
|
|
25
26
|
#
|
|
26
|
-
# @param attributes [Hash] A collection of attributes specific
|
|
27
|
-
# model.
|
|
27
|
+
# @param attributes [Hash] A collection of attributes specific
|
|
28
|
+
# to the model.
|
|
28
29
|
# @param block [Proc] The block passed to the build method.
|
|
29
30
|
# @return [Object] An instance of the model.
|
|
30
31
|
def build(attributes = {}, &block)
|
|
@@ -43,10 +44,11 @@ module Vedeu
|
|
|
43
44
|
repository.by_name(name) if repository
|
|
44
45
|
end
|
|
45
46
|
|
|
46
|
-
# Provide a convenient way to define the child or children of a
|
|
47
|
+
# Provide a convenient way to define the child or children of a
|
|
48
|
+
# model.
|
|
47
49
|
#
|
|
48
|
-
# @param klass [Class] The member (singular) or collection
|
|
49
|
-
# class name for the respective model.
|
|
50
|
+
# @param klass [Class] The member (singular) or collection
|
|
51
|
+
# (multiple) class name for the respective model.
|
|
50
52
|
# @return [void]
|
|
51
53
|
def child(klass)
|
|
52
54
|
send(:define_method, __callee__) { klass }
|
|
@@ -76,8 +78,8 @@ module Vedeu
|
|
|
76
78
|
|
|
77
79
|
end # ClassMethods
|
|
78
80
|
|
|
79
|
-
# When this module is included in a class, provide ClassMethods as
|
|
80
|
-
# methods for the class.
|
|
81
|
+
# When this module is included in a class, provide ClassMethods as
|
|
82
|
+
# class methods for the class.
|
|
81
83
|
#
|
|
82
84
|
# @param klass [Class]
|
|
83
85
|
# @return [void]
|
|
@@ -85,13 +87,13 @@ module Vedeu
|
|
|
85
87
|
klass.send(:extend, ClassMethods)
|
|
86
88
|
end
|
|
87
89
|
|
|
88
|
-
# Returns a DSL instance responsible for defining the DSL methods
|
|
89
|
-
# model.
|
|
90
|
+
# Returns a DSL instance responsible for defining the DSL methods
|
|
91
|
+
# of this model.
|
|
90
92
|
#
|
|
91
93
|
# @param client [Object|NilClass] The client binding represents
|
|
92
|
-
# the client application object that is currently invoking a DSL
|
|
93
|
-
# It is required so that we can send messages to the
|
|
94
|
-
# object should we need to.
|
|
94
|
+
# the client application object that is currently invoking a DSL
|
|
95
|
+
# method. It is required so that we can send messages to the
|
|
96
|
+
# client application object should we need to.
|
|
95
97
|
# @return [void] The DSL instance for this model.
|
|
96
98
|
def deputy(client = nil)
|
|
97
99
|
Object.const_get(dsl_class).new(self, client)
|
|
@@ -109,14 +111,11 @@ module Vedeu
|
|
|
109
111
|
#
|
|
110
112
|
# @return [String]
|
|
111
113
|
def dsl_class
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
'Vedeu::Geometry::DSL'
|
|
118
|
-
elsif demodulize(self.class.name) == 'Menu'
|
|
119
|
-
'Vedeu::Menus::DSL'
|
|
114
|
+
case demodulize(self.class.name)
|
|
115
|
+
when 'Border' then 'Vedeu::Borders::DSL'
|
|
116
|
+
when 'Buffer' then 'Vedeu::Buffers::DSL'
|
|
117
|
+
when 'Geometry' then 'Vedeu::Geometry::DSL'
|
|
118
|
+
when 'Menu' then 'Vedeu::Menus::DSL'
|
|
120
119
|
else
|
|
121
120
|
'Vedeu::DSL::' + demodulize(self.class.name)
|
|
122
121
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Vedeu
|
|
2
2
|
|
|
3
|
-
# Repositories contain registerables, this module provides
|
|
4
|
-
# for them.
|
|
3
|
+
# Repositories contain registerables, this module provides
|
|
4
|
+
# convenience methods for them.
|
|
5
5
|
#
|
|
6
6
|
module Registerable
|
|
7
7
|
|
|
@@ -16,7 +16,8 @@ module Vedeu
|
|
|
16
16
|
define_method(:null_model) { klass }
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
# The real model is the usual model to use for a given
|
|
19
|
+
# The real model is the usual model to use for a given
|
|
20
|
+
# repository.
|
|
20
21
|
#
|
|
21
22
|
# @param klass [Class]
|
|
22
23
|
# @return [Symbol]
|
|
@@ -38,9 +39,9 @@ module Vedeu
|
|
|
38
39
|
# Returns the repositories registered.
|
|
39
40
|
#
|
|
40
41
|
# @note
|
|
41
|
-
# If the repository is 'Geometries', for example, then @models
|
|
42
|
-
# either an empty Geometries repository or the
|
|
43
|
-
# models.
|
|
42
|
+
# If the repository is 'Geometries', for example, then @models
|
|
43
|
+
# will be either an empty Geometries repository or the
|
|
44
|
+
# collection of stored models.
|
|
44
45
|
#
|
|
45
46
|
# @return [void]
|
|
46
47
|
def repository
|
|
@@ -57,8 +58,8 @@ module Vedeu
|
|
|
57
58
|
|
|
58
59
|
end # ClassMethods
|
|
59
60
|
|
|
60
|
-
# When this module is included in a class, provide ClassMethods as
|
|
61
|
-
# methods for the class.
|
|
61
|
+
# When this module is included in a class, provide ClassMethods as
|
|
62
|
+
# class methods for the class.
|
|
62
63
|
#
|
|
63
64
|
# @param klass [Class]
|
|
64
65
|
# @return [void]
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
module Vedeu
|
|
2
2
|
|
|
3
|
-
# Provides common methods for accessing the various repositories
|
|
3
|
+
# Provides common methods for accessing the various repositories
|
|
4
|
+
# Vedeu uses.
|
|
4
5
|
#
|
|
5
6
|
# @example
|
|
6
7
|
# { 'models' => [Model, Model, Model] }
|
|
@@ -50,11 +51,12 @@ module Vedeu
|
|
|
50
51
|
# Return the named model or a null object if not registered.
|
|
51
52
|
#
|
|
52
53
|
# @example
|
|
53
|
-
#
|
|
54
|
-
#
|
|
54
|
+
# # Fetch the cursor belonging to the interface of the same
|
|
55
|
+
# # name.
|
|
56
|
+
# Vedeu.cursors.by_name('some_name')
|
|
55
57
|
#
|
|
56
|
-
#
|
|
57
|
-
#
|
|
58
|
+
# # Fetch the names of the interfaces belonging to this group.
|
|
59
|
+
# Vedeu.groups.by_name(name)
|
|
58
60
|
#
|
|
59
61
|
# @param name [String] The name of the stored model.
|
|
60
62
|
# @return [void]
|
|
@@ -85,19 +87,20 @@ module Vedeu
|
|
|
85
87
|
storage[name]
|
|
86
88
|
end
|
|
87
89
|
|
|
88
|
-
# Find the model attributes by name, raises an exception when the
|
|
89
|
-
# cannot be found.
|
|
90
|
+
# Find the model attributes by name, raises an exception when the
|
|
91
|
+
# model cannot be found.
|
|
90
92
|
#
|
|
91
93
|
# @param name [String]
|
|
92
|
-
# @raise [Vedeu::Error::ModelNotFound] When the model cannot be
|
|
93
|
-
# this name.
|
|
94
|
+
# @raise [Vedeu::Error::ModelNotFound] When the model cannot be
|
|
95
|
+
# found with this name.
|
|
94
96
|
# @return [Hash<String => Object>]
|
|
95
97
|
def find!(name)
|
|
96
98
|
find(name) || fail(Vedeu::Error::ModelNotFound,
|
|
97
99
|
"Cannot find model by name: '#{name}'")
|
|
98
100
|
end
|
|
99
101
|
|
|
100
|
-
# Find a model by name, registers the model by name when not
|
|
102
|
+
# Find a model by name, registers the model by name when not
|
|
103
|
+
# found.
|
|
101
104
|
#
|
|
102
105
|
# @param name [String]
|
|
103
106
|
# @return [void]
|
|
@@ -118,7 +121,8 @@ module Vedeu
|
|
|
118
121
|
"<#{self.class.name}>"
|
|
119
122
|
end
|
|
120
123
|
|
|
121
|
-
# Returns a boolean indicating whether the named model is
|
|
124
|
+
# Returns a boolean indicating whether the named model is
|
|
125
|
+
# registered.
|
|
122
126
|
#
|
|
123
127
|
# @param name [String]
|
|
124
128
|
# @return [Boolean]
|
|
@@ -129,8 +133,8 @@ module Vedeu
|
|
|
129
133
|
storage.include?(name)
|
|
130
134
|
end
|
|
131
135
|
|
|
132
|
-
# Returns the storage with the named model removed, or false when
|
|
133
|
-
# does not exist.
|
|
136
|
+
# Returns the storage with the named model removed, or false when
|
|
137
|
+
# the model does not exist.
|
|
134
138
|
#
|
|
135
139
|
# @param name [String]
|
|
136
140
|
# @return [Hash|FalseClass]
|
|
@@ -150,11 +154,12 @@ module Vedeu
|
|
|
150
154
|
alias_method :delete, :remove
|
|
151
155
|
alias_method :deregister, :remove
|
|
152
156
|
|
|
153
|
-
# Stores the model instance by name in the repository of the
|
|
157
|
+
# Stores the model instance by name in the repository of the
|
|
158
|
+
# model.
|
|
154
159
|
#
|
|
155
160
|
# @param model [void] A model instance.
|
|
156
|
-
# @raise [Vedeu::Error::MissingRequired] When the name attribute
|
|
157
|
-
# defined.
|
|
161
|
+
# @raise [Vedeu::Error::MissingRequired] When the name attribute
|
|
162
|
+
# is not defined.
|
|
158
163
|
# @return [void] The model instance which was stored.
|
|
159
164
|
def store(model)
|
|
160
165
|
unless present?(model.name)
|
|
@@ -19,7 +19,8 @@ module Vedeu
|
|
|
19
19
|
storage.empty?
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
# Returns a boolean indicating whether the named model is
|
|
22
|
+
# Returns a boolean indicating whether the named model is
|
|
23
|
+
# registered.
|
|
23
24
|
#
|
|
24
25
|
# @param name [String]
|
|
25
26
|
# @return [Boolean]
|
|
@@ -30,7 +31,8 @@ module Vedeu
|
|
|
30
31
|
end
|
|
31
32
|
alias_method :registered?, :exists?
|
|
32
33
|
|
|
33
|
-
# Returns a collection of the names of all the registered
|
|
34
|
+
# Returns a collection of the names of all the registered
|
|
35
|
+
# entities.
|
|
34
36
|
#
|
|
35
37
|
# @return [Array]
|
|
36
38
|
def registered
|
|
@@ -60,8 +62,8 @@ module Vedeu
|
|
|
60
62
|
storage.size
|
|
61
63
|
end
|
|
62
64
|
|
|
63
|
-
# Return whole repository; provides raw access to the storage for
|
|
64
|
-
# repository.
|
|
65
|
+
# Return whole repository; provides raw access to the storage for
|
|
66
|
+
# this repository.
|
|
65
67
|
#
|
|
66
68
|
# @return [Array|Hash|Set]
|
|
67
69
|
def storage
|
|
@@ -4,8 +4,9 @@ module Vedeu
|
|
|
4
4
|
|
|
5
5
|
# Provides the mechanism to start up a generated application.
|
|
6
6
|
#
|
|
7
|
-
# This class loads all necessary client application files and
|
|
8
|
-
# Vedeu with this data, then starts the client
|
|
7
|
+
# This class loads all necessary client application files and
|
|
8
|
+
# initializes Vedeu with this data, then starts the client
|
|
9
|
+
# application.
|
|
9
10
|
#
|
|
10
11
|
class Bootstrap
|
|
11
12
|
|
|
@@ -23,8 +24,8 @@ module Vedeu
|
|
|
23
24
|
@argv = argv
|
|
24
25
|
end
|
|
25
26
|
|
|
26
|
-
# Loads all of the client application files so that Vedeu has
|
|
27
|
-
# them, then launches the client application.
|
|
27
|
+
# Loads all of the client application files so that Vedeu has
|
|
28
|
+
# access to them, then launches the client application.
|
|
28
29
|
#
|
|
29
30
|
# @return [void]
|
|
30
31
|
def start
|
|
@@ -50,7 +51,8 @@ module Vedeu
|
|
|
50
51
|
end
|
|
51
52
|
|
|
52
53
|
# @note
|
|
53
|
-
# config/configuration.rb is already loaded so don't load it
|
|
54
|
+
# config/configuration.rb is already loaded so don't load it
|
|
55
|
+
# twice.
|
|
54
56
|
# @return [void]
|
|
55
57
|
def client_configuration!
|
|
56
58
|
Dir[File.join(base_path, 'config/**/*')].each do |path|
|