vedeu 0.8.12 → 0.8.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/vedeu +1 -1
- data/docs/dsl/by_method/profile.md +1 -1
- data/docs/dsl/by_method/view/repositories.md +4 -0
- data/integrations/342_streams.rb +1 -1
- data/integrations/dsl_app_001.rb +1 -0
- data/integrations/dsl_app_002.rb +1 -0
- data/integrations/dsl_app_003.rb +1 -0
- data/integrations/dsl_app_004.rb +1 -0
- data/integrations/dsl_app_005.rb +1 -0
- data/integrations/dsl_app_006.rb +1 -0
- data/integrations/dsl_app_007.rb +1 -0
- data/integrations/dsl_app_008.rb +1 -0
- data/integrations/dsl_app_009.rb +1 -0
- data/integrations/dsl_app_010.rb +1 -0
- data/integrations/dsl_app_011.rb +1 -0
- data/integrations/dsl_app_012.rb +1 -0
- data/integrations/dsl_app_013.rb +1 -0
- data/integrations/dsl_app_014.rb +1 -0
- data/integrations/dsl_app_015.rb +1 -0
- data/integrations/dsl_app_016.rb +1 -0
- data/integrations/dsl_app_017.rb +1 -0
- data/integrations/dsl_app_018.rb +1 -0
- data/integrations/dsl_app_019.rb +1 -0
- data/integrations/dsl_app_020.rb +1 -0
- data/integrations/dsl_app_021.rb +1 -0
- data/integrations/dsl_app_022.rb +1 -0
- data/integrations/dsl_app_border_001.rb +1 -0
- data/integrations/dsl_app_border_002.rb +1 -0
- data/integrations/dsl_app_border_003.rb +1 -0
- data/integrations/dsl_app_border_004.rb +1 -0
- data/integrations/dsl_app_border_005.rb +1 -0
- data/lib/vedeu/application/application_view.rb +3 -3
- data/lib/vedeu/borders/dsl.rb +2 -2
- data/lib/vedeu/borders/title.rb +1 -1
- data/lib/vedeu/buffers/view.rb +1 -11
- data/lib/vedeu/cells/empty.rb +2 -2
- data/lib/vedeu/coercers/alignment.rb +5 -5
- data/lib/vedeu/coercers/coercer.rb +4 -5
- data/lib/vedeu/coercers/colour_attributes.rb +1 -1
- data/lib/vedeu/coercers/horizontal_alignment.rb +3 -3
- data/lib/vedeu/coercers/position.rb +4 -9
- data/lib/vedeu/coercers/vertical_alignment.rb +3 -3
- data/lib/vedeu/colours/colour.rb +2 -1
- data/lib/vedeu/colours/translator.rb +2 -2
- data/lib/vedeu/common.rb +20 -1
- data/lib/vedeu/configuration/api.rb +8 -6
- data/lib/vedeu/configuration/configuration.rb +2 -2
- data/lib/vedeu/cursors/coordinate.rb +2 -2
- data/lib/vedeu/cursors/cursor.rb +3 -2
- data/lib/vedeu/dsl/border.rb +1 -1
- data/lib/vedeu/dsl/elements.rb +9 -9
- data/lib/vedeu/dsl/geometry.rb +3 -3
- data/lib/vedeu/dsl/helpers/wordwrap.rb +4 -4
- data/lib/vedeu/dsl/view.rb +9 -9
- data/lib/vedeu/dsl/views.rb +2 -2
- data/lib/vedeu/editor/document.rb +1 -1
- data/lib/vedeu/editor/item.rb +17 -15
- data/lib/vedeu/esc/colours.rb +21 -20
- data/lib/vedeu/geometries/area/area.rb +6 -2
- data/lib/vedeu/geometries/dsl/grid.rb +2 -2
- data/lib/vedeu/geometries/geometry.rb +34 -46
- data/lib/vedeu/geometries/move.rb +5 -4
- data/lib/vedeu/geometries/position.rb +1 -1
- data/lib/vedeu/groups/dsl.rb +2 -2
- data/lib/vedeu/groups/group.rb +1 -1
- data/lib/vedeu/groups/refresh.rb +2 -2
- data/lib/vedeu/input/capture.rb +2 -1
- data/lib/vedeu/input/dsl.rb +22 -16
- data/lib/vedeu/input/key.rb +1 -1
- data/lib/vedeu/input/mapper.rb +6 -6
- data/lib/vedeu/input/read.rb +2 -2
- data/lib/vedeu/interfaces/dsl.rb +2 -2
- data/lib/vedeu/logging/debug.rb +10 -10
- data/lib/vedeu/logging/timer.rb +7 -11
- data/lib/vedeu/menus/dsl.rb +2 -2
- data/lib/vedeu/models/focus.rb +3 -3
- data/lib/vedeu/models/page.rb +1 -1
- data/lib/vedeu/models/row.rb +1 -1
- data/lib/vedeu/presentation/style.rb +1 -1
- data/lib/vedeu/renderers/escape.rb +0 -6
- data/lib/vedeu/renderers/options.rb +3 -3
- data/lib/vedeu/renderers/text.rb +0 -6
- data/lib/vedeu/repositories/assemblage.rb +1 -1
- data/lib/vedeu/repositories/defaults.rb +2 -2
- data/lib/vedeu/repositories/repositories.rb +17 -1
- data/lib/vedeu/repositories/repository.rb +5 -5
- data/lib/vedeu/runtime/application.rb +3 -3
- data/lib/vedeu/runtime/main_loop.rb +2 -2
- data/lib/vedeu/runtime/router.rb +11 -11
- data/lib/vedeu/support/point.rb +18 -15
- data/lib/vedeu/templating/helpers.rb +1 -1
- data/lib/vedeu/templating/template.rb +4 -4
- data/lib/vedeu/terminal/terminal.rb +1 -1
- data/lib/vedeu/version.rb +1 -1
- data/lib/vedeu/views/chars.rb +3 -3
- data/lib/vedeu/views/line.rb +1 -1
- data/lib/vedeu/views/lines.rb +3 -3
- data/lib/vedeu/views/stream.rb +1 -1
- data/lib/vedeu/views/streams.rb +3 -3
- data/lib/vedeu/views/view.rb +2 -2
- data/test/lib/vedeu/common_test.rb +43 -0
- data/test/lib/vedeu/cursors/cursor_test.rb +1 -1
- data/test/lib/vedeu/esc/colours_test.rb +42 -0
- data/test/lib/vedeu/input/dsl_test.rb +8 -8
- data/test/lib/vedeu/logging/debug_test.rb +2 -2
- data/test/lib/vedeu/logging/timer_test.rb +4 -13
- data/test/lib/vedeu/renderers/escape_test.rb +24 -0
- data/test/lib/vedeu/repositories/repositories_test.rb +6 -0
- data/test/support/examples/material_colours_app.rb +30 -51
- data/vedeu.gemspec +2 -2
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 002c233933994a1c074caa09713374413fb3ec7e
|
4
|
+
data.tar.gz: f083bf135c2d9307329af03198159f73ecc88548
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0c4f251a4537d4907ec3b9b1eea499be60b8be212fc8544e3ce7beef9eaff3b33ed8d5ef73cd0dc6ad85965a88f77aa0f7dd06336bb2f5718db33e0dabfaa3e
|
7
|
+
data.tar.gz: 86f69b80ad1db0b0df5ef2bce701c33e6f09e8d57ab9784331f1cca01b3eb48781992ce61d451915b9caf0557564a8ec91d451bed3ba27b3187803907c486f78
|
data/bin/vedeu
CHANGED
data/integrations/342_streams.rb
CHANGED
data/integrations/dsl_app_001.rb
CHANGED
data/integrations/dsl_app_002.rb
CHANGED
data/integrations/dsl_app_003.rb
CHANGED
data/integrations/dsl_app_004.rb
CHANGED
data/integrations/dsl_app_005.rb
CHANGED
data/integrations/dsl_app_006.rb
CHANGED
data/integrations/dsl_app_007.rb
CHANGED
data/integrations/dsl_app_008.rb
CHANGED
data/integrations/dsl_app_009.rb
CHANGED
data/integrations/dsl_app_010.rb
CHANGED
data/integrations/dsl_app_011.rb
CHANGED
data/integrations/dsl_app_012.rb
CHANGED
data/integrations/dsl_app_013.rb
CHANGED
data/integrations/dsl_app_014.rb
CHANGED
data/integrations/dsl_app_015.rb
CHANGED
data/integrations/dsl_app_016.rb
CHANGED
data/integrations/dsl_app_017.rb
CHANGED
data/integrations/dsl_app_018.rb
CHANGED
data/integrations/dsl_app_019.rb
CHANGED
data/integrations/dsl_app_020.rb
CHANGED
data/integrations/dsl_app_021.rb
CHANGED
data/integrations/dsl_app_022.rb
CHANGED
@@ -34,9 +34,9 @@ module Vedeu
|
|
34
34
|
|
35
35
|
# @macro raise_not_implemented
|
36
36
|
def render
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
raise Vedeu::Error::NotImplemented,
|
38
|
+
'The subclass of Vedeu::ApplicationView must implement the ' \
|
39
|
+
'#render method.'
|
40
40
|
end
|
41
41
|
|
42
42
|
protected
|
data/lib/vedeu/borders/dsl.rb
CHANGED
@@ -21,8 +21,8 @@ module Vedeu
|
|
21
21
|
# @macro raise_missing_required
|
22
22
|
# @return [Vedeu::Borders::Border]
|
23
23
|
def self.border(name, &block)
|
24
|
-
|
25
|
-
|
24
|
+
raise Vedeu::Error::MissingRequired unless name
|
25
|
+
raise Vedeu::Error::RequiresBlock unless block_given?
|
26
26
|
|
27
27
|
Vedeu::Borders::Border.build(enabled: true, name: name, &block).store
|
28
28
|
end
|
data/lib/vedeu/borders/title.rb
CHANGED
data/lib/vedeu/buffers/view.rb
CHANGED
@@ -88,21 +88,11 @@ module Vedeu
|
|
88
88
|
# @param value [void]
|
89
89
|
# @return [Boolean]
|
90
90
|
def valid?(value)
|
91
|
-
|
91
|
+
positionable?(value) &&
|
92
92
|
valid_y?(value.position.y) &&
|
93
93
|
valid_x?(value.position.x)
|
94
94
|
end
|
95
95
|
|
96
|
-
# Returns a boolean indicating the value has a position
|
97
|
-
# attribute.
|
98
|
-
#
|
99
|
-
# @param value [void]
|
100
|
-
# @return [Boolean]
|
101
|
-
def valid_value?(value)
|
102
|
-
value.respond_to?(:position) &&
|
103
|
-
value.position.is_a?(Vedeu::Geometries::Position)
|
104
|
-
end
|
105
|
-
|
106
96
|
# Returns a boolean indicating whether the x position of the
|
107
97
|
# value object is valid for this geometry.
|
108
98
|
#
|
data/lib/vedeu/cells/empty.rb
CHANGED
@@ -38,9 +38,9 @@ module Vedeu
|
|
38
38
|
# @param other [void]
|
39
39
|
# @return [Boolean]
|
40
40
|
def eql?(other)
|
41
|
-
self.class
|
41
|
+
self.class.equal?(other.class) &&
|
42
42
|
position == other.position &&
|
43
|
-
value == other.value
|
43
|
+
value == other.value &&
|
44
44
|
colour == other.colour
|
45
45
|
end
|
46
46
|
alias == eql?
|
@@ -76,7 +76,7 @@ module Vedeu
|
|
76
76
|
# @param other [void]
|
77
77
|
# @return [Boolean]
|
78
78
|
def eql?(other)
|
79
|
-
self.class
|
79
|
+
self.class.equal?(other.class) && value == other.value
|
80
80
|
end
|
81
81
|
alias == eql?
|
82
82
|
|
@@ -132,9 +132,9 @@ module Vedeu
|
|
132
132
|
def validate
|
133
133
|
return coerce if valid_horizontal? || valid_vertical?
|
134
134
|
|
135
|
-
|
136
|
-
|
137
|
-
|
135
|
+
raise Vedeu::Error::InvalidSyntax,
|
136
|
+
'Missing or invalid alignment value. ' \
|
137
|
+
"Valid values are: #{to_sentence}"
|
138
138
|
end
|
139
139
|
|
140
140
|
# @return [Boolean]
|
@@ -167,7 +167,7 @@ module Vedeu
|
|
167
167
|
|
168
168
|
# @return [Boolean]
|
169
169
|
def valid_type?
|
170
|
-
present?(value) &&
|
170
|
+
present?(value) && symbol?(value)
|
171
171
|
end
|
172
172
|
|
173
173
|
# @return [Array<Symbol>]
|
@@ -30,7 +30,7 @@ module Vedeu
|
|
30
30
|
# @macro raise_not_implemented
|
31
31
|
# @return [void]
|
32
32
|
def coerce
|
33
|
-
|
33
|
+
raise Vedeu::Error::NotImplemented, 'Subclasses implement this.'
|
34
34
|
end
|
35
35
|
|
36
36
|
protected
|
@@ -49,15 +49,14 @@ module Vedeu
|
|
49
49
|
# @macro raise_fatal
|
50
50
|
# @return [void]
|
51
51
|
def incoercible!
|
52
|
-
|
53
|
-
|
54
|
-
"'#{klass}'."
|
52
|
+
raise Vedeu::Error::Fatal,
|
53
|
+
"Vedeu cannot coerce a '#{value.class.name}' into a '#{klass}'."
|
55
54
|
end
|
56
55
|
|
57
56
|
# @macro raise_not_implemented
|
58
57
|
# @return [Class]
|
59
58
|
def klass
|
60
|
-
|
59
|
+
raise Vedeu::Error::NotImplemented, 'Subclasses implement this.'
|
61
60
|
end
|
62
61
|
|
63
62
|
end # Coercer
|
@@ -28,7 +28,7 @@ module Vedeu
|
|
28
28
|
# @macro raise_invalid_syntax
|
29
29
|
# @return [Hash]
|
30
30
|
def coerce
|
31
|
-
|
31
|
+
raise Vedeu::Error::InvalidSyntax unless hash?(value)
|
32
32
|
|
33
33
|
if colour? && hash?(colour)
|
34
34
|
Vedeu::Coercers::ColourAttributes.coerce(colour)
|
@@ -15,9 +15,9 @@ module Vedeu
|
|
15
15
|
def validate
|
16
16
|
return coerce if valid_horizontal?
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
raise Vedeu::Error::InvalidSyntax,
|
19
|
+
'Missing or invalid horizontal alignment value. ' \
|
20
|
+
"Valid values are: #{to_sentence}"
|
21
21
|
end
|
22
22
|
|
23
23
|
private
|
@@ -23,7 +23,7 @@ module Vedeu
|
|
23
23
|
elsif hash?
|
24
24
|
klass.new(value.fetch(:y, 1), value.fetch(:x, 1))
|
25
25
|
|
26
|
-
elsif
|
26
|
+
elsif numeric?(value)
|
27
27
|
klass.new(value, 1)
|
28
28
|
|
29
29
|
else
|
@@ -34,11 +34,6 @@ module Vedeu
|
|
34
34
|
|
35
35
|
private
|
36
36
|
|
37
|
-
# @return [Boolean]
|
38
|
-
def fixnum?
|
39
|
-
value.is_a?(Fixnum)
|
40
|
-
end
|
41
|
-
|
42
37
|
# @return [Boolean]
|
43
38
|
def hash?
|
44
39
|
value.is_a?(Hash)
|
@@ -55,9 +50,9 @@ module Vedeu
|
|
55
50
|
return false unless value.is_a?(Array)
|
56
51
|
return true if value.size == 2
|
57
52
|
|
58
|
-
|
59
|
-
|
60
|
-
|
53
|
+
raise Vedeu::Error::Fatal,
|
54
|
+
"A '#{klass}' is made up of two elements. (Provided " \
|
55
|
+
"#{value.size}.)"
|
61
56
|
end
|
62
57
|
|
63
58
|
end # Position
|
@@ -15,9 +15,9 @@ module Vedeu
|
|
15
15
|
def validate
|
16
16
|
return coerce if valid_vertical?
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
raise Vedeu::Error::InvalidSyntax,
|
19
|
+
'Missing or invalid vertical alignment value. ' \
|
20
|
+
"Valid values are: #{to_sentence}"
|
21
21
|
end
|
22
22
|
|
23
23
|
private
|
data/lib/vedeu/colours/colour.rb
CHANGED
@@ -90,7 +90,8 @@ module Vedeu
|
|
90
90
|
# @param other [void]
|
91
91
|
# @return [Boolean]
|
92
92
|
def eql?(other)
|
93
|
-
self.class
|
93
|
+
self.class.equal?(other.class) &&
|
94
|
+
background == other.background &&
|
94
95
|
foreground == other.foreground
|
95
96
|
end
|
96
97
|
alias == eql?
|
@@ -74,7 +74,7 @@ module Vedeu
|
|
74
74
|
# @param other [void]
|
75
75
|
# @return [Boolean]
|
76
76
|
def eql?(other)
|
77
|
-
self.class
|
77
|
+
self.class.equal?(other.class) && colour == other.colour
|
78
78
|
end
|
79
79
|
alias == eql?
|
80
80
|
|
@@ -217,7 +217,7 @@ module Vedeu
|
|
217
217
|
|
218
218
|
# @macro raise_not_implemented
|
219
219
|
def not_implemented
|
220
|
-
|
220
|
+
raise Vedeu::Error::NotImplemented, 'Subclasses implement this.'
|
221
221
|
end
|
222
222
|
alias named not_implemented
|
223
223
|
alias repository not_implemented
|
data/lib/vedeu/common.rb
CHANGED
@@ -81,6 +81,17 @@ module Vedeu
|
|
81
81
|
def numeric?(value)
|
82
82
|
value.is_a?(Fixnum)
|
83
83
|
end
|
84
|
+
alias fixnum? numeric?
|
85
|
+
|
86
|
+
# Returns a boolean indicating the value has a position
|
87
|
+
# attribute.
|
88
|
+
#
|
89
|
+
# @param value [void]
|
90
|
+
# @return [Boolean]
|
91
|
+
def positionable?(value)
|
92
|
+
value.respond_to?(:position) &&
|
93
|
+
value.position.is_a?(Vedeu::Geometries::Position)
|
94
|
+
end
|
84
95
|
|
85
96
|
# Returns a boolean indicating whether a variable has a useful
|
86
97
|
# value.
|
@@ -135,7 +146,7 @@ module Vedeu
|
|
135
146
|
end
|
136
147
|
end
|
137
148
|
|
138
|
-
# Returns a boolean indicating whether the value is a
|
149
|
+
# Returns a boolean indicating whether the value is a String.
|
139
150
|
#
|
140
151
|
# @param value [String|void]
|
141
152
|
# @return [Boolean]
|
@@ -143,6 +154,14 @@ module Vedeu
|
|
143
154
|
value.is_a?(String)
|
144
155
|
end
|
145
156
|
|
157
|
+
# Returns a boolean indicating whether the value is a Symbol.
|
158
|
+
#
|
159
|
+
# @param value [Symbol|void]
|
160
|
+
# @return [Boolean]
|
161
|
+
def symbol?(value)
|
162
|
+
value.is_a?(Symbol)
|
163
|
+
end
|
164
|
+
|
146
165
|
# Returns a boolean indicating whether the value should be
|
147
166
|
# considered true.
|
148
167
|
#
|
@@ -10,6 +10,8 @@ module Vedeu
|
|
10
10
|
#
|
11
11
|
class API
|
12
12
|
|
13
|
+
include Vedeu::Common
|
14
|
+
|
13
15
|
# @param (see #initialize)
|
14
16
|
def self.configure(&block)
|
15
17
|
new(&block).configuration
|
@@ -200,8 +202,8 @@ module Vedeu
|
|
200
202
|
# @return [Boolean]
|
201
203
|
def colour_mode(value = nil)
|
202
204
|
unless valid_colour_mode?(value)
|
203
|
-
|
204
|
-
|
205
|
+
raise Vedeu::Error::InvalidSyntax,
|
206
|
+
'`colour_mode` must be `8`, `16`, `256`, `16777216`.'
|
205
207
|
end
|
206
208
|
|
207
209
|
options[:colour_mode] = value
|
@@ -282,7 +284,7 @@ module Vedeu
|
|
282
284
|
# setting is for profiling to be disabled. Using `profile!` or
|
283
285
|
# setting `profile` to true will enable profiling.
|
284
286
|
#
|
285
|
-
# Profile uses 'ruby-prof' to write a '
|
287
|
+
# Profile uses 'ruby-prof' to write a 'vedeu_profile' file to
|
286
288
|
# the /tmp directory which contains a call trace of the running
|
287
289
|
# application. Upon exit, this file can be examined to ascertain
|
288
290
|
# certain behaviours of Vedeu.
|
@@ -559,8 +561,8 @@ module Vedeu
|
|
559
561
|
|
560
562
|
# @macro raise_invalid_syntax
|
561
563
|
def invalid_mode!
|
562
|
-
|
563
|
-
|
564
|
+
raise Vedeu::Error::InvalidSyntax,
|
565
|
+
'Terminal mode can be set to either :cooked, :fake or :raw'
|
564
566
|
end
|
565
567
|
|
566
568
|
# Returns the options set via the configuration API DSL or an
|
@@ -576,7 +578,7 @@ module Vedeu
|
|
576
578
|
# @param value [Fixnum]
|
577
579
|
# @return [Boolean]
|
578
580
|
def valid_colour_mode?(value)
|
579
|
-
|
581
|
+
numeric?(value) && [8, 16, 256, 16_777_216].include?(value)
|
580
582
|
end
|
581
583
|
|
582
584
|
# Checks that the mode provided is valid.
|
@@ -149,7 +149,7 @@ module Vedeu
|
|
149
149
|
|
150
150
|
# @return [Boolean]
|
151
151
|
def height?
|
152
|
-
instance.options[:height]
|
152
|
+
numeric?(instance.options[:height])
|
153
153
|
end
|
154
154
|
|
155
155
|
# Returns whether the application is interactive (required user
|
@@ -299,7 +299,7 @@ module Vedeu
|
|
299
299
|
|
300
300
|
# @return [Boolean]
|
301
301
|
def width?
|
302
|
-
instance.options[:width]
|
302
|
+
numeric?(instance.options[:width])
|
303
303
|
end
|
304
304
|
|
305
305
|
# @param value [void]
|
@@ -86,8 +86,8 @@ module Vedeu
|
|
86
86
|
when :x then Vedeu::XCoordinate.new(geometry)
|
87
87
|
when :y then Vedeu::YCoordinate.new(geometry)
|
88
88
|
else
|
89
|
-
|
90
|
-
|
89
|
+
raise Vedeu::Error::InvalidSyntax,
|
90
|
+
'Coordinate type not given, cannot continue.'
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|