vedeu 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/Rakefile +6 -0
- data/bin/vedeu_drb_client +8 -3
- data/bin/vedeu_drb_server +113 -0
- data/bin/vedeu_test +1 -1
- data/docs/events.md +0 -127
- data/examples/borders_app.rb +17 -7
- data/examples/configuration_app.rb +1 -1
- data/examples/cursor_app.rb +4 -2
- data/examples/drb_app.rb +113 -0
- data/examples/focus_app.rb +1 -1
- data/examples/geometry_app.rb +1 -1
- data/examples/hello_world.rb +1 -1
- data/examples/lines_app.rb +1 -1
- data/features/start_stop.feature +1 -1
- data/inch.yml +5 -0
- data/lib/vedeu/all.rb +2 -0
- data/lib/vedeu/api.rb +1 -0
- data/lib/vedeu/application.rb +17 -36
- data/lib/vedeu/bindings.rb +134 -27
- data/lib/vedeu/buffers/display_buffer.rb +1 -4
- data/lib/vedeu/configuration/api.rb +15 -14
- data/lib/vedeu/configuration/cli.rb +17 -16
- data/lib/vedeu/configuration/configuration.rb +3 -1
- data/lib/vedeu/cursor/cursor.rb +6 -8
- data/lib/vedeu/cursor/move_cursor.rb +1 -0
- data/lib/vedeu/cursor/toggle_cursor.rb +1 -0
- data/lib/vedeu/debug.rb +23 -0
- data/lib/vedeu/distributed/all.rb +1 -1
- data/lib/vedeu/distributed/client.rb +55 -13
- data/lib/vedeu/distributed/server.rb +207 -0
- data/lib/vedeu/distributed/subprocess.rb +22 -21
- data/lib/vedeu/distributed/templates/default_application.vedeu +3 -1
- data/lib/vedeu/distributed/test_application.rb +2 -1
- data/lib/vedeu/distributed/uri.rb +1 -0
- data/lib/vedeu/dsl/all.rb +4 -2
- data/lib/vedeu/dsl/components/border.rb +11 -10
- data/lib/vedeu/dsl/components/geometry.rb +1 -0
- data/lib/vedeu/dsl/components/keymap.rb +1 -0
- data/lib/vedeu/dsl/components/menu.rb +1 -0
- data/lib/vedeu/dsl/interface.rb +1 -0
- data/lib/vedeu/dsl/line.rb +3 -1
- data/lib/vedeu/dsl/shared/colour.rb +1 -0
- data/lib/vedeu/dsl/shared/style.rb +1 -0
- data/lib/vedeu/dsl/shared/text.rb +2 -0
- data/lib/vedeu/dsl/shared/use.rb +3 -0
- data/lib/vedeu/dsl/stream.rb +3 -1
- data/lib/vedeu/dsl/view.rb +1 -0
- data/lib/vedeu/events/event.rb +9 -6
- data/lib/vedeu/events/trigger.rb +18 -7
- data/lib/vedeu/exceptions.rb +4 -1
- data/lib/vedeu/input/input.rb +1 -0
- data/lib/vedeu/input/key.rb +0 -1
- data/lib/vedeu/input/keymap.rb +5 -3
- data/lib/vedeu/input/keys.rb +1 -0
- data/lib/vedeu/input/mapper.rb +1 -0
- data/lib/vedeu/launcher.rb +35 -12
- data/lib/vedeu/main_loop.rb +53 -0
- data/lib/vedeu/models/collection.rb +11 -3
- data/lib/vedeu/models/focus.rb +3 -3
- data/lib/vedeu/models/geometry.rb +8 -16
- data/lib/vedeu/models/group.rb +1 -0
- data/lib/vedeu/models/menu.rb +2 -1
- data/lib/vedeu/models/model.rb +7 -1
- data/lib/vedeu/models/view/char.rb +52 -44
- data/lib/vedeu/models/view/chars.rb +1 -0
- data/lib/vedeu/models/view/composition.rb +2 -1
- data/lib/vedeu/models/view/interface.rb +5 -3
- data/lib/vedeu/models/view/interfaces.rb +1 -0
- data/lib/vedeu/models/view/line.rb +2 -1
- data/lib/vedeu/models/view/stream.rb +2 -1
- data/lib/vedeu/models/view/streams.rb +1 -0
- data/lib/vedeu/output/all.rb +4 -0
- data/lib/vedeu/output/border.rb +75 -206
- data/lib/vedeu/output/compositor.rb +1 -0
- data/lib/vedeu/output/html_char.rb +119 -0
- data/lib/vedeu/output/html_renderer.rb +89 -0
- data/lib/vedeu/output/output.rb +48 -44
- data/lib/vedeu/output/position_index.rb +12 -1
- data/lib/vedeu/output/renderer.rb +28 -0
- data/lib/vedeu/output/viewport.rb +14 -14
- data/lib/vedeu/output/virtual_buffer.rb +56 -0
- data/lib/vedeu/output/virtual_terminal.rb +42 -34
- data/lib/vedeu/output/wordwrap.rb +3 -0
- data/lib/vedeu/output/writer.rb +13 -1
- data/lib/vedeu/presentation/background.rb +1 -0
- data/lib/vedeu/presentation/colour.rb +8 -7
- data/lib/vedeu/presentation/foreground.rb +1 -0
- data/lib/vedeu/presentation/presentation.rb +43 -7
- data/lib/vedeu/presentation/translator.rb +12 -0
- data/lib/vedeu/repositories/repository.rb +8 -8
- data/lib/vedeu/support/bounding_area.rb +2 -0
- data/lib/vedeu/support/coercions.rb +2 -1
- data/lib/vedeu/support/common.rb +1 -0
- data/lib/vedeu/support/console.rb +17 -23
- data/lib/vedeu/support/content_geometry.rb +2 -0
- data/lib/vedeu/support/coordinate.rb +1 -0
- data/lib/vedeu/support/esc.rb +58 -29
- data/lib/vedeu/support/grid.rb +1 -0
- data/lib/vedeu/support/limit.rb +9 -0
- data/lib/vedeu/support/log.rb +31 -9
- data/lib/vedeu/support/node.rb +8 -18
- data/lib/vedeu/support/position.rb +13 -34
- data/lib/vedeu/support/position_validator.rb +3 -0
- data/lib/vedeu/support/read.rb +1 -0
- data/lib/vedeu/support/refresh.rb +3 -2
- data/lib/vedeu/support/terminal.rb +11 -5
- data/lib/vedeu/support/trace.rb +16 -1
- data/lib/vedeu/support/visible.rb +2 -0
- data/lib/vedeu/support/write.rb +1 -0
- data/lib/vedeu/traps.rb +1 -0
- data/lib/vedeu.rb +2 -0
- data/test/integration/distributed_test.rb +10 -8
- data/test/lib/vedeu/api_test.rb +3 -7
- data/test/lib/vedeu/application_test.rb +2 -5
- data/test/lib/vedeu/configuration/api_test.rb +12 -0
- data/test/lib/vedeu/cursor/cursor_test.rb +2 -0
- data/test/lib/vedeu/distributed/client_test.rb +17 -7
- data/test/lib/vedeu/distributed/server_test.rb +56 -0
- data/test/lib/vedeu/distributed/test_application_test.rb +7 -3
- data/test/lib/vedeu/dsl/components/border_test.rb +10 -2
- data/test/lib/vedeu/dsl/interface_test.rb +6 -0
- data/test/lib/vedeu/dsl/line_test.rb +19 -0
- data/test/lib/vedeu/dsl/shared/colour_test.rb +4 -26
- data/test/lib/vedeu/dsl/shared/text_test.rb +8 -1
- data/test/lib/vedeu/dsl/stream_test.rb +13 -1
- data/test/lib/vedeu/input/input_test.rb +1 -1
- data/test/lib/vedeu/input/key_test.rb +3 -16
- data/test/lib/vedeu/launcher_test.rb +11 -1
- data/test/lib/vedeu/main_loop_test.rb +41 -0
- data/test/lib/vedeu/models/geometry_test.rb +15 -34
- data/test/lib/vedeu/models/view/char_test.rb +44 -45
- data/test/lib/vedeu/models/view/interface_test.rb +6 -0
- data/test/lib/vedeu/models/view/line_test.rb +1 -1
- data/test/lib/vedeu/models/view/stream_test.rb +1 -1
- data/test/lib/vedeu/output/border_test.rb +6 -5
- data/test/lib/vedeu/output/compositor_test.rb +2 -20
- data/test/lib/vedeu/output/html_char_test.rb +85 -0
- data/test/lib/vedeu/output/html_renderer_test.rb +37 -0
- data/test/lib/vedeu/output/position_index_test.rb +2 -10
- data/test/lib/vedeu/output/renderer_test.rb +24 -0
- data/test/lib/vedeu/output/virtual_buffer_test.rb +53 -0
- data/test/lib/vedeu/output/virtual_terminal_test.rb +32 -2
- data/test/lib/vedeu/presentation/background_test.rb +41 -1
- data/test/lib/vedeu/presentation/colour_test.rb +10 -6
- data/test/lib/vedeu/presentation/foreground_test.rb +46 -6
- data/test/lib/vedeu/presentation/presentation_test.rb +44 -1
- data/test/lib/vedeu/presentation/translator_test.rb +34 -0
- data/test/lib/vedeu/repositories/repository_test.rb +1 -1
- data/test/lib/vedeu/support/bounding_area_test.rb +4 -12
- data/test/lib/vedeu/support/console_test.rb +9 -50
- data/test/lib/vedeu/support/esc_test.rb +7 -7
- data/test/lib/vedeu/support/position_test.rb +42 -0
- data/test/lib/vedeu/support/terminal_test.rb +5 -20
- data/test/lib/vedeu/support/write_test.rb +42 -18
- data/test/support/helpers/all.rb +0 -1
- data/test/support/helpers/repository_test_module.rb +1 -0
- data/test/test_helper.rb +5 -2
- data/vedeu.gemspec +7 -5
- metadata +60 -14
- data/lib/vedeu/distributed/application.rb +0 -91
- data/test/lib/vedeu/distributed/application_test.rb +0 -24
- data/test/support/helpers/presentation.rb +0 -16
@@ -6,7 +6,14 @@ module Vedeu
|
|
6
6
|
|
7
7
|
describe Text do
|
8
8
|
|
9
|
-
|
9
|
+
describe '#text' do
|
10
|
+
|
11
|
+
# it { described.must_respond_to(:align) }
|
12
|
+
# it { described.must_respond_to(:center) }
|
13
|
+
# it { described.must_respond_to(:centre) }
|
14
|
+
# it { described.must_respond_to(:left) }
|
15
|
+
# it { described.must_respond_to(:right) }
|
16
|
+
end
|
10
17
|
|
11
18
|
end # Text
|
12
19
|
|
@@ -8,7 +8,7 @@ module Vedeu
|
|
8
8
|
|
9
9
|
let(:described) { Vedeu::DSL::Stream }
|
10
10
|
let(:instance) { described.new(model) }
|
11
|
-
let(:model) {
|
11
|
+
let(:model) { Vedeu::Stream.new }
|
12
12
|
let(:client) {}
|
13
13
|
|
14
14
|
describe '#initialize' do
|
@@ -17,6 +17,18 @@ module Vedeu
|
|
17
17
|
it { instance.instance_variable_get('@client').must_equal(client) }
|
18
18
|
end
|
19
19
|
|
20
|
+
describe '#stream' do
|
21
|
+
subject { instance.stream { } }
|
22
|
+
|
23
|
+
# it { subject.must_be_instance_of(Vedeu::Stream) }
|
24
|
+
|
25
|
+
context 'when the block is not given' do
|
26
|
+
subject { instance.stream }
|
27
|
+
|
28
|
+
it { proc { subject }.must_raise(InvalidSyntax) }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
20
32
|
end # Stream
|
21
33
|
|
22
34
|
end # DSL
|
@@ -38,11 +38,7 @@ module Vedeu
|
|
38
38
|
subject.must_equal('a')
|
39
39
|
end
|
40
40
|
|
41
|
-
|
42
|
-
subject { instance.key }
|
43
|
-
|
44
|
-
it { subject.must_equal('a') }
|
45
|
-
end
|
41
|
+
it { instance.must_respond_to(:key) }
|
46
42
|
end
|
47
43
|
|
48
44
|
describe '#output' do
|
@@ -52,17 +48,8 @@ module Vedeu
|
|
52
48
|
subject.must_equal(:output)
|
53
49
|
end
|
54
50
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
it { subject.must_equal(:output) }
|
59
|
-
end
|
60
|
-
|
61
|
-
context 'alias method #press' do
|
62
|
-
subject { instance.press }
|
63
|
-
|
64
|
-
it { subject.must_equal(:output) }
|
65
|
-
end
|
51
|
+
it { instance.must_respond_to(:action) }
|
52
|
+
it { instance.must_respond_to(:press) }
|
66
53
|
end
|
67
54
|
|
68
55
|
end # Key
|
@@ -24,6 +24,16 @@ module Vedeu
|
|
24
24
|
it { instance.instance_variable_get('@exit_code').must_equal(1) }
|
25
25
|
end
|
26
26
|
|
27
|
+
describe '#debug_execute!' do
|
28
|
+
subject { instance.debug_execute! }
|
29
|
+
|
30
|
+
context 'when debugging is enabled in the configuration' do
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when debugging is not enabled in the configuration' do
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
27
37
|
describe '#execute!' do
|
28
38
|
subject { instance.execute! }
|
29
39
|
|
@@ -38,7 +48,7 @@ module Vedeu
|
|
38
48
|
|
39
49
|
# it 'displays the exception' do
|
40
50
|
# capture_io do
|
41
|
-
# Launcher.
|
51
|
+
# Launcher.execute!
|
42
52
|
# end.must_equal(["", ""])
|
43
53
|
# end
|
44
54
|
# end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe MainLoop do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::MainLoop }
|
8
|
+
|
9
|
+
describe '.start!' do
|
10
|
+
before do
|
11
|
+
# subject.expects(:while).yields do
|
12
|
+
# String.expects(:new).returns("samantha")
|
13
|
+
# end
|
14
|
+
end
|
15
|
+
|
16
|
+
subject { described.start! { } }
|
17
|
+
|
18
|
+
# it { subject; described.instance_variable_get('@started').must_equal(true) }
|
19
|
+
# it { subject; described.instance_variable_get('@loop').must_equal(true) }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '.stop!' do
|
23
|
+
subject { described.stop! }
|
24
|
+
|
25
|
+
it { subject; described.instance_variable_get('@loop').must_equal(false) }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '.safe_exit_point!' do
|
29
|
+
subject { described.safe_exit_point! }
|
30
|
+
|
31
|
+
context 'when we wish to continue' do
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when we wish to stop' do
|
35
|
+
# it { proc { subject }.must_raise(VedeuInterrupt) }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end # MainLoop
|
40
|
+
|
41
|
+
end # Vedeu
|
@@ -143,58 +143,39 @@ module Vedeu
|
|
143
143
|
describe '#origin' do
|
144
144
|
it 'returns the origin for the interface' do
|
145
145
|
geometry = Geometry.new({ width: 5, height: 5 })
|
146
|
-
geometry.origin.
|
146
|
+
geometry.origin.must_be_instance_of(Vedeu::Position)
|
147
|
+
geometry.origin.y.must_equal(1)
|
148
|
+
geometry.origin.x.must_equal(1)
|
147
149
|
end
|
148
150
|
|
149
151
|
it 'returns the origin for the interface' do
|
150
152
|
geometry = Geometry.new({ width: 5, height: 5, centred: true })
|
151
|
-
geometry.origin.
|
153
|
+
geometry.origin.must_be_instance_of(Vedeu::Position)
|
154
|
+
geometry.origin.y.must_equal(10)
|
155
|
+
geometry.origin.x.must_equal(38)
|
152
156
|
end
|
153
157
|
|
154
158
|
it 'returns the line position relative to the origin' do
|
155
159
|
geometry = Geometry.new({ width: 5, height: 5 })
|
156
|
-
geometry.origin(3).
|
160
|
+
geometry.origin(3).must_be_instance_of(Vedeu::Position)
|
161
|
+
geometry.origin(3).y.must_equal(4)
|
162
|
+
geometry.origin(3).x.must_equal(1)
|
157
163
|
end
|
158
164
|
|
159
165
|
it 'returns the origin for the interface when the interface' \
|
160
166
|
' is at a custom position' do
|
161
167
|
geometry = Geometry.new({ width: 5, height: 5, x: 3, y: 6 })
|
162
|
-
geometry.origin.
|
168
|
+
geometry.origin.must_be_instance_of(Vedeu::Position)
|
169
|
+
geometry.origin.y.must_equal(6)
|
170
|
+
geometry.origin.x.must_equal(3)
|
163
171
|
end
|
164
172
|
|
165
173
|
it 'returns the line position relative to the origin when the' \
|
166
174
|
' interface is at a custom position' do
|
167
175
|
geometry = Geometry.new({ width: 5, height: 5, x: 3, y: 6 })
|
168
|
-
geometry.origin(3).
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
describe '#raw_origin' do
|
173
|
-
it 'returns the origin for the interface' do
|
174
|
-
geometry = Geometry.new({ width: 5, height: 5 })
|
175
|
-
geometry.raw_origin.must_equal([1, 1])
|
176
|
-
end
|
177
|
-
|
178
|
-
it 'returns the origin for the interface' do
|
179
|
-
geometry = Geometry.new({ width: 5, height: 5, centred: true })
|
180
|
-
geometry.raw_origin.must_equal([10, 38])
|
181
|
-
end
|
182
|
-
|
183
|
-
it 'returns the line position relative to the origin' do
|
184
|
-
geometry = Geometry.new({ width: 5, height: 5 })
|
185
|
-
geometry.raw_origin(3).must_equal([4, 1])
|
186
|
-
end
|
187
|
-
|
188
|
-
it 'returns the origin for the interface when the interface' \
|
189
|
-
' is at a custom position' do
|
190
|
-
geometry = Geometry.new({ width: 5, height: 5, x: 3, y: 6 })
|
191
|
-
geometry.raw_origin.must_equal([6, 3])
|
192
|
-
end
|
193
|
-
|
194
|
-
it 'returns the line position relative to the origin when the' \
|
195
|
-
' interface is at a custom position' do
|
196
|
-
geometry = Geometry.new({ width: 5, height: 5, x: 3, y: 6 })
|
197
|
-
geometry.raw_origin(3).must_equal([9, 3])
|
176
|
+
geometry.origin(3).must_be_instance_of(Vedeu::Position)
|
177
|
+
geometry.origin(3).y.must_equal(9)
|
178
|
+
geometry.origin(3).x.must_equal(3)
|
198
179
|
end
|
199
180
|
end
|
200
181
|
|
@@ -5,7 +5,16 @@ module Vedeu
|
|
5
5
|
describe Char do
|
6
6
|
|
7
7
|
let(:described) { Vedeu::Char }
|
8
|
-
let(:instance) { described.new(
|
8
|
+
let(:instance) { described.new(attributes) }
|
9
|
+
let(:attributes) {
|
10
|
+
{
|
11
|
+
colour: colour,
|
12
|
+
parent: parent,
|
13
|
+
position: position,
|
14
|
+
style: style,
|
15
|
+
value: value,
|
16
|
+
}
|
17
|
+
}
|
9
18
|
let(:value) { 'a' }
|
10
19
|
let(:parent) { Line.new(parent_attributes) }
|
11
20
|
let(:parent_attributes) {
|
@@ -22,42 +31,6 @@ module Vedeu
|
|
22
31
|
let(:parent_colour) { nil }
|
23
32
|
let(:parent_style) { nil }
|
24
33
|
|
25
|
-
describe '.coerce' do
|
26
|
-
subject { described.coerce(value, parent, colour, style, position) }
|
27
|
-
|
28
|
-
context 'when the value is already a Char' do
|
29
|
-
let(:value) { described.new('b') }
|
30
|
-
|
31
|
-
it { subject.must_equal(value) }
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'when the value is an Array' do
|
35
|
-
context 'and the Array contains instances of Char' do
|
36
|
-
let(:value) { [described.new('b')] }
|
37
|
-
|
38
|
-
it { subject.must_equal(value) }
|
39
|
-
end
|
40
|
-
|
41
|
-
context 'and the Array contains instances of String' do
|
42
|
-
let(:value) { ['carbon'] }
|
43
|
-
|
44
|
-
it { subject.must_be_instance_of(Array) }
|
45
|
-
end
|
46
|
-
|
47
|
-
context 'and the Array contains instances of NilClass' do
|
48
|
-
let(:value) { [] }
|
49
|
-
|
50
|
-
it { subject.must_be_instance_of(NilClass) }
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context 'when the value is not a Char or Array' do
|
55
|
-
let(:value) { {} }
|
56
|
-
|
57
|
-
it { subject.must_be_instance_of(NilClass) }
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
34
|
describe '#initialize' do
|
62
35
|
it { instance.must_be_instance_of(Char) }
|
63
36
|
it { instance.instance_variable_get('@colour').must_be_instance_of(Vedeu::Colour) }
|
@@ -84,13 +57,13 @@ module Vedeu
|
|
84
57
|
|
85
58
|
context 'when the value is set' do
|
86
59
|
it { subject.must_equal('a') }
|
60
|
+
end
|
61
|
+
end
|
87
62
|
|
88
|
-
|
89
|
-
|
63
|
+
describe '#to_html' do
|
64
|
+
subject { instance.to_html }
|
90
65
|
|
91
|
-
|
92
|
-
end
|
93
|
-
end
|
66
|
+
it { subject.must_be_instance_of(String) }
|
94
67
|
end
|
95
68
|
|
96
69
|
describe '#to_s' do
|
@@ -159,11 +132,37 @@ module Vedeu
|
|
159
132
|
|
160
133
|
it { subject.must_equal("") }
|
161
134
|
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe '#x' do
|
138
|
+
let(:position) { Position.new(17, 2) }
|
139
|
+
|
140
|
+
subject { instance.x }
|
141
|
+
|
142
|
+
context 'when a position is set' do
|
143
|
+
it { subject.must_equal(2) }
|
144
|
+
end
|
162
145
|
|
163
|
-
context 'when
|
164
|
-
let(:
|
146
|
+
context 'when a position is not set' do
|
147
|
+
let(:position) {}
|
148
|
+
|
149
|
+
it { subject.must_equal(nil) }
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
describe '#y' do
|
154
|
+
let(:position) { Position.new(17, 2) }
|
155
|
+
|
156
|
+
subject { instance.y }
|
157
|
+
|
158
|
+
context 'when a position is set' do
|
159
|
+
it { subject.must_equal(17) }
|
160
|
+
end
|
161
|
+
|
162
|
+
context 'when a position is not set' do
|
163
|
+
let(:position) {}
|
165
164
|
|
166
|
-
it { subject.must_equal(
|
165
|
+
it { subject.must_equal(nil) }
|
167
166
|
end
|
168
167
|
end
|
169
168
|
|
@@ -33,7 +33,7 @@ module Vedeu
|
|
33
33
|
|
34
34
|
let(:streams_parent) { Line.new({ streams: nil, parent: parent, colour: colour, style: style }) }
|
35
35
|
|
36
|
-
let(:parent) {
|
36
|
+
let(:parent) { Vedeu::Interface.new }
|
37
37
|
let(:colour) { Colour.new({ foreground: '#ff0000', background: '#000000' }) }
|
38
38
|
let(:style) { Style.new('normal') }
|
39
39
|
|
@@ -25,7 +25,7 @@ module Vedeu
|
|
25
25
|
}
|
26
26
|
let(:colour) { Colour.new({ background: '#ff0000', foreground: '#000000' }) }
|
27
27
|
let(:style) { Style.new('normal') }
|
28
|
-
let(:line_parent) {
|
28
|
+
let(:line_parent) { Vedeu::Interface.new }
|
29
29
|
|
30
30
|
describe '#initialize' do
|
31
31
|
it { instance.must_be_instance_of(described) }
|
@@ -14,6 +14,7 @@ module Vedeu
|
|
14
14
|
|
15
15
|
before do
|
16
16
|
Vedeu.interfaces.reset
|
17
|
+
Vedeu.borders.reset
|
17
18
|
Vedeu.interface 'borders' do
|
18
19
|
geometry do
|
19
20
|
height 5
|
@@ -280,11 +281,11 @@ module Vedeu
|
|
280
281
|
|
281
282
|
it 'returns the escape sequences to draw a border' do
|
282
283
|
subject.must_equal(
|
283
|
-
"\e(0l\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0k\e(B
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
284
|
+
"\e(0l\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0k\e(B
|
285
|
+
\e(0x\e(BBeryll\e(0x\e(B
|
286
|
+
\e(0x\e(BMagnes\e(0x\e(B
|
287
|
+
\e(0x\e(BPluton\e(0x\e(B
|
288
|
+
\e(0m\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0j\e(B"
|
288
289
|
)
|
289
290
|
end
|
290
291
|
end
|
@@ -12,6 +12,7 @@ module Vedeu
|
|
12
12
|
let(:buffer) { Buffer.new(_name, interface) }
|
13
13
|
let(:interface) {
|
14
14
|
Vedeu.interface(_name) do
|
15
|
+
border!
|
15
16
|
geometry do
|
16
17
|
height 5
|
17
18
|
width 10
|
@@ -50,26 +51,7 @@ module Vedeu
|
|
50
51
|
end
|
51
52
|
|
52
53
|
context 'when the view has not redefined the geometry' do
|
53
|
-
it
|
54
|
-
subject.must_equal(
|
55
|
-
[
|
56
|
-
[
|
57
|
-
"\e[1;1H \e[1;1H" \
|
58
|
-
"\e[2;1H \e[2;1H" \
|
59
|
-
"\e[3;1H \e[3;1H" \
|
60
|
-
"\e[4;1H \e[4;1H" \
|
61
|
-
"\e[5;1H \e[5;1H" \
|
62
|
-
"\e[1;1HSome text." \
|
63
|
-
"\e[2;1H " \
|
64
|
-
"\e[3;1H " \
|
65
|
-
"\e[4;1H " \
|
66
|
-
"\e[5;1H ",
|
67
|
-
|
68
|
-
"\e[1;1H\e[?25l"
|
69
|
-
]
|
70
|
-
]
|
71
|
-
)
|
72
|
-
end
|
54
|
+
# it { skip }
|
73
55
|
end
|
74
56
|
end
|
75
57
|
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe HTMLChar do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::HTMLChar }
|
8
|
+
let(:instance) { described.new(char) }
|
9
|
+
let(:char) { Vedeu::Char.new(attributes) }
|
10
|
+
let(:attributes) {
|
11
|
+
{
|
12
|
+
border: border,
|
13
|
+
colour: colour,
|
14
|
+
parent: parent,
|
15
|
+
value: value
|
16
|
+
}
|
17
|
+
}
|
18
|
+
let(:border) {}
|
19
|
+
let(:colour) {}
|
20
|
+
let(:parent) { Vedeu::Line.new({ colour: parent_colour }) }
|
21
|
+
let(:parent_colour) {}
|
22
|
+
let(:value) {}
|
23
|
+
|
24
|
+
describe '#initialize' do
|
25
|
+
it { instance.must_be_instance_of(Vedeu::HTMLChar) }
|
26
|
+
it { instance.instance_variable_get('@char').must_equal(char) }
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '.render' do
|
30
|
+
subject { described.render(char) }
|
31
|
+
|
32
|
+
it { subject.must_be_instance_of(String) }
|
33
|
+
|
34
|
+
context 'when there is a border' do
|
35
|
+
let(:border) { :top_left }
|
36
|
+
|
37
|
+
context 'when there is a colour' do
|
38
|
+
let(:colour) { Vedeu::Colour.new({ background: '#220022', foreground: '#aadd00' }) }
|
39
|
+
|
40
|
+
it { subject.must_equal(
|
41
|
+
"<td style='background:#220022;color:#aadd00;border:1px #220022 solid;border-top:1px #aadd00 solid;border-left:1px #aadd00 solid;'> </td>"
|
42
|
+
) }
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when there is no colour' do
|
46
|
+
context 'when there is a parent colour' do
|
47
|
+
let(:parent_colour) { Vedeu::Colour.new({ background: '#002222', foreground: '#dd2200' }) }
|
48
|
+
|
49
|
+
it { subject.must_equal(
|
50
|
+
"<td style='background:#002222;color:#dd2200;border:1px #002222 solid;border-top:1px #dd2200 solid;border-left:1px #dd2200 solid;'> </td>"
|
51
|
+
) }
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'when there is no parent colour' do
|
55
|
+
it { subject.must_equal(
|
56
|
+
"<td style='background:#000;color:#222;border:1px #000 solid;border-top:1px #222 solid;border-left:1px #222 solid;'> </td>"
|
57
|
+
) }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'when there is no border' do
|
63
|
+
context 'when there is no value' do
|
64
|
+
it { subject.must_equal("<td> </td>") }
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'when the value is empty' do
|
68
|
+
let(:value) { '' }
|
69
|
+
|
70
|
+
it { subject.must_equal("<td> </td>") }
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'when there is a value' do
|
74
|
+
let(:value) { 'a' }
|
75
|
+
|
76
|
+
it { subject.must_equal(
|
77
|
+
"<td style='background:#000;color:#222;border:1px #000 solid;'>a</td>"
|
78
|
+
) }
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end # HTMLChar
|
84
|
+
|
85
|
+
end # Vedeu
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe HTMLRenderer do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::HTMLRenderer }
|
8
|
+
let(:instance) { described.new(output) }
|
9
|
+
let(:output) {}
|
10
|
+
|
11
|
+
describe '#initialize' do
|
12
|
+
it { instance.must_be_instance_of(Vedeu::HTMLRenderer) }
|
13
|
+
it { instance.instance_variable_get('@output').must_equal(output) }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#render' do
|
17
|
+
subject { instance.render }
|
18
|
+
|
19
|
+
it { subject.must_be_instance_of(String) }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#to_file' do
|
23
|
+
let(:path) {}
|
24
|
+
|
25
|
+
subject { instance.to_file(path) }
|
26
|
+
|
27
|
+
context 'when a path is given' do
|
28
|
+
let(:path) { '/tmp/test_vedeu_html_renderer.html' }
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when a path is not given' do
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end # HTMLRenderer
|
36
|
+
|
37
|
+
end # Vedeu
|
@@ -47,11 +47,7 @@ module Vedeu
|
|
47
47
|
|
48
48
|
it { subject.must_equal(5) }
|
49
49
|
|
50
|
-
|
51
|
-
subject { instance.first }
|
52
|
-
|
53
|
-
it { subject.must_equal(5) }
|
54
|
-
end
|
50
|
+
it { instance.must_respond_to(:first) }
|
55
51
|
end
|
56
52
|
|
57
53
|
context '#x' do
|
@@ -59,11 +55,7 @@ module Vedeu
|
|
59
55
|
|
60
56
|
it { subject.must_equal(16) }
|
61
57
|
|
62
|
-
|
63
|
-
subject { instance.last }
|
64
|
-
|
65
|
-
it { subject.must_equal(16) }
|
66
|
-
end
|
58
|
+
it { instance.must_respond_to(:last) }
|
67
59
|
end
|
68
60
|
end
|
69
61
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe Renderer do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::Renderer }
|
8
|
+
let(:instance) { described.new(output) }
|
9
|
+
let(:output) {}
|
10
|
+
|
11
|
+
describe '#initialize' do
|
12
|
+
it { instance.must_be_instance_of(Vedeu::Renderer) }
|
13
|
+
it { instance.instance_variable_get('@output').must_equal([output]) }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '.render' do
|
17
|
+
subject { described.render }
|
18
|
+
|
19
|
+
it { subject.must_be_instance_of(String) }
|
20
|
+
end
|
21
|
+
|
22
|
+
end # Renderer
|
23
|
+
|
24
|
+
end # Vedeu
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe VirtualBuffer do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::VirtualBuffer }
|
8
|
+
|
9
|
+
before { described.clear }
|
10
|
+
|
11
|
+
describe '#retrieve' do
|
12
|
+
subject { described.retrieve }
|
13
|
+
|
14
|
+
context 'when no buffers are stored' do
|
15
|
+
it { subject.must_be_instance_of(NilClass) }
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when buffers are stored' do
|
19
|
+
before { described.store([[Vedeu::Char.new]]) }
|
20
|
+
|
21
|
+
it { subject.must_be_instance_of(Array) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#store' do
|
26
|
+
let(:data) { :data }
|
27
|
+
|
28
|
+
subject { described.store(data) }
|
29
|
+
|
30
|
+
it { subject.must_be_instance_of(Array) }
|
31
|
+
|
32
|
+
it { subject.wont_be_empty }
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#size' do
|
36
|
+
subject { described.size }
|
37
|
+
|
38
|
+
it { subject.must_be_instance_of(Fixnum) }
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#clear' do
|
42
|
+
subject { described.clear }
|
43
|
+
|
44
|
+
it { subject.must_be_instance_of(Array) }
|
45
|
+
|
46
|
+
it { subject.must_be_empty }
|
47
|
+
|
48
|
+
it { described.must_respond_to(:reset) }
|
49
|
+
end
|
50
|
+
|
51
|
+
end # VirtualBuffer
|
52
|
+
|
53
|
+
end # Vedeu
|