vedeu 0.4.44 → 0.4.45
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/.ruby-version +1 -1
- data/README.md +3 -2
- data/Rakefile +0 -6
- data/docs/api.md +56 -53
- data/docs/applications.md +1 -1
- data/docs/dsl.md +2 -0
- data/docs/getting_started.md +1 -1
- data/docs/object_graph.md +1 -1
- data/docs/views.md +1 -1
- data/lib/vedeu.rb +4 -0
- data/lib/vedeu/api.rb +75 -13
- data/lib/vedeu/application/application_view.rb +3 -0
- data/lib/vedeu/application/controller.rb +13 -0
- data/lib/vedeu/bootstrap.rb +11 -0
- data/lib/vedeu/buffers/buffer.rb +2 -0
- data/lib/vedeu/configuration/api.rb +1 -15
- data/lib/vedeu/configuration/configuration.rb +1 -0
- data/lib/vedeu/cursor/cursor.rb +2 -0
- data/lib/vedeu/geometry/dimension.rb +2 -0
- data/lib/vedeu/geometry/geometry.rb +4 -0
- data/lib/vedeu/input/keymap.rb +2 -0
- data/lib/vedeu/launcher.rb +14 -0
- data/lib/vedeu/main_loop.rb +2 -0
- data/lib/vedeu/models/cell.rb +2 -0
- data/lib/vedeu/models/char.rb +2 -0
- data/lib/vedeu/models/escape_char.rb +2 -0
- data/lib/vedeu/models/group.rb +2 -0
- data/lib/vedeu/output/clear.rb +2 -0
- data/lib/vedeu/output/esc.rb +8 -16
- data/lib/vedeu/output/render_border.rb +43 -19
- data/lib/vedeu/output/renderers/file.rb +2 -0
- data/lib/vedeu/output/wordwrap.rb +2 -0
- data/lib/vedeu/repositories/repositories/backgrounds.rb +1 -3
- data/lib/vedeu/repositories/repositories/borders.rb +0 -4
- data/lib/vedeu/repositories/repositories/buffers.rb +0 -4
- data/lib/vedeu/repositories/repositories/cursors.rb +1 -7
- data/lib/vedeu/repositories/repositories/events.rb +0 -4
- data/lib/vedeu/repositories/repositories/foregrounds.rb +1 -3
- data/lib/vedeu/repositories/repositories/geometries.rb +0 -4
- data/lib/vedeu/repositories/repositories/groups.rb +0 -4
- data/lib/vedeu/repositories/repositories/interfaces.rb +0 -4
- data/lib/vedeu/repositories/repositories/keymaps.rb +0 -4
- data/lib/vedeu/repositories/repositories/menus.rb +0 -4
- data/lib/vedeu/repositories/repository.rb +6 -0
- data/lib/vedeu/templating/directive.rb +3 -0
- data/lib/vedeu/traps.rb +2 -0
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/cli/generator/helpers_test.rb +33 -1
- data/test/lib/vedeu/distributed/client_test.rb +10 -0
- data/test/lib/vedeu/output/text_test.rb +18 -12
- data/test/lib/vedeu/repositories/repository_test.rb +11 -2
- data/test/support/helpers/model_test_class.rb +2 -0
- data/test/test_helper.rb +7 -2
- data/vedeu.gemspec +2 -3
- metadata +5 -21
- data/inch.yml +0 -5
- data/logs/.gitkeep +0 -0
data/lib/vedeu/bootstrap.rb
CHANGED
@@ -6,12 +6,14 @@ module Vedeu
|
|
6
6
|
# Vedeu with this data, then starts the client application.
|
7
7
|
class Bootstrap
|
8
8
|
|
9
|
+
# :nocov:
|
9
10
|
# @param argv [Array<String>]
|
10
11
|
# @param entry_point [void]
|
11
12
|
# @return [void]
|
12
13
|
def self.start(argv = ARGV, entry_point = nil)
|
13
14
|
new(argv, entry_point).start
|
14
15
|
end
|
16
|
+
# :nocov:
|
15
17
|
|
16
18
|
# Returns a new instance of Vedeu::Bootstrap.
|
17
19
|
#
|
@@ -23,6 +25,10 @@ module Vedeu
|
|
23
25
|
@entry_point = entry_point
|
24
26
|
end
|
25
27
|
|
28
|
+
# Loads all of the client application files so that Vedeu has access to
|
29
|
+
# them, calls the 'entry_point' controller, ready to start the application,
|
30
|
+
# then launches the client application.
|
31
|
+
#
|
26
32
|
# @return [void]
|
27
33
|
def start
|
28
34
|
Vedeu.configure { log('/tmp/vedeu_bootstrap.log') }
|
@@ -57,6 +63,8 @@ module Vedeu
|
|
57
63
|
|
58
64
|
private
|
59
65
|
|
66
|
+
# Load each of the loadable files.
|
67
|
+
#
|
60
68
|
# @param path [String]
|
61
69
|
# @return [String]
|
62
70
|
def load(path)
|
@@ -65,6 +73,9 @@ module Vedeu
|
|
65
73
|
path
|
66
74
|
end
|
67
75
|
|
76
|
+
# Collect each of the files from the client application directories by path
|
77
|
+
# excluding '.' and '..' and only loading files with the '.rb' extension.
|
78
|
+
#
|
68
79
|
# @param path [String]
|
69
80
|
# @return [Array<String>]
|
70
81
|
def loadables(path)
|
data/lib/vedeu/buffers/buffer.rb
CHANGED
@@ -281,7 +281,7 @@ module Vedeu
|
|
281
281
|
# other resources). By default the base path is just cwd but this will
|
282
282
|
# not work for many applications.
|
283
283
|
#
|
284
|
-
# @param
|
284
|
+
# @param path [String]
|
285
285
|
# @return [String]
|
286
286
|
def base_path(path = nil)
|
287
287
|
options[:base_path] = path
|
@@ -347,20 +347,6 @@ module Vedeu
|
|
347
347
|
value.is_a?(Fixnum) && [8, 16, 256, 16_777_216].include?(value)
|
348
348
|
end
|
349
349
|
|
350
|
-
# Checks that the value provided to {#exit_key}, {#focus_next_key},
|
351
|
-
# {#focus_prev_key} and {#mode_switch_key} is valid. Must be a Symbol or a
|
352
|
-
# non-empty String.
|
353
|
-
#
|
354
|
-
# @param value [String|Symbol]
|
355
|
-
# @return [Boolean]
|
356
|
-
def valid_key?(value)
|
357
|
-
return false unless value.is_a?(String) || value.is_a?(Symbol)
|
358
|
-
|
359
|
-
return false if value.is_a?(String) && value.size != 1
|
360
|
-
|
361
|
-
(value.is_a?(String) || value.is_a?(Symbol)) && present?(value)
|
362
|
-
end
|
363
|
-
|
364
350
|
end # API
|
365
351
|
|
366
352
|
end # Config
|
data/lib/vedeu/cursor/cursor.rb
CHANGED
@@ -92,6 +92,8 @@ module Vedeu
|
|
92
92
|
@attributes.each { |key, value| instance_variable_set("@#{key}", value) }
|
93
93
|
end
|
94
94
|
|
95
|
+
# Override Ruby's Object#inspect method to provide a more helpful output.
|
96
|
+
#
|
95
97
|
# @return [String]
|
96
98
|
def inspect
|
97
99
|
'<Vedeu::Geometry ' \
|
@@ -198,6 +200,8 @@ module Vedeu
|
|
198
200
|
@xn.is_a?(Proc) ? @xn.call : @xn
|
199
201
|
end
|
200
202
|
|
203
|
+
# Returns the default options/attributes for this class.
|
204
|
+
#
|
201
205
|
# @return [Hash]
|
202
206
|
def defaults
|
203
207
|
{
|
data/lib/vedeu/input/keymap.rb
CHANGED
data/lib/vedeu/launcher.rb
CHANGED
@@ -13,6 +13,7 @@ module Vedeu
|
|
13
13
|
# error occurred (1).
|
14
14
|
attr_reader :exit_code
|
15
15
|
|
16
|
+
# :nocov:
|
16
17
|
# @param (see #initialize)
|
17
18
|
def self.execute!(argv = [],
|
18
19
|
stdin = STDIN,
|
@@ -21,6 +22,7 @@ module Vedeu
|
|
21
22
|
kernel = Kernel)
|
22
23
|
new(argv, stdin, stdout, stderr, kernel).debug_execute!
|
23
24
|
end
|
25
|
+
# :nocov:
|
24
26
|
|
25
27
|
# Returns a new instance of Vedeu::Launcher.
|
26
28
|
#
|
@@ -43,6 +45,11 @@ module Vedeu
|
|
43
45
|
@exit_code = 1
|
44
46
|
end
|
45
47
|
|
48
|
+
# :nocov:
|
49
|
+
# If debugging is enabled, execute the application within the debugging
|
50
|
+
# context. At the moment, this simple uses 'ruby-prof' to profile the
|
51
|
+
# running application.
|
52
|
+
#
|
46
53
|
# @return [void]
|
47
54
|
def debug_execute!
|
48
55
|
if configuration.debug?
|
@@ -55,7 +62,12 @@ module Vedeu
|
|
55
62
|
|
56
63
|
terminate!
|
57
64
|
end
|
65
|
+
# :nocov:
|
58
66
|
|
67
|
+
# Alters the STD[IN|OUT|ERR] to those requested by the client application,
|
68
|
+
# then starts the application. If an uncaught exception occurs during the
|
69
|
+
# application runtime, we exit ungracefully with the error message if any.
|
70
|
+
#
|
59
71
|
# @return [void]
|
60
72
|
def execute!
|
61
73
|
$stdin = @stdin
|
@@ -79,6 +91,7 @@ module Vedeu
|
|
79
91
|
|
80
92
|
private
|
81
93
|
|
94
|
+
# :nocov:
|
82
95
|
# Terminates the application after resetting $stdin, $stdout and $stderr.
|
83
96
|
#
|
84
97
|
# @return [void]
|
@@ -91,6 +104,7 @@ module Vedeu
|
|
91
104
|
|
92
105
|
@kernel.exit(exit_code)
|
93
106
|
end
|
107
|
+
# :nocov:
|
94
108
|
|
95
109
|
# Use the arguments passed on the command-line along with those defined by
|
96
110
|
# the client application and Vedeu's defaults to configure the client
|
data/lib/vedeu/main_loop.rb
CHANGED
@@ -38,6 +38,7 @@ module Vedeu
|
|
38
38
|
@loop = false
|
39
39
|
end
|
40
40
|
|
41
|
+
# :nocov:
|
41
42
|
# Check the application has started and we wish to continue running.
|
42
43
|
#
|
43
44
|
# @raise [VedeuInterrupt] When we wish to terminate the running
|
@@ -46,6 +47,7 @@ module Vedeu
|
|
46
47
|
def safe_exit_point!
|
47
48
|
fail VedeuInterrupt if @started && !@loop
|
48
49
|
end
|
50
|
+
# :nocov:
|
49
51
|
|
50
52
|
end
|
51
53
|
|
data/lib/vedeu/models/cell.rb
CHANGED
data/lib/vedeu/models/char.rb
CHANGED
data/lib/vedeu/models/group.rb
CHANGED
data/lib/vedeu/output/clear.rb
CHANGED
data/lib/vedeu/output/esc.rb
CHANGED
@@ -122,11 +122,9 @@ module Vedeu
|
|
122
122
|
# @param value [String|Symbol]
|
123
123
|
# @return [String]
|
124
124
|
def string(value = '')
|
125
|
-
|
125
|
+
return '' if value.empty?
|
126
126
|
|
127
|
-
|
128
|
-
|
129
|
-
send(name)
|
127
|
+
send(value.to_sym)
|
130
128
|
|
131
129
|
rescue NoMethodError
|
132
130
|
''
|
@@ -155,11 +153,6 @@ module Vedeu
|
|
155
153
|
[colour_reset, "\e[2K"].join
|
156
154
|
end
|
157
155
|
|
158
|
-
# @return [String]
|
159
|
-
def clear_last_line
|
160
|
-
Vedeu::Position.new((Vedeu::Terminal.height - 1), 1).to_s { clear_line }
|
161
|
-
end
|
162
|
-
|
163
156
|
# @return [String]
|
164
157
|
def colour_reset
|
165
158
|
[fg_reset, bg_reset].join
|
@@ -177,13 +170,12 @@ module Vedeu
|
|
177
170
|
|
178
171
|
# @return [String]
|
179
172
|
def screen_exit
|
180
|
-
[
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
].join
|
173
|
+
[show_cursor, colour_reset, reset, last_character_position, "\n"].join
|
174
|
+
end
|
175
|
+
|
176
|
+
# @return [String]
|
177
|
+
def last_character_position
|
178
|
+
Vedeu::Position.new(Vedeu.height, Vedeu.width).to_s
|
187
179
|
end
|
188
180
|
|
189
181
|
end # Esc
|
@@ -92,17 +92,43 @@ module Vedeu
|
|
92
92
|
border: type)
|
93
93
|
end
|
94
94
|
|
95
|
+
# @return [Array<Vedeu::Char>]
|
96
|
+
def build_bottom_horizontal
|
97
|
+
horizontal_border(:bottom_horizontal, yn)
|
98
|
+
end
|
99
|
+
|
100
|
+
# @return [Vedeu::Char]
|
101
|
+
def build_bottom_left
|
102
|
+
build(bottom_left, :bottom_left, *[yn, x]) if left?
|
103
|
+
end
|
104
|
+
|
105
|
+
# @return [Vedeu::Char]
|
106
|
+
def build_bottom_right
|
107
|
+
build(bottom_right, :bottom_right, *[yn, xn]) if right?
|
108
|
+
end
|
109
|
+
|
110
|
+
# @return [Array<Vedeu::Char>]
|
111
|
+
def build_top_horizontal
|
112
|
+
horizontal_border(:top_horizontal, y)
|
113
|
+
end
|
114
|
+
|
115
|
+
# @return [Vedeu::Char]
|
116
|
+
def build_top_left
|
117
|
+
build(top_left, :top_left, *[y, x]) if left?
|
118
|
+
end
|
119
|
+
|
120
|
+
# @return [Vedeu::Char]
|
121
|
+
def build_top_right
|
122
|
+
build(top_right, :top_right, *[y, xn]) if right?
|
123
|
+
end
|
124
|
+
|
95
125
|
# Renders the bottom border for the interface.
|
96
126
|
#
|
97
127
|
# @return [String]
|
98
128
|
def bottom
|
99
129
|
return [] unless bottom?
|
100
130
|
|
101
|
-
|
102
|
-
out << build(bottom_left, :bottom_left, *[yn, x]) if left?
|
103
|
-
out << horizontal_border(:bottom_horizontal, yn)
|
104
|
-
out << build(bottom_right, :bottom_right, *[yn, xn]) if right?
|
105
|
-
out
|
131
|
+
[build_bottom_left, build_bottom_horizontal, build_bottom_right].compact
|
106
132
|
end
|
107
133
|
|
108
134
|
# @return [Vedeu::Geometry]
|
@@ -169,12 +195,22 @@ module Vedeu
|
|
169
195
|
present?(title)
|
170
196
|
end
|
171
197
|
|
198
|
+
# Return boolean indicating whether the title fits within the width of the
|
199
|
+
# top border.
|
200
|
+
#
|
201
|
+
# @return [Boolean]
|
202
|
+
def title_fits?
|
203
|
+
width > title_characters.size
|
204
|
+
end
|
205
|
+
|
172
206
|
# From the second element of {#title_characters} remove the border from each
|
173
207
|
# {#horizontal_border} Vedeu::Char, and add the title character.
|
174
208
|
#
|
175
209
|
# @return [Array<Vedeu::Char>]
|
176
210
|
def titlebar
|
177
|
-
|
211
|
+
return build_top_horizontal unless title? && title_fits?
|
212
|
+
|
213
|
+
build_top_horizontal.each_with_index do |char, index|
|
178
214
|
if index >= 1 && index <= title_characters.size
|
179
215
|
char.border = nil
|
180
216
|
char.value = title_characters[(index - 1)]
|
@@ -198,19 +234,7 @@ module Vedeu
|
|
198
234
|
def top
|
199
235
|
return [] unless top?
|
200
236
|
|
201
|
-
|
202
|
-
out << build(top_left, :top_left, *[y, x]) if left?
|
203
|
-
|
204
|
-
if title? && width > title_characters.size
|
205
|
-
out << titlebar
|
206
|
-
|
207
|
-
else
|
208
|
-
out << horizontal_border(:top_horizontal, y)
|
209
|
-
|
210
|
-
end
|
211
|
-
|
212
|
-
out << build(top_right, :top_right, *[y, xn]) if right?
|
213
|
-
out
|
237
|
+
[build_top_left, titlebar, build_top_right].compact
|
214
238
|
end
|
215
239
|
|
216
240
|
# Truncates the title to the width of the interface, minus characters needed
|