vedeu 0.6.10 → 0.6.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vedeu/all.rb +17 -103
- data/lib/vedeu/api/all.rb +15 -0
- data/lib/vedeu/api/internal.rb +4 -0
- data/lib/vedeu/application/all.rb +6 -0
- data/lib/vedeu/bindings/all.rb +32 -0
- data/lib/vedeu/bindings/bindings.rb +0 -14
- data/lib/vedeu/bindings/refresh.rb +8 -2
- data/lib/vedeu/bindings/system.rb +1 -0
- data/lib/vedeu/borders/border.rb +1 -1
- data/lib/vedeu/borders/repository.rb +1 -1
- data/lib/vedeu/buffers/buffer.rb +2 -4
- data/lib/vedeu/buffers/repository.rb +1 -1
- data/lib/vedeu/colours/background.rb +1 -1
- data/lib/vedeu/colours/backgrounds.rb +1 -1
- data/lib/vedeu/colours/foreground.rb +1 -1
- data/lib/vedeu/colours/foregrounds.rb +1 -1
- data/lib/vedeu/colours/translator.rb +4 -3
- data/lib/vedeu/configuration/api.rb +2 -1
- data/lib/vedeu/configuration/cli.rb +1 -1
- data/lib/vedeu/cursors/cursor.rb +26 -26
- data/lib/vedeu/cursors/repository.rb +1 -1
- data/lib/vedeu/distributed/all.rb +16 -0
- data/lib/vedeu/distributed/test_application.rb +3 -3
- data/lib/vedeu/dsl/all.rb +22 -0
- data/lib/vedeu/dsl/composition.rb +43 -40
- data/lib/vedeu/dsl/dsl.rb +6 -3
- data/lib/vedeu/dsl/group.rb +23 -16
- data/lib/vedeu/dsl/interface.rb +48 -38
- data/lib/vedeu/dsl/keymap.rb +6 -7
- data/lib/vedeu/dsl/line.rb +6 -3
- data/lib/vedeu/dsl/stream.rb +2 -1
- data/lib/vedeu/editor/cursor.rb +1 -3
- data/lib/vedeu/editor/document.rb +4 -5
- data/lib/vedeu/editor/documents.rb +1 -1
- data/lib/vedeu/editor/line.rb +2 -3
- data/lib/vedeu/editor/lines.rb +2 -3
- data/lib/vedeu/esc/all.rb +14 -0
- data/lib/vedeu/esc/colours.rb +8 -4
- data/lib/vedeu/esc/esc.rb +89 -84
- data/lib/vedeu/events/aliases.rb +1 -2
- data/lib/vedeu/events/collection.rb +1 -1
- data/lib/vedeu/events/event.rb +1 -1
- data/lib/vedeu/events/repository.rb +1 -1
- data/lib/vedeu/events/trigger.rb +11 -9
- data/lib/vedeu/geometry/dimension.rb +1 -3
- data/lib/vedeu/geometry/generic_coordinate.rb +1 -3
- data/lib/vedeu/geometry/geometry.rb +1 -1
- data/lib/vedeu/geometry/repository.rb +3 -3
- data/lib/vedeu/input/all.rb +3 -0
- data/lib/vedeu/input/keymap.rb +10 -11
- data/lib/vedeu/input/keymaps.rb +1 -1
- data/lib/vedeu/input/keys.rb +1 -1
- data/lib/vedeu/input/mapper.rb +14 -12
- data/lib/vedeu/logging/all.rb +3 -0
- data/lib/vedeu/logging/log.rb +4 -2
- data/lib/vedeu/menus/menu.rb +2 -4
- data/lib/vedeu/menus/repository.rb +1 -1
- data/lib/vedeu/models/all.rb +15 -0
- data/lib/vedeu/models/cell.rb +1 -1
- data/lib/vedeu/models/escape.rb +1 -1
- data/lib/vedeu/models/group.rb +4 -3
- data/lib/vedeu/models/groups.rb +1 -1
- data/lib/vedeu/models/interface.rb +1 -1
- data/lib/vedeu/models/interfaces.rb +1 -1
- data/lib/vedeu/models/views/char.rb +1 -1
- data/lib/vedeu/models/views/collections/chars.rb +1 -1
- data/lib/vedeu/models/views/collections/lines.rb +1 -1
- data/lib/vedeu/models/views/collections/streams.rb +1 -1
- data/lib/vedeu/models/views/collections/view_collection.rb +1 -1
- data/lib/vedeu/models/views/composition.rb +1 -1
- data/lib/vedeu/models/views/line.rb +8 -6
- data/lib/vedeu/models/views/stream.rb +1 -1
- data/lib/vedeu/models/views/view.rb +1 -1
- data/lib/vedeu/null/all.rb +12 -0
- data/lib/vedeu/output/clear/named_group.rb +2 -1
- data/lib/vedeu/output/clear/named_interface.rb +5 -4
- data/lib/vedeu/output/compressor.rb +1 -0
- data/lib/vedeu/output/output.rb +3 -0
- data/lib/vedeu/output/presentation/colour.rb +10 -10
- data/lib/vedeu/output/presentation/presentation.rb +9 -9
- data/lib/vedeu/output/presentation/style.rb +2 -2
- data/lib/vedeu/output/refresh/refresh.rb +35 -0
- data/lib/vedeu/output/refresh/refresh_group.rb +66 -0
- data/lib/vedeu/output/renderers/all.rb +17 -0
- data/lib/vedeu/output/renderers/escape_sequence.rb +4 -2
- data/lib/vedeu/output/renderers/file.rb +7 -6
- data/lib/vedeu/output/renderers/html.rb +9 -7
- data/lib/vedeu/output/renderers/null.rb +1 -1
- data/lib/vedeu/output/renderers/renderer_options.rb +24 -20
- data/lib/vedeu/output/renderers/terminal.rb +1 -1
- data/lib/vedeu/output/renderers/text.rb +1 -1
- data/lib/vedeu/output/wordwrap.rb +7 -4
- data/lib/vedeu/plugins/all.rb +2 -0
- data/lib/vedeu/repositories/all.rb +16 -0
- data/lib/vedeu/repositories/collection.rb +93 -89
- data/lib/vedeu/repositories/model.rb +113 -102
- data/lib/vedeu/repositories/registerable.rb +60 -56
- data/lib/vedeu/repositories/repository.rb +161 -156
- data/lib/vedeu/repositories/store.rb +70 -66
- data/lib/vedeu/runtime/all.rb +15 -0
- data/lib/vedeu/runtime/launcher.rb +19 -16
- data/lib/vedeu/templating/all.rb +6 -0
- data/lib/vedeu/terminal/all.rb +14 -0
- data/lib/vedeu/terminal/buffer.rb +8 -7
- data/lib/vedeu/terminal/mode.rb +11 -10
- data/lib/vedeu/terminal/terminal.rb +50 -45
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/cursors/cursor_test.rb +4 -2
- data/test/lib/vedeu/editor/cursor_test.rb +0 -3
- data/test/lib/vedeu/esc/esc_test.rb +58 -54
- data/test/lib/vedeu/events/collection_test.rb +1 -1
- data/test/lib/vedeu/input/keys_test.rb +1 -1
- data/test/lib/vedeu/input/mapper_test.rb +1 -1
- data/test/lib/vedeu/models/views/collections/chars_test.rb +1 -1
- data/test/lib/vedeu/models/views/collections/lines_test.rb +1 -1
- data/test/lib/vedeu/models/views/collections/streams_test.rb +1 -1
- data/test/lib/vedeu/models/views/collections/view_collection_test.rb +1 -1
- data/test/lib/vedeu/output/refresh/refresh_group_test.rb +43 -0
- data/test/lib/vedeu/output/refresh/refresh_test.rb +50 -0
- data/test/lib/vedeu/output/renderers/renderer_options_test.rb +8 -4
- data/test/lib/vedeu/output/renderers_test.rb +2 -1
- data/test/lib/vedeu/repositories/collection_test.rb +105 -101
- data/test/lib/vedeu/repositories/model_test.rb +56 -52
- data/test/lib/vedeu/repositories/registerable_test.rb +36 -32
- data/test/lib/vedeu/repositories/repository_test.rb +178 -174
- data/test/lib/vedeu/repositories/store_test.rb +109 -105
- data/test/support/examples/material_colours_app.rb +0 -1
- data/test/support/helpers/model_test_class.rb +50 -46
- data/test/test_helper.rb +2 -2
- metadata +21 -9
- data/lib/vedeu/refresh/refresh.rb +0 -31
- data/lib/vedeu/refresh/refresh_group.rb +0 -59
- data/out_ +0 -50
- data/test/lib/vedeu/refresh/refresh_group_test.rb +0 -39
- data/test/lib/vedeu/refresh/refresh_test.rb +0 -46
@@ -1,188 +1,193 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
|
4
|
-
# Vedeu uses.
|
5
|
-
#
|
6
|
-
# @example
|
7
|
-
# { 'models' => [Model, Model, Model] }
|
8
|
-
#
|
9
|
-
# { 'models' => [Model] }
|
10
|
-
#
|
11
|
-
class Repository
|
12
|
-
|
13
|
-
include Vedeu::Common
|
14
|
-
include Vedeu::Registerable
|
15
|
-
include Vedeu::Store
|
16
|
-
|
17
|
-
# @!attribute [r] model
|
18
|
-
# @return [void]
|
19
|
-
attr_reader :model
|
20
|
-
|
21
|
-
# @!attribute [r] storage
|
22
|
-
# @return [void]
|
23
|
-
attr_reader :storage
|
24
|
-
|
25
|
-
# Returns a new instance of Vedeu::Repository.
|
26
|
-
#
|
27
|
-
# @param model [Class]
|
28
|
-
# @param storage [Class|Hash]
|
29
|
-
# @return [Vedeu::Repository]
|
30
|
-
def initialize(model = nil, storage = {})
|
31
|
-
@model = model
|
32
|
-
@storage = storage
|
33
|
-
end
|
34
|
-
|
35
|
-
# Returns the repository class.
|
36
|
-
#
|
37
|
-
# @return [Class]
|
38
|
-
def repository
|
39
|
-
self.class
|
40
|
-
end
|
41
|
-
|
42
|
-
# Return all the registered models.
|
43
|
-
#
|
44
|
-
# @return [Array<void>] An array containing each stored model.
|
45
|
-
def all
|
46
|
-
return storage.values if storage.is_a?(Hash)
|
47
|
-
|
48
|
-
registered
|
49
|
-
end
|
3
|
+
module Repositories
|
50
4
|
|
51
|
-
#
|
5
|
+
# Provides common methods for accessing the various repositories
|
6
|
+
# Vedeu uses.
|
52
7
|
#
|
53
8
|
# @example
|
54
|
-
#
|
55
|
-
# # name.
|
56
|
-
# Vedeu.cursors.by_name('some_name')
|
9
|
+
# { 'models' => [Model, Model, Model] }
|
57
10
|
#
|
58
|
-
#
|
59
|
-
# Vedeu.groups.by_name(name)
|
11
|
+
# { 'models' => [Model] }
|
60
12
|
#
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
13
|
+
class Repository
|
14
|
+
|
15
|
+
include Vedeu::Common
|
16
|
+
include Vedeu::Repositories::Registerable
|
17
|
+
include Vedeu::Repositories::Store
|
18
|
+
|
19
|
+
# @!attribute [r] model
|
20
|
+
# @return [void]
|
21
|
+
attr_reader :model
|
22
|
+
|
23
|
+
# @!attribute [r] storage
|
24
|
+
# @return [void]
|
25
|
+
attr_reader :storage
|
26
|
+
|
27
|
+
# Returns a new instance of Vedeu::Repositories::Repository.
|
28
|
+
#
|
29
|
+
# @param model [Class]
|
30
|
+
# @param storage [Class|Hash]
|
31
|
+
# @return [Vedeu::Repositories::Repository]
|
32
|
+
def initialize(model = nil, storage = {})
|
33
|
+
@model = model
|
34
|
+
@storage = storage
|
35
|
+
end
|
65
36
|
|
66
|
-
|
67
|
-
|
37
|
+
# Returns the repository class.
|
38
|
+
#
|
39
|
+
# @return [Class]
|
40
|
+
def repository
|
41
|
+
self.class
|
42
|
+
end
|
68
43
|
|
69
|
-
|
70
|
-
|
44
|
+
# Return all the registered models.
|
45
|
+
#
|
46
|
+
# @return [Array<void>] An array containing each stored model.
|
47
|
+
def all
|
48
|
+
return storage.values if storage.is_a?(Hash)
|
71
49
|
|
50
|
+
registered
|
72
51
|
end
|
73
|
-
end
|
74
52
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
53
|
+
# Return the named model or a null object if not registered.
|
54
|
+
#
|
55
|
+
# @example
|
56
|
+
# # Fetch the cursor belonging to the interface of the same
|
57
|
+
# # name.
|
58
|
+
# Vedeu.cursors.by_name('some_name')
|
59
|
+
#
|
60
|
+
# # Fetch the names of the interfaces belonging to this group.
|
61
|
+
# Vedeu.groups.by_name(name)
|
62
|
+
#
|
63
|
+
# @param name [String] The name of the stored model.
|
64
|
+
# @return [void]
|
65
|
+
def by_name(name)
|
66
|
+
name ||= Vedeu.focus
|
67
|
+
|
68
|
+
if registered?(name)
|
69
|
+
find(name)
|
70
|
+
|
71
|
+
else
|
72
|
+
null_model.new(name: name)
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
81
76
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
end
|
89
|
-
|
90
|
-
# Find the model attributes by name, raises an exception when the
|
91
|
-
# model cannot be found.
|
92
|
-
#
|
93
|
-
# @param name [String]
|
94
|
-
# @raise [Vedeu::Error::ModelNotFound] When the model cannot be
|
95
|
-
# found with this name.
|
96
|
-
# @return [Hash<String => Object>]
|
97
|
-
def find!(name)
|
98
|
-
find(name) || fail(Vedeu::Error::ModelNotFound,
|
99
|
-
"Cannot find model by name: '#{name}'")
|
100
|
-
end
|
101
|
-
|
102
|
-
# Find a model by name, registers the model by name when not
|
103
|
-
# found.
|
104
|
-
#
|
105
|
-
# @param name [String]
|
106
|
-
# @return [void]
|
107
|
-
def find_or_create(name)
|
108
|
-
if registered?(name)
|
109
|
-
find(name)
|
77
|
+
# Return the model for the interface currently in focus.
|
78
|
+
#
|
79
|
+
# @return [String|NilClass]
|
80
|
+
def current
|
81
|
+
find_or_create(Vedeu.focus) if Vedeu.focus
|
82
|
+
end
|
110
83
|
|
111
|
-
|
112
|
-
|
113
|
-
|
84
|
+
# Find the model by name.
|
85
|
+
#
|
86
|
+
# @param name [String]
|
87
|
+
# @return [Hash<String => Object>|NilClass]
|
88
|
+
def find(name)
|
89
|
+
storage[name]
|
90
|
+
end
|
114
91
|
|
115
|
-
|
92
|
+
# Find the model attributes by name, raises an exception when
|
93
|
+
# the model cannot be found.
|
94
|
+
#
|
95
|
+
# @param name [String]
|
96
|
+
# @raise [Vedeu::Error::ModelNotFound] When the model cannot be
|
97
|
+
# found with this name.
|
98
|
+
# @return [Hash<String => Object>]
|
99
|
+
def find!(name)
|
100
|
+
find(name) || fail(Vedeu::Error::ModelNotFound,
|
101
|
+
"Cannot find model by name: '#{name}'")
|
116
102
|
end
|
117
|
-
end
|
118
103
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
104
|
+
# Find a model by name, registers the model by name when not
|
105
|
+
# found.
|
106
|
+
#
|
107
|
+
# @param name [String]
|
108
|
+
# @return [void]
|
109
|
+
def find_or_create(name)
|
110
|
+
if registered?(name)
|
111
|
+
find(name)
|
112
|
+
|
113
|
+
else
|
114
|
+
Vedeu.log(type: :store,
|
115
|
+
message: "Model (#{model}) not found, " \
|
116
|
+
"registering: '#{name}'")
|
117
|
+
|
118
|
+
model.new(name).store
|
119
|
+
end
|
120
|
+
end
|
123
121
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
# @return [Boolean]
|
129
|
-
def registered?(name)
|
130
|
-
return false if name.nil? || name.empty?
|
131
|
-
return false if empty?
|
122
|
+
# @return [String]
|
123
|
+
def inspect
|
124
|
+
"<#{self.class.name}>"
|
125
|
+
end
|
132
126
|
|
133
|
-
|
134
|
-
|
127
|
+
# Returns a boolean indicating whether the named model is
|
128
|
+
# registered.
|
129
|
+
#
|
130
|
+
# @param name [String]
|
131
|
+
# @return [Boolean]
|
132
|
+
def registered?(name)
|
133
|
+
return false if name.nil? || name.empty?
|
134
|
+
return false if empty?
|
135
135
|
|
136
|
-
|
137
|
-
|
138
|
-
#
|
139
|
-
# @param name [String]
|
140
|
-
# @return [Hash|FalseClass]
|
141
|
-
def remove(name)
|
142
|
-
return false if empty?
|
136
|
+
storage.include?(name)
|
137
|
+
end
|
143
138
|
|
144
|
-
|
145
|
-
|
146
|
-
|
139
|
+
# Returns the storage with the named model removed, or false
|
140
|
+
# when the model does not exist.
|
141
|
+
#
|
142
|
+
# @param name [String]
|
143
|
+
# @return [Hash|FalseClass]
|
144
|
+
def remove(name)
|
145
|
+
return false if empty?
|
147
146
|
|
148
|
-
|
149
|
-
|
147
|
+
if registered?(name)
|
148
|
+
storage.delete(name)
|
149
|
+
storage unless storage.is_a?(Set)
|
150
150
|
|
151
|
-
|
152
|
-
|
153
|
-
alias_method :destroy, :remove
|
154
|
-
alias_method :delete, :remove
|
155
|
-
alias_method :deregister, :remove
|
151
|
+
else
|
152
|
+
false
|
156
153
|
|
157
|
-
|
158
|
-
# model.
|
159
|
-
#
|
160
|
-
# @param model [void] A model instance.
|
161
|
-
# @raise [Vedeu::Error::MissingRequired] When the name attribute
|
162
|
-
# is not defined.
|
163
|
-
# @return [void] The model instance which was stored.
|
164
|
-
def store(model)
|
165
|
-
unless present?(model.name)
|
166
|
-
fail Vedeu::Error::MissingRequired,
|
167
|
-
"Cannot store model '#{model.class}' without a name attribute."
|
154
|
+
end
|
168
155
|
end
|
156
|
+
alias_method :destroy, :remove
|
157
|
+
alias_method :delete, :remove
|
158
|
+
alias_method :deregister, :remove
|
159
|
+
|
160
|
+
# Stores the model instance by name in the repository of the
|
161
|
+
# model.
|
162
|
+
#
|
163
|
+
# @param model [void] A model instance.
|
164
|
+
# @raise [Vedeu::Error::MissingRequired] When the name attribute
|
165
|
+
# is not defined.
|
166
|
+
# @return [void] The model instance which was stored.
|
167
|
+
def store(model)
|
168
|
+
unless present?(model.name)
|
169
|
+
fail Vedeu::Error::MissingRequired,
|
170
|
+
"Cannot store model '#{model.class}' without a name attribute."
|
171
|
+
end
|
172
|
+
|
173
|
+
log_store(model)
|
174
|
+
|
175
|
+
storage[model.name] = model
|
176
|
+
end
|
177
|
+
alias_method :register, :store
|
178
|
+
alias_method :add, :store
|
169
179
|
|
170
|
-
|
171
|
-
|
172
|
-
storage[model.name] = model
|
173
|
-
end
|
174
|
-
alias_method :register, :store
|
175
|
-
alias_method :add, :store
|
180
|
+
private
|
176
181
|
|
177
|
-
|
182
|
+
# @return [String]
|
183
|
+
def log_store(model)
|
184
|
+
type = registered?(model.name) ? :update : :create
|
178
185
|
|
179
|
-
|
180
|
-
|
181
|
-
type = registered?(model.name) ? :update : :create
|
186
|
+
Vedeu.log(type: type, message: "#{model.class.name}: '#{model.name}'")
|
187
|
+
end
|
182
188
|
|
183
|
-
|
184
|
-
end
|
189
|
+
end # Repository
|
185
190
|
|
186
|
-
end #
|
191
|
+
end # Repositories
|
187
192
|
|
188
193
|
end # Vedeu
|
@@ -1,81 +1,85 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
|
4
|
-
#
|
5
|
-
module Store
|
3
|
+
module Repositories
|
6
4
|
|
7
|
-
|
5
|
+
# Provides generic repository related behaviour.
|
6
|
+
#
|
7
|
+
module Store
|
8
8
|
|
9
|
-
|
10
|
-
# @return [Enumerator]
|
11
|
-
def each(&block)
|
12
|
-
storage.each(&block)
|
13
|
-
end
|
9
|
+
include Enumerable
|
14
10
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
11
|
+
# @param block [Proc]
|
12
|
+
# @return [Enumerator]
|
13
|
+
def each(&block)
|
14
|
+
storage.each(&block)
|
15
|
+
end
|
21
16
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
return false if empty? || name.nil? || name.empty?
|
17
|
+
# Return a boolean indicating whether the storage is empty.
|
18
|
+
#
|
19
|
+
# @return [Boolean]
|
20
|
+
def empty?
|
21
|
+
storage.empty?
|
22
|
+
end
|
29
23
|
|
30
|
-
|
31
|
-
|
32
|
-
|
24
|
+
# Returns a boolean indicating whether the named model is
|
25
|
+
# registered.
|
26
|
+
#
|
27
|
+
# @param name [String]
|
28
|
+
# @return [Boolean]
|
29
|
+
def exists?(name)
|
30
|
+
return false if empty? || name.nil? || name.empty?
|
33
31
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
# @return [Array]
|
38
|
-
def registered
|
39
|
-
return [] if empty?
|
40
|
-
return storage.keys if storage.is_a?(Hash)
|
41
|
-
return storage.to_a if storage.is_a?(Set)
|
32
|
+
storage.include?(name)
|
33
|
+
end
|
34
|
+
alias_method :registered?, :exists?
|
42
35
|
|
43
|
-
|
44
|
-
|
36
|
+
# Returns a collection of the names of all the registered
|
37
|
+
# entities.
|
38
|
+
#
|
39
|
+
# @return [Array]
|
40
|
+
def registered
|
41
|
+
return [] if empty?
|
42
|
+
return storage.keys if storage.is_a?(Hash)
|
43
|
+
return storage.to_a if storage.is_a?(Set)
|
45
44
|
|
46
|
-
|
47
|
-
|
48
|
-
# @return [Array|Hash|Set]
|
49
|
-
def reset
|
50
|
-
Vedeu.log(type: :reset,
|
51
|
-
message: "(#{self.class.name}) #{registered.inspect}")
|
45
|
+
storage
|
46
|
+
end
|
52
47
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
48
|
+
# Remove all currently stored data.
|
49
|
+
#
|
50
|
+
# @return [Array|Hash|Set]
|
51
|
+
def reset
|
52
|
+
Vedeu.log(type: :reset,
|
53
|
+
message: "(#{self.class.name}) #{registered.inspect}")
|
57
54
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
storage.size
|
63
|
-
end
|
55
|
+
@storage = in_memory
|
56
|
+
end
|
57
|
+
alias_method :reset!, :reset
|
58
|
+
alias_method :clear, :reset
|
64
59
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
60
|
+
# Return the number of entries stored.
|
61
|
+
#
|
62
|
+
# @return [Fixnum]
|
63
|
+
def size
|
64
|
+
storage.size
|
65
|
+
end
|
66
|
+
|
67
|
+
# Return whole repository; provides raw access to the storage
|
68
|
+
# for this repository.
|
69
|
+
#
|
70
|
+
# @return [Array|Hash|Set]
|
71
|
+
def storage
|
72
|
+
@storage ||= in_memory
|
73
|
+
end
|
74
|
+
alias_method :all, :storage
|
75
|
+
|
76
|
+
# @return [Hash]
|
77
|
+
def in_memory
|
78
|
+
{}
|
79
|
+
end
|
80
|
+
|
81
|
+
end # Store
|
82
|
+
|
83
|
+
end # Repositories
|
80
84
|
|
81
85
|
end # Vedeu
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
module Runtime
|
4
|
+
|
5
|
+
end # Runtime
|
6
|
+
|
7
|
+
end # Vedeu
|
8
|
+
|
9
|
+
require 'vedeu/runtime/traps'
|
10
|
+
require 'vedeu/runtime/launcher'
|
11
|
+
require 'vedeu/runtime/bootstrap'
|
12
|
+
require 'vedeu/runtime/router'
|
13
|
+
require 'vedeu/runtime/main_loop'
|
14
|
+
require 'vedeu/runtime/flags'
|
15
|
+
require 'vedeu/runtime/application'
|
@@ -1,15 +1,16 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
# This class ensures that STDIN, STDOUT and STDERR point to the
|
4
|
-
# places. It also handles the initial configuration of the
|
5
|
-
# the starting of the application, the handling of
|
6
|
-
# finally the exiting of the application
|
3
|
+
# This class ensures that STDIN, STDOUT and STDERR point to the
|
4
|
+
# correct places. It also handles the initial configuration of the
|
5
|
+
# application, the starting of the application, the handling of
|
6
|
+
# uncaught exceptions and finally the exiting of the application
|
7
|
+
# with the correct exit code.
|
7
8
|
#
|
8
9
|
class Launcher
|
9
10
|
|
10
11
|
# @!attribute [r] exit_code
|
11
|
-
# @return [Fixnum] Return value indicating successful execution
|
12
|
-
# error occurred (1).
|
12
|
+
# @return [Fixnum] Return value indicating successful execution
|
13
|
+
# (0) or an error occurred (1).
|
13
14
|
attr_reader :exit_code
|
14
15
|
|
15
16
|
# :nocov:
|
@@ -45,9 +46,9 @@ module Vedeu
|
|
45
46
|
end
|
46
47
|
|
47
48
|
# :nocov:
|
48
|
-
# If debugging is enabled, execute the application within the
|
49
|
-
# context. At the moment, this simple uses 'ruby-prof'
|
50
|
-
# running application.
|
49
|
+
# If debugging is enabled, execute the application within the
|
50
|
+
# debugging context. At the moment, this simple uses 'ruby-prof'
|
51
|
+
# to profile the running application.
|
51
52
|
#
|
52
53
|
# @return [void]
|
53
54
|
def debug_execute!
|
@@ -63,9 +64,10 @@ module Vedeu
|
|
63
64
|
end
|
64
65
|
# :nocov:
|
65
66
|
|
66
|
-
# Alters the STD[IN|OUT|ERR] to those requested by the client
|
67
|
-
# then starts the application. If an uncaught
|
68
|
-
# application runtime, we exit
|
67
|
+
# Alters the STD[IN|OUT|ERR] to those requested by the client
|
68
|
+
# application, then starts the application. If an uncaught
|
69
|
+
# exception occurs during the application runtime, we exit
|
70
|
+
# ungracefully with any error message(s).
|
69
71
|
#
|
70
72
|
# @return [void]
|
71
73
|
def execute!
|
@@ -95,7 +97,8 @@ module Vedeu
|
|
95
97
|
private
|
96
98
|
|
97
99
|
# :nocov:
|
98
|
-
# Terminates the application after resetting $stdin, $stdout and
|
100
|
+
# Terminates the application after resetting $stdin, $stdout and
|
101
|
+
# $stderr.
|
99
102
|
#
|
100
103
|
# @return [void]
|
101
104
|
def terminate!
|
@@ -109,9 +112,9 @@ module Vedeu
|
|
109
112
|
end
|
110
113
|
# :nocov:
|
111
114
|
|
112
|
-
# Use the arguments passed on the command-line along with those
|
113
|
-
# the client application and Vedeu's defaults to
|
114
|
-
# application.
|
115
|
+
# Use the arguments passed on the command-line along with those
|
116
|
+
# defined by the client application and Vedeu's defaults to
|
117
|
+
# configure the client application.
|
115
118
|
#
|
116
119
|
# @return [Vedeu::Configuration]
|
117
120
|
def configuration
|
data/lib/vedeu/templating/all.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# This module is the direct interface between Vedeu and your
|
4
|
+
# terminal/ console, via Ruby's IO core library.
|
5
|
+
#
|
6
|
+
module Terminal
|
7
|
+
|
8
|
+
end # Terminal
|
9
|
+
|
10
|
+
end # Vedeu
|
11
|
+
|
12
|
+
require 'vedeu/terminal/mode'
|
13
|
+
require 'vedeu/terminal/terminal'
|
14
|
+
require 'vedeu/terminal/buffer'
|
@@ -2,13 +2,14 @@ module Vedeu
|
|
2
2
|
|
3
3
|
module Terminal
|
4
4
|
|
5
|
-
# All output will be written to this singleton, and #render will
|
6
|
-
# at the end of each run of {Vedeu::MainLoop};
|
7
|
-
# buffer to each registered renderer.
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
5
|
+
# All output will be written to this singleton, and #render will
|
6
|
+
# be called at the end of each run of {Vedeu::MainLoop};
|
7
|
+
# effectively rendering this buffer to each registered renderer.
|
8
|
+
# This buffer is not cleared after this action though, as
|
9
|
+
# subsequent actions will modify the contents. This means that
|
10
|
+
# individual parts of Vedeu can write content here at various
|
11
|
+
# points and only at the end of each run of {Vedeu::MainLoop} will
|
12
|
+
# it be actually output 'somewhere'.
|
12
13
|
#
|
13
14
|
module Buffer
|
14
15
|
|