vedeu 0.4.1 → 0.4.2
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/lib/vedeu.rb +1 -1
- data/lib/vedeu/all.rb +2 -0
- data/lib/vedeu/buffers/buffer.rb +0 -11
- data/lib/vedeu/configuration/api.rb +4 -6
- data/lib/vedeu/configuration/cli.rb +1 -3
- data/lib/vedeu/configuration/configuration.rb +15 -0
- data/lib/vedeu/cursor/cursor.rb +2 -9
- data/lib/vedeu/cursor/move_cursor.rb +7 -9
- data/lib/vedeu/cursor/toggle_cursor.rb +2 -2
- data/lib/vedeu/debug.rb +3 -0
- data/lib/vedeu/distributed/test_application.rb +4 -8
- data/lib/vedeu/dsl/components/keymap.rb +1 -3
- data/lib/vedeu/dsl/composition.rb +2 -2
- data/lib/vedeu/dsl/interface.rb +2 -2
- data/lib/vedeu/dsl/shared/text.rb +2 -2
- data/lib/vedeu/events/event.rb +1 -1
- data/lib/vedeu/geometry/all.rb +10 -0
- data/lib/vedeu/{support → geometry}/bounding_area.rb +1 -0
- data/lib/vedeu/{support → geometry}/content_geometry.rb +0 -7
- data/lib/vedeu/{support → geometry}/coordinate.rb +0 -14
- data/lib/vedeu/{support → geometry}/grid.rb +0 -0
- data/lib/vedeu/{support → geometry}/limit.rb +0 -0
- data/lib/vedeu/{support → geometry}/position.rb +3 -5
- data/lib/vedeu/{support → geometry}/position_validator.rb +2 -0
- data/lib/vedeu/input/input.rb +1 -1
- data/lib/vedeu/input/key.rb +0 -13
- data/lib/vedeu/input/keymap.rb +1 -1
- data/lib/vedeu/models/focus.rb +2 -2
- data/lib/vedeu/models/geometry.rb +4 -51
- data/lib/vedeu/models/menu.rb +1 -1
- data/lib/vedeu/models/model.rb +1 -1
- data/lib/vedeu/models/view/char.rb +2 -9
- data/lib/vedeu/models/view/composition.rb +3 -10
- data/lib/vedeu/models/view/interface.rb +5 -13
- data/lib/vedeu/models/view/line.rb +3 -10
- data/lib/vedeu/models/view/stream.rb +18 -11
- data/lib/vedeu/output/background.rb +6 -21
- data/lib/vedeu/output/border.rb +26 -17
- data/lib/vedeu/output/colour.rb +1 -1
- data/lib/vedeu/output/foreground.rb +6 -21
- data/lib/vedeu/output/html_renderer.rb +3 -9
- data/lib/vedeu/output/output.rb +38 -11
- data/lib/vedeu/output/style.rb +1 -1
- data/lib/vedeu/output/translator.rb +45 -15
- data/lib/vedeu/output/viewport.rb +1 -1
- data/lib/vedeu/output/virtual_buffer.rb +2 -2
- data/lib/vedeu/output/wordwrap.rb +1 -1
- data/lib/vedeu/repositories/all.rb +9 -9
- data/lib/vedeu/repositories/repository.rb +0 -7
- data/lib/vedeu/support/all.rb +1 -7
- data/lib/vedeu/support/esc.rb +33 -11
- data/lib/vedeu/support/template.rb +39 -0
- data/lib/vedeu/support/terminal.rb +3 -3
- data/lib/vedeu/support/text.rb +1 -1
- data/lib/vedeu/support/trace.rb +4 -4
- data/lib/vedeu/support/visible.rb +2 -7
- data/test/lib/vedeu/buffers/buffer_test.rb +0 -6
- data/test/lib/vedeu/cursor/cursor_test.rb +0 -6
- data/test/lib/vedeu/{support → geometry}/bounding_area_test.rb +0 -0
- data/test/lib/vedeu/{support → geometry}/content_geometry_test.rb +0 -6
- data/test/lib/vedeu/{support → geometry}/coordinate_test.rb +0 -8
- data/test/lib/vedeu/{support → geometry}/grid_test.rb +0 -0
- data/test/lib/vedeu/{support → geometry}/limit_test.rb +0 -0
- data/test/lib/vedeu/{support → geometry}/position_test.rb +8 -6
- data/test/lib/vedeu/{support → geometry}/position_validator_test.rb +0 -0
- data/test/lib/vedeu/input/key_test.rb +0 -12
- data/test/lib/vedeu/models/geometry_test.rb +0 -47
- data/test/lib/vedeu/models/view/char_test.rb +5 -9
- data/test/lib/vedeu/models/view/composition_test.rb +2 -8
- data/test/lib/vedeu/models/view/interface_test.rb +2 -8
- data/test/lib/vedeu/models/view/line_test.rb +0 -6
- data/test/lib/vedeu/models/view/stream_test.rb +0 -6
- data/test/lib/vedeu/output/border_test.rb +2 -2
- data/test/lib/vedeu/output/html_renderer_test.rb +0 -1
- data/test/lib/vedeu/output/output_test.rb +39 -0
- data/test/lib/vedeu/repositories/repository_test.rb +0 -6
- data/test/lib/vedeu/support/template_test.rb +24 -0
- data/test/lib/vedeu/support/visible_test.rb +0 -6
- data/test/support/helpers/model_test_class.rb +1 -1
- data/vedeu.gemspec +1 -1
- metadata +27 -23
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
# Generic class to loading a template and parsing it via ERb.
|
6
|
+
#
|
7
|
+
class Template
|
8
|
+
|
9
|
+
# @param object [Class]
|
10
|
+
# @param path [String]
|
11
|
+
# @return [void]
|
12
|
+
def self.parse(object, path)
|
13
|
+
new(object, path).parse
|
14
|
+
end
|
15
|
+
|
16
|
+
# @param object [Class]
|
17
|
+
# @param path [String]
|
18
|
+
# @return [Template]
|
19
|
+
def initialize(object, path)
|
20
|
+
@object, @path = object, path
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [void]
|
24
|
+
def parse
|
25
|
+
ERB.new(load, nil, '-').result(binding)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
attr_reader :object, :path
|
31
|
+
|
32
|
+
# @return [String]
|
33
|
+
def load
|
34
|
+
File.read(path)
|
35
|
+
end
|
36
|
+
|
37
|
+
end # Template
|
38
|
+
|
39
|
+
end # Vedeu
|
@@ -135,7 +135,7 @@ module Vedeu
|
|
135
135
|
def cooked_mode!
|
136
136
|
Vedeu.log(type: :info, message: "Terminal switching to 'cooked' mode")
|
137
137
|
|
138
|
-
@
|
138
|
+
@mode = :cooked
|
139
139
|
end
|
140
140
|
|
141
141
|
# Returns a boolean indicating whether the terminal is currently in `raw`
|
@@ -152,7 +152,7 @@ module Vedeu
|
|
152
152
|
def raw_mode!
|
153
153
|
Vedeu.log(type: :info, message: "Terminal switching to 'raw' mode")
|
154
154
|
|
155
|
-
@
|
155
|
+
@mode = :raw
|
156
156
|
end
|
157
157
|
|
158
158
|
# Toggles the terminal's mode between `cooked` and `raw`, depending on its
|
@@ -169,7 +169,7 @@ module Vedeu
|
|
169
169
|
#
|
170
170
|
# @return [Symbol]
|
171
171
|
def mode
|
172
|
-
@
|
172
|
+
@mode ||= Configuration.terminal_mode
|
173
173
|
end
|
174
174
|
|
175
175
|
# Returns a coordinate tuple of the format [y, x], where `y` is the row/line
|
data/lib/vedeu/support/text.rb
CHANGED
data/lib/vedeu/support/trace.rb
CHANGED
@@ -114,7 +114,7 @@ module Vedeu
|
|
114
114
|
|
115
115
|
# @return [Hash]
|
116
116
|
def options
|
117
|
-
defaults.merge(@options)
|
117
|
+
defaults.merge!(@options)
|
118
118
|
end
|
119
119
|
|
120
120
|
# The default values for a new instance of this class.
|
@@ -143,21 +143,21 @@ module Vedeu
|
|
143
143
|
#
|
144
144
|
# @return [String]
|
145
145
|
def class_count
|
146
|
-
@
|
146
|
+
@count ||= "(#{classes.size}/#{vedeu_classes.size})"
|
147
147
|
end
|
148
148
|
|
149
149
|
# Returns the classes to be traced, without exceptions or ignored classes.
|
150
150
|
#
|
151
151
|
# @return [Set]
|
152
152
|
def classes
|
153
|
-
@
|
153
|
+
@classes ||= vedeu_classes - vedeu_exceptions - ignored_classes
|
154
154
|
end
|
155
155
|
|
156
156
|
# Returns all the classes defined within Vedeu.
|
157
157
|
#
|
158
158
|
# @return [Set]
|
159
159
|
def vedeu_classes
|
160
|
-
@
|
160
|
+
@vedeu_classes ||= Vedeu.constants.collect do |c|
|
161
161
|
Vedeu.const_get(c).to_s
|
162
162
|
end.to_set
|
163
163
|
end
|
@@ -6,6 +6,7 @@ module Vedeu
|
|
6
6
|
#
|
7
7
|
class Visible
|
8
8
|
|
9
|
+
# @param visible [Boolean|Symbol]
|
9
10
|
# @return [Visible]
|
10
11
|
def self.coerce(value)
|
11
12
|
if value.is_a?(self)
|
@@ -17,6 +18,7 @@ module Vedeu
|
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
21
|
+
# @param visible [Boolean|Symbol]
|
20
22
|
# @return [Visible]
|
21
23
|
def initialize(visible = nil)
|
22
24
|
@visible = if visible == :hide || visible == false
|
@@ -31,13 +33,6 @@ module Vedeu
|
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
34
|
-
# Returns log friendly output.
|
35
|
-
#
|
36
|
-
# @return [String]
|
37
|
-
def inspect
|
38
|
-
"<#{self.class.name} (#{@visible.to_s})>"
|
39
|
-
end
|
40
|
-
|
41
36
|
# @return [String]
|
42
37
|
def cursor
|
43
38
|
if visible?
|
@@ -23,12 +23,6 @@ module Vedeu
|
|
23
23
|
it { instance.instance_variable_get('@repository').must_equal(Vedeu.buffers) }
|
24
24
|
end
|
25
25
|
|
26
|
-
describe '#inspect' do
|
27
|
-
subject { instance.inspect }
|
28
|
-
|
29
|
-
it { subject.must_equal('<Vedeu::Buffer ( back?:false front?:false previous?:false )>') }
|
30
|
-
end
|
31
|
-
|
32
26
|
describe '#add' do
|
33
27
|
let(:back) {
|
34
28
|
Vedeu.interface 'buffer' do
|
@@ -39,12 +39,6 @@ module Vedeu
|
|
39
39
|
it { instance.instance_variable_get('@position').must_be_instance_of(Vedeu::Position) }
|
40
40
|
end
|
41
41
|
|
42
|
-
describe '#inspect' do
|
43
|
-
subject { instance.inspect }
|
44
|
-
|
45
|
-
it { subject.must_equal('<Vedeu::Cursor (silver: x:19 y:8 ox:3 oy:2)>') }
|
46
|
-
end
|
47
|
-
|
48
42
|
describe '#to_s' do
|
49
43
|
let(:state) { true }
|
50
44
|
|
File without changes
|
@@ -26,12 +26,6 @@ module Vedeu
|
|
26
26
|
it { instance.instance_variable_get('@interface').must_equal(interface) }
|
27
27
|
end
|
28
28
|
|
29
|
-
describe '#inspect' do
|
30
|
-
subject { instance.inspect }
|
31
|
-
|
32
|
-
it { subject.must_equal('<Vedeu::ContentGeometry (y:1 x:1 yn:3 xn:5)>') }
|
33
|
-
end
|
34
|
-
|
35
29
|
describe '#yn' do
|
36
30
|
subject { instance.yn }
|
37
31
|
|
@@ -19,14 +19,6 @@ module Vedeu
|
|
19
19
|
it { instance.instance_variable_get('@y').must_equal(y) }
|
20
20
|
end
|
21
21
|
|
22
|
-
describe '#inspect' do
|
23
|
-
subject { instance.inspect }
|
24
|
-
|
25
|
-
it { subject.must_equal(
|
26
|
-
'<Vedeu::Coordinate ( height:6 width:6 x:7 xn:13 y:5 yn:11 )>'
|
27
|
-
) }
|
28
|
-
end
|
29
|
-
|
30
22
|
describe '#yn' do
|
31
23
|
subject { instance.yn }
|
32
24
|
|
File without changes
|
File without changes
|
@@ -34,17 +34,19 @@ module Vedeu
|
|
34
34
|
it { subject.x.must_equal(8) }
|
35
35
|
end
|
36
36
|
|
37
|
+
context 'when the value is a Hash' do
|
38
|
+
let(:value) { { y: 3, x: 9 } }
|
39
|
+
|
40
|
+
it { subject.must_be_instance_of(described) }
|
41
|
+
it { subject.y.must_equal(3) }
|
42
|
+
it { subject.x.must_equal(9) }
|
43
|
+
end
|
44
|
+
|
37
45
|
context 'when the value is something unhandled' do
|
38
46
|
it { subject.must_be_instance_of(NilClass) }
|
39
47
|
end
|
40
48
|
end
|
41
49
|
|
42
|
-
describe '#inspect' do
|
43
|
-
subject { instance.inspect }
|
44
|
-
|
45
|
-
it { subject.must_equal("<Vedeu::Position (y:12 x:19)>") }
|
46
|
-
end
|
47
|
-
|
48
50
|
describe '#==' do
|
49
51
|
let(:other) {}
|
50
52
|
|
File without changes
|
@@ -8,18 +8,6 @@ module Vedeu
|
|
8
8
|
let(:instance) { described.new(input) { :output } }
|
9
9
|
let(:input) { 'a' }
|
10
10
|
|
11
|
-
describe '.build' do
|
12
|
-
subject { described.build(input) { :output } }
|
13
|
-
|
14
|
-
it { subject.must_be_instance_of(Key) }
|
15
|
-
|
16
|
-
context 'when the required block is not given' do
|
17
|
-
subject { described.build(input) }
|
18
|
-
|
19
|
-
it { proc { subject }.must_raise(InvalidSyntax) }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
11
|
describe '#initialize' do
|
24
12
|
it { instance.must_be_instance_of(Key) }
|
25
13
|
it { instance.instance_variable_get('@input').must_equal(input) }
|
@@ -40,14 +40,6 @@ module Vedeu
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
describe '#inspect' do
|
44
|
-
subject { instance.inspect }
|
45
|
-
|
46
|
-
it { subject.must_equal(
|
47
|
-
'<Vedeu::Geometry (height:(25/24) width:(80/79) top:1 bottom:25 left:1 right:80)>'
|
48
|
-
) }
|
49
|
-
end
|
50
|
-
|
51
43
|
describe '#y' do
|
52
44
|
subject { instance.y }
|
53
45
|
|
@@ -148,45 +140,6 @@ module Vedeu
|
|
148
140
|
end
|
149
141
|
end
|
150
142
|
|
151
|
-
describe '#origin' do
|
152
|
-
it 'returns the origin for the interface' do
|
153
|
-
geometry = Geometry.new({ width: 5, height: 5 })
|
154
|
-
geometry.origin.must_be_instance_of(Vedeu::Position)
|
155
|
-
geometry.origin.y.must_equal(1)
|
156
|
-
geometry.origin.x.must_equal(1)
|
157
|
-
end
|
158
|
-
|
159
|
-
it 'returns the origin for the interface' do
|
160
|
-
geometry = Geometry.new({ width: 5, height: 5, centred: true })
|
161
|
-
geometry.origin.must_be_instance_of(Vedeu::Position)
|
162
|
-
geometry.origin.y.must_equal(10)
|
163
|
-
geometry.origin.x.must_equal(38)
|
164
|
-
end
|
165
|
-
|
166
|
-
it 'returns the line position relative to the origin' do
|
167
|
-
geometry = Geometry.new({ width: 5, height: 5 })
|
168
|
-
geometry.origin(3).must_be_instance_of(Vedeu::Position)
|
169
|
-
geometry.origin(3).y.must_equal(4)
|
170
|
-
geometry.origin(3).x.must_equal(1)
|
171
|
-
end
|
172
|
-
|
173
|
-
it 'returns the origin for the interface when the interface' \
|
174
|
-
' is at a custom position' do
|
175
|
-
geometry = Geometry.new({ width: 5, height: 5, x: 3, y: 6 })
|
176
|
-
geometry.origin.must_be_instance_of(Vedeu::Position)
|
177
|
-
geometry.origin.y.must_equal(6)
|
178
|
-
geometry.origin.x.must_equal(3)
|
179
|
-
end
|
180
|
-
|
181
|
-
it 'returns the line position relative to the origin when the' \
|
182
|
-
' interface is at a custom position' do
|
183
|
-
geometry = Geometry.new({ width: 5, height: 5, x: 3, y: 6 })
|
184
|
-
geometry.origin(3).must_be_instance_of(Vedeu::Position)
|
185
|
-
geometry.origin(3).y.must_equal(9)
|
186
|
-
geometry.origin(3).x.must_equal(3)
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
143
|
describe '#top' do
|
191
144
|
it 'centred is true' do
|
192
145
|
console = IO.console
|
@@ -33,19 +33,13 @@ module Vedeu
|
|
33
33
|
|
34
34
|
describe '#initialize' do
|
35
35
|
it { instance.must_be_instance_of(Char) }
|
36
|
-
it { instance.instance_variable_get('@colour').
|
36
|
+
it { instance.instance_variable_get('@colour').must_equal(colour) }
|
37
37
|
it { instance.instance_variable_get('@parent').must_equal(parent) }
|
38
38
|
it { instance.instance_variable_get('@style').must_equal(style) }
|
39
39
|
it { instance.instance_variable_get('@value').must_equal(value) }
|
40
40
|
it { instance.instance_variable_get('@position').must_equal(position) }
|
41
41
|
end
|
42
42
|
|
43
|
-
describe '#inspect' do
|
44
|
-
subject { instance.inspect }
|
45
|
-
|
46
|
-
it { subject.must_equal("<Vedeu::Char (value:'a')>") }
|
47
|
-
end
|
48
|
-
|
49
43
|
describe '#value' do
|
50
44
|
subject { instance.value }
|
51
45
|
|
@@ -84,10 +78,12 @@ module Vedeu
|
|
84
78
|
end
|
85
79
|
|
86
80
|
context 'when a colour is specified' do
|
87
|
-
let(:colour) { Colour.new({ foreground: '#00ff00',
|
81
|
+
let(:colour) { Colour.new({ foreground: '#00ff00',
|
82
|
+
background: '#005500' }) }
|
88
83
|
|
89
84
|
context 'when a parent colour is specified' do
|
90
|
-
let(:parent_colour) { Colour.new({ foreground: '#ff0000',
|
85
|
+
let(:parent_colour) { Colour.new({ foreground: '#ff0000',
|
86
|
+
background: '#550000' }) }
|
91
87
|
|
92
88
|
it { subject.must_equal("\e[38;2;0;255;0m\e[48;2;0;85;0ma\e[38;2;255;0;0m\e[48;2;85;0;0m") }
|
93
89
|
end
|
@@ -30,14 +30,8 @@ module Vedeu
|
|
30
30
|
describe '#initialize' do
|
31
31
|
it { instance.must_be_instance_of(described) }
|
32
32
|
it { instance.instance_variable_get('@interfaces').must_equal(interfaces) }
|
33
|
-
it { instance.instance_variable_get('@colour').
|
34
|
-
it { instance.instance_variable_get('@style').
|
35
|
-
end
|
36
|
-
|
37
|
-
describe '#inspect' do
|
38
|
-
subject { instance.inspect }
|
39
|
-
|
40
|
-
it { subject.must_equal('<Vedeu::Composition (interfaces:0)>') }
|
33
|
+
it { instance.instance_variable_get('@colour').must_equal(colour) }
|
34
|
+
it { instance.instance_variable_get('@style').must_equal(style) }
|
41
35
|
end
|
42
36
|
|
43
37
|
end # Composition
|
@@ -25,8 +25,8 @@ module Vedeu
|
|
25
25
|
it { instance.instance_variable_get('@name').must_equal(_name) }
|
26
26
|
it { instance.instance_variable_get('@lines').must_equal(lines) }
|
27
27
|
it { instance.instance_variable_get('@parent').must_equal(parent) }
|
28
|
-
it { instance.instance_variable_get('@colour').
|
29
|
-
it { instance.instance_variable_get('@style').
|
28
|
+
it { instance.instance_variable_get('@colour').must_equal(colour) }
|
29
|
+
it { instance.instance_variable_get('@style').must_equal(style) }
|
30
30
|
it { instance.instance_variable_get('@border').must_equal(nil) }
|
31
31
|
it { instance.instance_variable_get('@delay').must_equal(0.0) }
|
32
32
|
it { instance.instance_variable_get('@geometry').must_equal(nil) }
|
@@ -68,12 +68,6 @@ module Vedeu
|
|
68
68
|
it { subject.must_be_instance_of(Vedeu::Cursor) }
|
69
69
|
end
|
70
70
|
|
71
|
-
describe '#inspect' do
|
72
|
-
subject { instance.inspect }
|
73
|
-
|
74
|
-
it { subject.must_equal('<Vedeu::Interface (lines:0)>') }
|
75
|
-
end
|
76
|
-
|
77
71
|
describe '#store' do
|
78
72
|
subject { instance.store }
|
79
73
|
|
@@ -62,10 +62,10 @@ module Vedeu
|
|
62
62
|
vertical: 'x',
|
63
63
|
})
|
64
64
|
}
|
65
|
-
it { instance.instance_variable_get('@colour').
|
65
|
+
it { instance.instance_variable_get('@colour').must_equal({}) }
|
66
66
|
it { instance.instance_variable_get('@name').must_equal('borders') }
|
67
67
|
it { instance.instance_variable_get('@repository').must_be_instance_of(Vedeu::Borders) }
|
68
|
-
it { instance.instance_variable_get('@style').
|
68
|
+
it { instance.instance_variable_get('@style').must_equal([]) }
|
69
69
|
end
|
70
70
|
|
71
71
|
describe '#width' do
|
@@ -11,7 +11,6 @@ module Vedeu
|
|
11
11
|
describe '#initialize' do
|
12
12
|
it { instance.must_be_instance_of(Vedeu::HTMLRenderer) }
|
13
13
|
it { instance.instance_variable_get('@output').must_equal(output) }
|
14
|
-
it { instance.instance_variable_get('@object').must_be_instance_of(Vedeu::HTMLRenderer) }
|
15
14
|
end
|
16
15
|
|
17
16
|
describe '#render' do
|