vedeu 0.8.5 → 0.8.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/dsl/by_method/geometry.md +25 -1
- data/docs/dsl/by_method/geometry/align.md +13 -1
- data/docs/events/by_name/refresh_border.md +6 -2
- data/docs/events/by_name/refresh_view.md +3 -0
- data/docs/events/by_name/refresh_view_content.md +3 -0
- data/integrations/expected/dsl_app_021.out +1 -1
- data/integrations/expected/dsl_app_022.out +1 -1
- data/integrations/test_runner.sh +2 -0
- data/lib/vedeu/application/application_view.rb +1 -2
- data/lib/vedeu/borders/dsl.rb +1 -2
- data/lib/vedeu/borders/refresh.rb +2 -4
- data/lib/vedeu/buffers/empty.rb +10 -8
- data/lib/vedeu/buffers/refresh.rb +4 -8
- data/lib/vedeu/buffers/view.rb +6 -6
- data/lib/vedeu/coercers/alignment.rb +1 -2
- data/lib/vedeu/coercers/colour_attributes.rb +1 -0
- data/lib/vedeu/coercers/horizontal_alignment.rb +1 -1
- data/lib/vedeu/coercers/vertical_alignment.rb +1 -1
- data/lib/vedeu/colours/translator.rb +1 -3
- data/lib/vedeu/common.rb +12 -4
- data/lib/vedeu/configuration/api.rb +3 -5
- data/lib/vedeu/configuration/configuration.rb +0 -2
- data/lib/vedeu/cursors/coordinate.rb +1 -2
- data/lib/vedeu/dsl/border.rb +2 -4
- data/lib/vedeu/dsl/geometry.rb +4 -31
- data/lib/vedeu/dsl/helpers/wordwrap.rb +1 -1
- data/lib/vedeu/dsl/view.rb +4 -3
- data/lib/vedeu/error.rb +17 -0
- data/lib/vedeu/geometries/dsl/dsl.rb +2 -19
- data/lib/vedeu/groups/refresh.rb +1 -2
- data/lib/vedeu/input/dsl.rb +2 -6
- data/lib/vedeu/input/mapper.rb +1 -2
- data/lib/vedeu/input/read.rb +1 -0
- data/lib/vedeu/interfaces/dsl.rb +1 -0
- data/lib/vedeu/menus/dsl.rb +1 -2
- data/lib/vedeu/models/page.rb +1 -0
- data/lib/vedeu/output/output.rb +35 -44
- data/lib/vedeu/renderers/html.rb +1 -10
- data/lib/vedeu/renderers/options.rb +16 -21
- data/lib/vedeu/renderers/terminal.rb +4 -0
- data/lib/vedeu/repositories/defaults.rb +1 -2
- data/lib/vedeu/repositories/repository.rb +2 -3
- data/lib/vedeu/runtime/router.rb +3 -6
- data/lib/vedeu/support/point.rb +11 -0
- data/lib/vedeu/templating/template.rb +1 -2
- data/lib/vedeu/version.rb +1 -1
- data/lib/vedeu/views/chars.rb +1 -2
- data/lib/vedeu/views/lines.rb +1 -2
- data/lib/vedeu/views/streams.rb +1 -2
- data/lib/vedeu/views/view.rb +1 -2
- data/test/lib/vedeu/buffers/empty_test.rb +2 -2
- data/test/lib/vedeu/common_test.rb +22 -0
- data/test/lib/vedeu/output/output_test.rb +2 -2
- metadata +2 -2
@@ -151,8 +151,7 @@ module Vedeu
|
|
151
151
|
# @note If a block is given, store the model, return the model
|
152
152
|
# after yielding.
|
153
153
|
# @param model [void] A model instance.
|
154
|
-
# @
|
155
|
-
# is not defined.
|
154
|
+
# @macro raise_missing_required
|
156
155
|
# @return [void] The model instance which was stored.
|
157
156
|
def store(model, &block)
|
158
157
|
valid_model?(model)
|
@@ -179,8 +178,8 @@ module Vedeu
|
|
179
178
|
message: "#{model.class.name}: '#{model.name}'")
|
180
179
|
end
|
181
180
|
|
182
|
-
#
|
183
181
|
# @param model [void] A model instance.
|
182
|
+
# @macro raise_missing_required
|
184
183
|
# @return [Boolean]
|
185
184
|
def valid_model?(model)
|
186
185
|
fail Vedeu::Error::MissingRequired,
|
data/lib/vedeu/runtime/router.rb
CHANGED
@@ -18,8 +18,7 @@ module Vedeu
|
|
18
18
|
#
|
19
19
|
# @param controller [Symbol]
|
20
20
|
# @param klass [String]
|
21
|
-
# @
|
22
|
-
# name is not given.
|
21
|
+
# @macro raise_missing_required
|
23
22
|
# @return [void]
|
24
23
|
def add_controller(controller, klass)
|
25
24
|
unless present?(controller)
|
@@ -46,8 +45,7 @@ module Vedeu
|
|
46
45
|
#
|
47
46
|
# @param controller [Symbol]
|
48
47
|
# @param action [Symbol]
|
49
|
-
# @
|
50
|
-
# name or action name is not given.
|
48
|
+
# @macro raise_missing_required
|
51
49
|
# @return [void]
|
52
50
|
def add_action(controller, action)
|
53
51
|
if present?(controller) && present?(action)
|
@@ -143,8 +141,7 @@ module Vedeu
|
|
143
141
|
# Fetch the class for the controller by name.
|
144
142
|
#
|
145
143
|
# @param controller [Symbol]
|
146
|
-
# @
|
147
|
-
# controller name does not have a class defined.
|
144
|
+
# @macro raise_missing_required
|
148
145
|
# @return [String]
|
149
146
|
def klass_for(controller)
|
150
147
|
if registered?(controller) && klass_defined?(controller)
|
data/lib/vedeu/support/point.rb
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
+
# A `Vedeu::Point` represents part of a coordinate within the 2D
|
4
|
+
# space of a terminal. This class is specifically used to coerce
|
5
|
+
# a coordinate to be within boundaries. The `min` and `max`
|
6
|
+
# arguments are used to define this boundary.
|
7
|
+
#
|
8
|
+
# @api private
|
9
|
+
#
|
3
10
|
class Point
|
4
11
|
|
5
12
|
# @param (see #initialize)
|
13
|
+
# @macro raise_invalid_syntax
|
6
14
|
# @return (see #initialize)
|
7
15
|
def self.coerce(value: nil, min: 1, max: nil)
|
8
16
|
new(value: value, min: min, max: max).coerce
|
@@ -24,6 +32,7 @@ module Vedeu
|
|
24
32
|
@value = value
|
25
33
|
end
|
26
34
|
|
35
|
+
# @macro raise_invalid_syntax
|
27
36
|
# @return [Vedeu::Point]
|
28
37
|
def coerce
|
29
38
|
fail Vedeu::Error::InvalidSyntax,
|
@@ -53,6 +62,7 @@ module Vedeu
|
|
53
62
|
|
54
63
|
private
|
55
64
|
|
65
|
+
# @macro raise_invalid_syntax
|
56
66
|
# @return [Fixnum]
|
57
67
|
def min
|
58
68
|
return @min if @min.is_a?(Fixnum)
|
@@ -60,6 +70,7 @@ module Vedeu
|
|
60
70
|
fail Vedeu::Error::InvalidSyntax, "Expecting 'min' to be a Fixnum."
|
61
71
|
end
|
62
72
|
|
73
|
+
# @macro raise_invalid_syntax
|
63
74
|
# @return [Fixnum]
|
64
75
|
def max
|
65
76
|
return @max if @max.is_a?(Fixnum)
|
data/lib/vedeu/version.rb
CHANGED
data/lib/vedeu/views/chars.rb
CHANGED
@@ -13,8 +13,7 @@ module Vedeu
|
|
13
13
|
# @param collection [void]
|
14
14
|
# @param parent [Vedeu::Views::Stream]
|
15
15
|
# @param name [NilClass|Symbol|String]
|
16
|
-
# @
|
17
|
-
# cannot be coerced since it is unrecognised or unsupported.
|
16
|
+
# @macro raise_invalid_syntax
|
18
17
|
# @return [Vedeu::Views::Chars]
|
19
18
|
def self.coerce(collection = [], parent = nil, name = nil)
|
20
19
|
if collection.is_a?(Vedeu::Views::Chars)
|
data/lib/vedeu/views/lines.rb
CHANGED
@@ -11,8 +11,7 @@ module Vedeu
|
|
11
11
|
class Lines < Vedeu::Repositories::Collection
|
12
12
|
|
13
13
|
# @param (see Vedeu::Repositories::Collection#initialize)
|
14
|
-
# @
|
15
|
-
# cannot be coerced since it is unrecognised or unsupported.
|
14
|
+
# @macro raise_invalid_syntax
|
16
15
|
# @return [Vedeu::Views::Lines]
|
17
16
|
def self.coerce(collection = [], parent = nil, name = nil)
|
18
17
|
if collection.is_a?(Vedeu::Views::Lines)
|
data/lib/vedeu/views/streams.rb
CHANGED
@@ -11,8 +11,7 @@ module Vedeu
|
|
11
11
|
class Streams < Vedeu::Repositories::Collection
|
12
12
|
|
13
13
|
# @param (see Vedeu::Repositories::Collection#initialize)
|
14
|
-
# @
|
15
|
-
# cannot be coerced since it is unrecognised or unsupported.
|
14
|
+
# @macro raise_invalid_syntax
|
16
15
|
# @return [Vedeu::Views::Streams]
|
17
16
|
def self.coerce(collection = [], parent = nil, name = nil)
|
18
17
|
if collection.is_a?(Vedeu::Views::Streams)
|
data/lib/vedeu/views/view.rb
CHANGED
@@ -113,8 +113,7 @@ module Vedeu
|
|
113
113
|
#
|
114
114
|
# @param refresh [Boolean] Should the buffer of the view be
|
115
115
|
# refreshed once stored? Default: false.
|
116
|
-
# @
|
117
|
-
# view is not defined.
|
116
|
+
# @macro raise_missing_required
|
118
117
|
# @return [Vedeu::Views::View]
|
119
118
|
def update_buffer(refresh = false)
|
120
119
|
if present?(name)
|
@@ -90,8 +90,8 @@ module Vedeu
|
|
90
90
|
it { subject.first.must_be_instance_of(Array) }
|
91
91
|
it { subject.first.first.must_be_instance_of(Vedeu::Cells::Empty) }
|
92
92
|
|
93
|
-
it { subject.size.must_equal(height) }
|
94
|
-
it { subject.first.size.must_equal(width) }
|
93
|
+
it { subject.size.must_equal(height + 1) }
|
94
|
+
it { subject.first.size.must_equal(width + 1) }
|
95
95
|
it { subject.first.first.position.must_equal(position) }
|
96
96
|
end
|
97
97
|
|
@@ -123,6 +123,28 @@ module Vedeu
|
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
|
+
describe '#escape?' do
|
127
|
+
subject { instance.escape?(_value) }
|
128
|
+
|
129
|
+
context 'when the value is a Vedeu::Cells::Escape' do
|
130
|
+
let(:_value) { Vedeu::Cells::Escape.new(value: "\e[0m") }
|
131
|
+
|
132
|
+
it { subject.must_equal(true) }
|
133
|
+
end
|
134
|
+
|
135
|
+
context 'when the value is a Vedeu::Cells::Cursor' do
|
136
|
+
let(:_value) { Vedeu::Cells::Cursor.new(value: "\e[?25h") }
|
137
|
+
|
138
|
+
it { subject.must_equal(true) }
|
139
|
+
end
|
140
|
+
|
141
|
+
context 'when the value is anything else' do
|
142
|
+
let(:_value) { 'anything' }
|
143
|
+
|
144
|
+
it { subject.must_equal(false) }
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
126
148
|
describe '#falsy?' do
|
127
149
|
subject { instance.falsy?(_value) }
|
128
150
|
|
@@ -26,7 +26,7 @@ module Vedeu
|
|
26
26
|
end
|
27
27
|
|
28
28
|
context 'when the output is not empty' do
|
29
|
-
let(:output) { Vedeu::
|
29
|
+
let(:output) { Vedeu::Cells::Char.new(value: 'a') }
|
30
30
|
|
31
31
|
it do
|
32
32
|
Vedeu::Buffers::Terminal.expects(:write).with(output)
|
@@ -74,7 +74,7 @@ module Vedeu
|
|
74
74
|
end
|
75
75
|
|
76
76
|
context 'and the output is not an escape sequence' do
|
77
|
-
let(:output) { Vedeu::
|
77
|
+
let(:output) { Vedeu::Cells::Char.new(value: 'a') }
|
78
78
|
|
79
79
|
it do
|
80
80
|
Vedeu::Buffers::Terminal.expects(:write).with(output)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vedeu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Laking
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|