vedeu 0.4.13 → 0.4.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -1
- data/.travis.yml +2 -1
- data/Guardfile +6 -5
- data/README.md +3 -30
- data/Rakefile +5 -5
- data/bin/vedeu_drb_client +1 -1
- data/bin/vedeu_drb_server +91 -89
- data/bin/vedeu_test +4 -0
- data/config/rubocop_enabled.yml +5 -10
- data/examples/borders_app.rb +2 -1
- data/examples/colours_app.rb +13 -8
- data/examples/configuration_app.rb +3 -2
- data/examples/cursor_app.rb +16 -11
- data/examples/drb_app.rb +88 -89
- data/examples/focus_app.rb +31 -32
- data/examples/geometry_app.rb +2 -1
- data/examples/hello_world.rb +2 -1
- data/examples/lines_app.rb +2 -1
- data/examples/material_colours_app.rb +126 -0
- data/examples/typed_commands/typed_commands_app.rb +5 -1
- data/examples/view_templates_app/view_templates_app.rb +6 -3
- data/lib/vedeu/all.rb +1 -1
- data/lib/vedeu/api.rb +18 -10
- data/lib/vedeu/application.rb +0 -1
- data/lib/vedeu/bindings.rb +77 -16
- data/lib/vedeu/buffers/all.rb +2 -5
- data/lib/vedeu/buffers/buffer.rb +69 -25
- data/lib/vedeu/buffers/display_buffer.rb +3 -7
- data/lib/vedeu/configuration/all.rb +3 -6
- data/lib/vedeu/configuration/api.rb +28 -4
- data/lib/vedeu/configuration/cli.rb +9 -9
- data/lib/vedeu/configuration/configuration.rb +11 -7
- data/lib/vedeu/cursor/all.rb +3 -6
- data/lib/vedeu/cursor/cursor.rb +22 -14
- data/lib/vedeu/cursor/move.rb +32 -22
- data/lib/vedeu/cursor/refresh_cursor.rb +1 -1
- data/lib/vedeu/debug.rb +2 -1
- data/lib/vedeu/distributed/client.rb +1 -7
- data/lib/vedeu/distributed/server.rb +0 -4
- data/lib/vedeu/distributed/subprocess.rb +1 -1
- data/lib/vedeu/distributed/templates/default_configuration.vedeu +1 -1
- data/lib/vedeu/distributed/test_application.rb +3 -5
- data/lib/vedeu/distributed/uri.rb +2 -2
- data/lib/vedeu/dsl/all.rb +6 -6
- data/lib/vedeu/dsl/components/all.rb +0 -3
- data/lib/vedeu/dsl/components/border.rb +20 -12
- data/lib/vedeu/dsl/components/geometry.rb +68 -3
- data/lib/vedeu/dsl/components/keymap.rb +1 -2
- data/lib/vedeu/dsl/composition.rb +8 -1
- data/lib/vedeu/dsl/interface.rb +61 -11
- data/lib/vedeu/dsl/line.rb +12 -12
- data/lib/vedeu/dsl/shared/all.rb +4 -7
- data/lib/vedeu/dsl/shared/colour.rb +2 -2
- data/lib/vedeu/dsl/shared/text.rb +2 -35
- data/lib/vedeu/dsl/shared/use.rb +2 -2
- data/lib/vedeu/dsl/view.rb +4 -4
- data/lib/vedeu/events/all.rb +3 -5
- data/lib/vedeu/events/event.rb +5 -5
- data/lib/vedeu/geometry/all.rb +11 -16
- data/lib/vedeu/geometry/area.rb +2 -5
- data/lib/vedeu/geometry/canvas.rb +12 -16
- data/lib/vedeu/geometry/dimension.rb +20 -22
- data/lib/vedeu/geometry/geometry.rb +28 -30
- data/lib/vedeu/geometry/grid.rb +1 -1
- data/lib/vedeu/geometry/index_position.rb +7 -0
- data/lib/vedeu/geometry/null_geometry.rb +61 -0
- data/lib/vedeu/geometry/position.rb +0 -3
- data/lib/vedeu/geometry/position_index.rb +7 -0
- data/lib/vedeu/geometry/position_validator.rb +44 -33
- data/lib/vedeu/input/all.rb +5 -4
- data/lib/vedeu/input/keymap.rb +0 -1
- data/lib/vedeu/input/mapper.rb +1 -3
- data/lib/vedeu/launcher.rb +6 -7
- data/lib/vedeu/main_loop.rb +1 -2
- data/lib/vedeu/models/all.rb +1 -0
- data/lib/vedeu/models/cell.rb +5 -8
- data/lib/vedeu/models/char.rb +50 -15
- data/lib/vedeu/models/composition.rb +8 -1
- data/lib/vedeu/models/focus.rb +4 -4
- data/lib/vedeu/models/group.rb +3 -3
- data/lib/vedeu/models/interface.rb +62 -46
- data/lib/vedeu/models/line.rb +1 -1
- data/lib/vedeu/models/null.rb +48 -0
- data/lib/vedeu/models/stream.rb +5 -5
- data/lib/vedeu/output/all.rb +20 -30
- data/lib/vedeu/output/border.rb +93 -40
- data/lib/vedeu/output/clear.rb +100 -15
- data/lib/vedeu/output/colour.rb +56 -12
- data/lib/vedeu/output/compressor.rb +59 -0
- data/lib/vedeu/output/html_char.rb +4 -2
- data/lib/vedeu/output/null_border.rb +16 -4
- data/lib/vedeu/output/output.rb +13 -21
- data/lib/vedeu/output/presentation.rb +28 -23
- data/lib/vedeu/output/refresh.rb +2 -2
- data/lib/vedeu/output/renderers/all.rb +80 -3
- data/lib/vedeu/output/renderers/file_renderer.rb +38 -2
- data/lib/vedeu/output/renderers/html_renderer.rb +6 -4
- data/lib/vedeu/output/renderers/json_renderer.rb +52 -0
- data/lib/vedeu/output/renderers/null_renderer.rb +14 -0
- data/lib/vedeu/output/renderers/terminal_renderer.rb +2 -12
- data/lib/vedeu/output/style.rb +33 -3
- data/lib/vedeu/output/text.rb +98 -1
- data/lib/vedeu/output/translator.rb +30 -7
- data/lib/vedeu/output/viewport.rb +43 -79
- data/lib/vedeu/output/wordwrap.rb +4 -4
- data/lib/vedeu/repositories/all.rb +22 -179
- data/lib/vedeu/repositories/collection.rb +11 -13
- data/lib/vedeu/repositories/collections/all.rb +8 -0
- data/lib/vedeu/repositories/collections/chars.rb +9 -0
- data/lib/vedeu/repositories/collections/events.rb +9 -0
- data/lib/vedeu/repositories/collections/interfaces.rb +9 -0
- data/lib/vedeu/repositories/collections/keys.rb +9 -0
- data/lib/vedeu/repositories/collections/lines.rb +9 -0
- data/lib/vedeu/repositories/collections/streams.rb +9 -0
- data/lib/vedeu/repositories/model.rb +7 -2
- data/lib/vedeu/repositories/repositories/all.rb +14 -0
- data/lib/vedeu/repositories/repositories/background_colours.rb +14 -0
- data/lib/vedeu/repositories/repositories/borders.rb +38 -0
- data/lib/vedeu/repositories/repositories/buffers.rb +36 -0
- data/lib/vedeu/repositories/repositories/colours.rb +63 -0
- data/lib/vedeu/repositories/repositories/cursors.rb +29 -0
- data/lib/vedeu/repositories/repositories/events_repository.rb +24 -0
- data/lib/vedeu/repositories/repositories/foreground_colours.rb +14 -0
- data/lib/vedeu/repositories/repositories/geometries.rb +37 -0
- data/lib/vedeu/repositories/repositories/groups.rb +24 -0
- data/lib/vedeu/repositories/repositories/interfaces_repository.rb +24 -0
- data/lib/vedeu/repositories/repositories/keymaps.rb +24 -0
- data/lib/vedeu/repositories/repositories/menus.rb +24 -0
- data/lib/vedeu/repositories/repository.rb +29 -47
- data/lib/vedeu/storage/all.rb +6 -0
- data/lib/vedeu/storage/associative_store.rb +47 -0
- data/lib/vedeu/storage/conveyor_store.rb +69 -0
- data/lib/vedeu/storage/fifo_store.rb +37 -0
- data/lib/vedeu/storage/store.rb +58 -0
- data/lib/vedeu/support/all.rb +5 -10
- data/lib/vedeu/support/common.rb +0 -8
- data/lib/vedeu/support/log.rb +13 -24
- data/lib/vedeu/support/template.rb +4 -1
- data/lib/vedeu/support/terminal.rb +10 -10
- data/lib/vedeu/support/trace.rb +15 -88
- data/lib/vedeu/support/visibility.rb +73 -0
- data/lib/vedeu.rb +37 -0
- data/test/lib/vedeu/api_test.rb +7 -3
- data/test/lib/vedeu/application_test.rb +9 -3
- data/test/lib/vedeu/bindings_test.rb +21 -0
- data/test/lib/vedeu/buffers/buffer_test.rb +110 -134
- data/test/lib/vedeu/buffers/display_buffer_test.rb +8 -0
- data/test/lib/vedeu/configuration/api_test.rb +5 -1
- data/test/lib/vedeu/configuration/configuration_test.rb +4 -6
- data/test/lib/vedeu/cursor/cursor_test.rb +25 -17
- data/test/lib/vedeu/cursor/move_test.rb +7 -7
- data/test/lib/vedeu/distributed/client_test.rb +1 -1
- data/test/lib/vedeu/distributed/subprocess_test.rb +3 -1
- data/test/lib/vedeu/distributed/uri_test.rb +5 -5
- data/test/lib/vedeu/dsl/components/geometry_test.rb +43 -0
- data/test/lib/vedeu/dsl/components/keymap_test.rb +1 -1
- data/test/lib/vedeu/dsl/composition_test.rb +6 -5
- data/test/lib/vedeu/dsl/interface_test.rb +81 -16
- data/test/lib/vedeu/dsl/shared/colour_test.rb +4 -4
- data/test/lib/vedeu/dsl/shared/text_test.rb +87 -9
- data/test/lib/vedeu/dsl/stream_test.rb +1 -1
- data/test/lib/vedeu/events/event_test.rb +3 -1
- data/test/lib/vedeu/events/trigger_test.rb +8 -4
- data/test/lib/vedeu/geometry/dimension_test.rb +1 -1
- data/test/lib/vedeu/geometry/geometry_test.rb +5 -3
- data/test/lib/vedeu/geometry/index_position_test.rb +30 -7
- data/test/lib/vedeu/geometry/null_geometry_test.rb +57 -0
- data/test/lib/vedeu/geometry/position_index_test.rb +14 -0
- data/test/lib/vedeu/geometry/position_validator_test.rb +17 -3
- data/test/lib/vedeu/input/keymap_test.rb +3 -1
- data/test/lib/vedeu/input/mapper_test.rb +8 -4
- data/test/lib/vedeu/launcher_test.rb +1 -1
- data/test/lib/vedeu/models/cell_test.rb +10 -8
- data/test/lib/vedeu/models/char_test.rb +52 -28
- data/test/lib/vedeu/models/composition_test.rb +26 -4
- data/test/lib/vedeu/models/group_test.rb +11 -5
- data/test/lib/vedeu/models/interface_test.rb +32 -19
- data/test/lib/vedeu/models/line_test.rb +21 -25
- data/test/lib/vedeu/models/menu_test.rb +10 -6
- data/test/lib/vedeu/models/null_test.rb +66 -0
- data/test/lib/vedeu/models/stream_test.rb +13 -10
- data/test/lib/vedeu/output/border_test.rb +29 -8
- data/test/lib/vedeu/output/clear_test.rb +23 -4
- data/test/lib/vedeu/output/colour_test.rb +20 -4
- data/test/lib/vedeu/output/compressor_test.rb +43 -0
- data/test/lib/vedeu/output/html_char_test.rb +29 -17
- data/test/lib/vedeu/output/null_border_test.rb +2 -1
- data/test/lib/vedeu/output/output_test.rb +20 -30
- data/test/lib/vedeu/output/presentation_test.rb +39 -16
- data/test/lib/vedeu/output/refresh_test.rb +14 -10
- data/test/lib/vedeu/output/renderers/all_test.rb +96 -0
- data/test/lib/vedeu/output/renderers/file_renderer_test.rb +1 -1
- data/test/lib/vedeu/output/renderers/html_renderer_test.rb +13 -9
- data/test/lib/vedeu/output/renderers/json_renderer_test.rb +52 -0
- data/test/lib/vedeu/output/renderers/null_renderer_test.rb +19 -0
- data/test/lib/vedeu/output/style_test.rb +41 -1
- data/test/lib/vedeu/output/text_test.rb +61 -10
- data/test/lib/vedeu/output/translator_test.rb +14 -0
- data/test/lib/vedeu/output/viewport_test.rb +22 -3
- data/test/lib/vedeu/output/virtual_terminal_test.rb +3 -3
- data/test/lib/vedeu/output/wordwrap_test.rb +58 -45
- data/test/lib/vedeu/repositories/collections/chars_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/events_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/interfaces_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/keys_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/lines_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/streams_test.rb +16 -0
- data/test/lib/vedeu/repositories/repositories/background_colours_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/borders_test.rb +51 -0
- data/test/lib/vedeu/repositories/repositories/buffers_test.rb +52 -0
- data/test/lib/vedeu/repositories/repositories/colours_test.rb +16 -0
- data/test/lib/vedeu/repositories/repositories/cursors_test.rb +39 -0
- data/test/lib/vedeu/repositories/repositories/events_repository_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/foreground_colours_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/geometries_test.rb +42 -0
- data/test/lib/vedeu/repositories/repositories/groups_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/interfaces_repositories_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/keymaps_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/menus_test.rb +17 -0
- data/test/lib/vedeu/repositories/repository_test.rb +16 -36
- data/test/lib/vedeu/storage/associative_store_test.rb +69 -0
- data/test/lib/vedeu/storage/conveyor_store_test.rb +135 -0
- data/test/lib/vedeu/storage/fifo_store_test.rb +47 -0
- data/test/lib/vedeu/storage/store_test.rb +123 -0
- data/test/lib/vedeu/support/common_test.rb +0 -9
- data/test/lib/vedeu/support/terminal_test.rb +78 -55
- data/test/lib/vedeu/support/visibility_test.rb +80 -0
- data/test/test_helper.rb +13 -11
- data/vedeu.gemspec +4 -3
- metadata +92 -32
- data/lib/vedeu/cursor/toggle.rb +0 -55
- data/lib/vedeu/exceptions.rb +0 -37
- data/lib/vedeu/geometry/centre.rb +0 -85
- data/lib/vedeu/geometry/content.rb +0 -70
- data/lib/vedeu/geometry/limit.rb +0 -58
- data/lib/vedeu/output/compositor.rb +0 -62
- data/lib/vedeu/repositories/collections.rb +0 -41
- data/lib/vedeu/support/coercions.rb +0 -60
- data/lib/vedeu/support/sentence.rb +0 -91
- data/lib/vedeu/support/visible.rb +0 -90
- data/test/lib/vedeu/cursor/toggle_test.rb +0 -63
- data/test/lib/vedeu/geometry/centre_test.rb +0 -58
- data/test/lib/vedeu/geometry/content_test.rb +0 -98
- data/test/lib/vedeu/geometry/limit_test.rb +0 -30
- data/test/lib/vedeu/output/compositor_test.rb +0 -48
- data/test/lib/vedeu/repositories/all_test.rb +0 -135
- data/test/lib/vedeu/repositories/collections_test.rb +0 -71
- data/test/lib/vedeu/support/coercions_test.rb +0 -84
- data/test/lib/vedeu/support/sentence_test.rb +0 -56
- data/test/lib/vedeu/support/visible_test.rb +0 -161
@@ -14,8 +14,10 @@ module Vedeu
|
|
14
14
|
}
|
15
15
|
|
16
16
|
describe '#initialize' do
|
17
|
-
|
18
|
-
|
17
|
+
subject { instance }
|
18
|
+
|
19
|
+
it { subject.must_be_instance_of(described) }
|
20
|
+
it { subject.instance_variable_get('@attributes').must_equal(attributes) }
|
19
21
|
end
|
20
22
|
|
21
23
|
describe '#background' do
|
@@ -45,11 +47,25 @@ module Vedeu
|
|
45
47
|
describe '#background=' do
|
46
48
|
let(:value) { '#000000' }
|
47
49
|
|
48
|
-
subject { instance.background=(value) }
|
50
|
+
subject { instance.background = (value) }
|
49
51
|
|
50
52
|
it { subject.must_equal(value) }
|
51
53
|
end
|
52
54
|
|
55
|
+
describe '#eql?' do
|
56
|
+
let(:other) { instance }
|
57
|
+
|
58
|
+
subject { instance.eql?(other) }
|
59
|
+
|
60
|
+
it { subject.must_equal(true) }
|
61
|
+
|
62
|
+
context 'when different to other' do
|
63
|
+
let(:other) { described.new(background: '#ff0000') }
|
64
|
+
|
65
|
+
it { subject.must_equal(false) }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
53
69
|
describe '#foreground' do
|
54
70
|
subject { instance.foreground }
|
55
71
|
|
@@ -77,7 +93,7 @@ module Vedeu
|
|
77
93
|
describe '#foreground=' do
|
78
94
|
let(:value) { '#ff0000' }
|
79
95
|
|
80
|
-
subject { instance.foreground=(value) }
|
96
|
+
subject { instance.foreground = (value) }
|
81
97
|
|
82
98
|
it { subject.must_equal(value) }
|
83
99
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe Compressor do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::Compressor }
|
8
|
+
let(:instance) { described.new(output) }
|
9
|
+
let(:output) {}
|
10
|
+
|
11
|
+
describe '#initialize' do
|
12
|
+
it { instance.must_be_instance_of(Vedeu::Compressor) }
|
13
|
+
it { instance.instance_variable_get('@output').must_equal(output) }
|
14
|
+
it { instance.instance_variable_get('@colour').must_equal('') }
|
15
|
+
it { instance.instance_variable_get('@style').must_equal('') }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#render' do
|
19
|
+
subject { instance.render }
|
20
|
+
|
21
|
+
it { subject.must_be_instance_of(String) }
|
22
|
+
|
23
|
+
context 'when the output is all Vedeu::Char elements' do
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when the output is not all Vedeu::Char elements' do
|
28
|
+
let(:output) {
|
29
|
+
[
|
30
|
+
Vedeu::Char.new(value: 'N'),
|
31
|
+
'o',
|
32
|
+
Vedeu::Char.new(value: 't'),
|
33
|
+
]
|
34
|
+
}
|
35
|
+
it 'converts the non-Vedeu::Char elements into String elements' do
|
36
|
+
subject.must_equal('Not')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end # Compressor
|
42
|
+
|
43
|
+
end # Vedeu
|
@@ -17,7 +17,7 @@ module Vedeu
|
|
17
17
|
}
|
18
18
|
let(:border) {}
|
19
19
|
let(:colour) {}
|
20
|
-
let(:parent) { Vedeu::Line.new(
|
20
|
+
let(:parent) { Vedeu::Line.new(colour: parent_colour) }
|
21
21
|
let(:parent_colour) {}
|
22
22
|
let(:value) {}
|
23
23
|
|
@@ -35,39 +35,50 @@ module Vedeu
|
|
35
35
|
let(:border) { :top_left }
|
36
36
|
|
37
37
|
context 'when there is a colour' do
|
38
|
-
let(:colour) {
|
38
|
+
let(:colour) {
|
39
|
+
Vedeu::Colour.new(background: '#220022', foreground: '#aadd00')
|
40
|
+
}
|
39
41
|
|
40
42
|
it { subject.must_equal(
|
41
|
-
"<td style='background:#220022;color:#aadd00;
|
43
|
+
"<td style='background:#220022;color:#aadd00;" \
|
44
|
+
"border:1px #220022 solid;border-top:1px #aadd00 solid;" \
|
45
|
+
"border-left:1px #aadd00 solid;'> </td>"
|
42
46
|
) }
|
43
47
|
end
|
44
48
|
|
45
49
|
context 'when there is no colour' do
|
46
50
|
context 'when there is a parent colour' do
|
47
|
-
let(:parent_colour) {
|
51
|
+
let(:parent_colour) {
|
52
|
+
Vedeu::Colour.new(background: '#002222', foreground: '#dd2200')
|
53
|
+
}
|
48
54
|
|
49
55
|
it { subject.must_equal(
|
50
|
-
"<td style='background:#002222;color:#dd2200;
|
56
|
+
"<td style='background:#002222;color:#dd2200;" \
|
57
|
+
"border:1px #002222 solid;border-top:1px #dd2200 solid;" \
|
58
|
+
"border-left:1px #dd2200 solid;'> </td>"
|
51
59
|
) }
|
52
60
|
end
|
53
61
|
|
54
62
|
context 'when there is no parent colour' do
|
55
63
|
it { subject.must_equal(
|
56
|
-
"<td style='background:#000;color:#222;border:1px #000 solid;
|
64
|
+
"<td style='background:#000;color:#222;border:1px #000 solid;" \
|
65
|
+
"border-top:1px #222 solid;border-left:1px #222 solid;'>" \
|
66
|
+
" </td>"
|
57
67
|
) }
|
58
68
|
end
|
59
69
|
end
|
60
70
|
end
|
61
71
|
|
72
|
+
grey = '1px #222 solid'
|
62
73
|
{
|
63
|
-
top_horizontal: "border-top
|
64
|
-
left_vertical: "border-left
|
65
|
-
right_vertical: "border-right
|
66
|
-
bottom_horizontal: "border-bottom
|
67
|
-
top_left:
|
68
|
-
top_right:
|
69
|
-
bottom_left:
|
70
|
-
bottom_right:
|
74
|
+
top_horizontal: "border-top:#{grey};",
|
75
|
+
left_vertical: "border-left:#{grey};",
|
76
|
+
right_vertical: "border-right:#{grey};",
|
77
|
+
bottom_horizontal: "border-bottom:#{grey};",
|
78
|
+
top_left: "border-top:#{grey};border-left:#{grey};",
|
79
|
+
top_right: "border-top:#{grey};border-right:#{grey};",
|
80
|
+
bottom_left: "border-bottom:#{grey};border-left:#{grey};",
|
81
|
+
bottom_right: "border-bottom:#{grey};border-right:#{grey};",
|
71
82
|
horizontal: '',
|
72
83
|
vertical: ''
|
73
84
|
}.each do |border_style, result|
|
@@ -84,20 +95,21 @@ module Vedeu
|
|
84
95
|
|
85
96
|
context 'when there is no border' do
|
86
97
|
context 'when there is no value' do
|
87
|
-
it { subject.must_equal(
|
98
|
+
it { subject.must_equal('<td> </td>') }
|
88
99
|
end
|
89
100
|
|
90
101
|
context 'when the value is empty' do
|
91
102
|
let(:value) { '' }
|
92
103
|
|
93
|
-
it { subject.must_equal(
|
104
|
+
it { subject.must_equal('<td> </td>') }
|
94
105
|
end
|
95
106
|
|
96
107
|
context 'when there is a value' do
|
97
108
|
let(:value) { 'a' }
|
98
109
|
|
99
110
|
it { subject.must_equal(
|
100
|
-
"<td style='background:#000;color:#222;
|
111
|
+
"<td style='background:#000;color:#222;" \
|
112
|
+
"border:1px #000 solid;'>a</td>"
|
101
113
|
) }
|
102
114
|
end
|
103
115
|
end
|
@@ -6,7 +6,8 @@ module Vedeu
|
|
6
6
|
|
7
7
|
let(:described) { Vedeu::NullBorder }
|
8
8
|
let(:instance) { described.new(interface) }
|
9
|
-
let(:interface) { stub('Interface',
|
9
|
+
let(:interface) { stub('Interface', geometry: geometry) }
|
10
|
+
let(:geometry) { stub('Geometry', x: 4, y: 6, xn: 10, yn: 12) }
|
10
11
|
|
11
12
|
describe '#initialize' do
|
12
13
|
it { instance.must_be_instance_of(Vedeu::NullBorder) }
|
@@ -5,46 +5,36 @@ module Vedeu
|
|
5
5
|
describe Output do
|
6
6
|
|
7
7
|
let(:described) { Vedeu::Output }
|
8
|
-
let(:instance) { described.new(
|
9
|
-
let(:
|
10
|
-
Vedeu.interface 'flourine' do
|
11
|
-
geometry do
|
12
|
-
height 3
|
13
|
-
width 32
|
14
|
-
end
|
15
|
-
end
|
16
|
-
}
|
17
|
-
let(:lines) {
|
18
|
-
[
|
19
|
-
Line.new({ streams: [Stream.new({ value: 'this is the first' })] }),
|
20
|
-
Line.new({ streams: [Stream.new({ value: 'this is the second and it is long' })] }),
|
21
|
-
Line.new({ streams: [Stream.new({ value: 'this is the third, it is even longer and still truncated' })] }),
|
22
|
-
Line.new({ streams: [Stream.new({ value: 'this should not render' })] }),
|
23
|
-
]
|
24
|
-
}
|
25
|
-
|
26
|
-
before do
|
27
|
-
interface.lines = lines
|
28
|
-
IO.console.stubs(:print)
|
29
|
-
end
|
8
|
+
let(:instance) { described.new(content) }
|
9
|
+
let(:content) {}
|
30
10
|
|
31
11
|
describe '#initialize' do
|
32
12
|
it { instance.must_be_instance_of(described) }
|
33
|
-
it { instance.instance_variable_get('@
|
13
|
+
it { instance.instance_variable_get('@content').must_equal(content) }
|
34
14
|
end
|
35
15
|
|
36
16
|
describe '.render' do
|
37
|
-
|
17
|
+
let(:rendered) { interface.render }
|
38
18
|
|
39
|
-
|
19
|
+
before do
|
20
|
+
Vedeu.renderers.stubs(:render)
|
21
|
+
# Vedeu::FileRenderer.stubs(:render)
|
22
|
+
# Vedeu::HTMLRenderer.stubs(:to_file)
|
23
|
+
# Vedeu::TerminalRenderer.stubs(:render).returns(rendered)
|
24
|
+
end
|
40
25
|
|
41
|
-
|
26
|
+
subject { described.render(content) }
|
42
27
|
|
43
|
-
context 'when
|
44
|
-
|
28
|
+
# context 'when DRb is enabled' do
|
29
|
+
# it { }
|
30
|
+
# end
|
45
31
|
|
46
|
-
context 'when
|
47
|
-
|
32
|
+
# context 'when DRb is not enabled' do
|
33
|
+
# it 'sends the rendered interface to the Terminal' do
|
34
|
+
# Vedeu::TerminalRenderer.expects(:render)
|
35
|
+
# subject.must_be_instance_of(Array)
|
36
|
+
# end
|
37
|
+
# end
|
48
38
|
end
|
49
39
|
|
50
40
|
end # Output
|
@@ -2,9 +2,28 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
+
class ParentPresentationTestClass
|
6
|
+
include Presentation
|
7
|
+
|
8
|
+
def parent
|
9
|
+
nil
|
10
|
+
end
|
11
|
+
|
12
|
+
def attributes
|
13
|
+
{
|
14
|
+
colour: { background: '#330000', foreground: '#00aadd' },
|
15
|
+
style: ['bold']
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
5
20
|
class PresentationTestClass
|
6
21
|
include Presentation
|
7
22
|
|
23
|
+
def parent
|
24
|
+
ParentPresentationTestClass.new
|
25
|
+
end
|
26
|
+
|
8
27
|
def attributes
|
9
28
|
{
|
10
29
|
colour: { background: '#000033', foreground: '#aadd00' },
|
@@ -44,9 +63,9 @@ module Vedeu
|
|
44
63
|
end
|
45
64
|
|
46
65
|
describe '#colour=' do
|
47
|
-
let(:colour) { Colour.new(
|
66
|
+
let(:colour) { Colour.new(foreground: '#00ff00', background: '#000000') }
|
48
67
|
|
49
|
-
subject { receiver.colour=(colour) }
|
68
|
+
subject { receiver.colour = (colour) }
|
50
69
|
|
51
70
|
it { subject.must_be_instance_of(Colour) }
|
52
71
|
end
|
@@ -60,23 +79,31 @@ module Vedeu
|
|
60
79
|
describe '#style=' do
|
61
80
|
let(:style) { Style.new('normal') }
|
62
81
|
|
63
|
-
subject { receiver.style=(style) }
|
82
|
+
subject { receiver.style = (style) }
|
64
83
|
|
65
84
|
it { subject.must_be_instance_of(Style) }
|
66
85
|
end
|
67
86
|
|
68
87
|
describe '#to_s' do
|
69
88
|
let(:line) {
|
70
|
-
Vedeu::Line.new(
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
89
|
+
Vedeu::Line.new(streams: [],
|
90
|
+
parent: Vedeu::Interface.new,
|
91
|
+
colour: line_colour,
|
92
|
+
style: Style.new('normal'))
|
93
|
+
}
|
94
|
+
let(:line_colour) {
|
95
|
+
Colour.new(foreground: '#00ff00', background: '#000000')
|
96
|
+
}
|
97
|
+
let(:stream) {
|
98
|
+
Stream.new(value: stream_value,
|
99
|
+
parent: line,
|
100
|
+
colour: stream_colour,
|
101
|
+
style: stream_style)
|
76
102
|
}
|
77
|
-
let(:stream) { Stream.new({ value: stream_value, parent: line, colour: stream_colour, style: stream_style }) }
|
78
103
|
let(:stream_value) { 'Some text' }
|
79
|
-
let(:stream_colour) {
|
104
|
+
let(:stream_colour) {
|
105
|
+
Colour.new(foreground: '#ff0000', background: '#000000')
|
106
|
+
}
|
80
107
|
let(:stream_style) { Style.new(:underline) }
|
81
108
|
|
82
109
|
it 'returns output' do
|
@@ -84,13 +111,9 @@ module Vedeu
|
|
84
111
|
# - stream colour
|
85
112
|
# - stream style
|
86
113
|
# - stream content
|
87
|
-
# - line style
|
88
|
-
# - line colour
|
89
114
|
"\e[38;2;255;0;0m\e[48;2;0;0;0m" \
|
90
115
|
"\e[4m" \
|
91
|
-
|
92
|
-
"\e[24m\e[22m\e[27m" \
|
93
|
-
"\e[38;2;0;255;0m\e[48;2;0;0;0m"
|
116
|
+
'Some text'
|
94
117
|
)
|
95
118
|
end
|
96
119
|
end
|
@@ -24,7 +24,7 @@ module Vedeu
|
|
24
24
|
context 'when there are no registered interfaces' do
|
25
25
|
before { Vedeu.focusable.reset }
|
26
26
|
|
27
|
-
it {
|
27
|
+
it { subject.must_equal(nil) }
|
28
28
|
end
|
29
29
|
|
30
30
|
context 'when there are registered interfaces' do
|
@@ -32,13 +32,24 @@ module Vedeu
|
|
32
32
|
end
|
33
33
|
|
34
34
|
describe '.by_group' do
|
35
|
+
subject { described.by_group(group_name) }
|
36
|
+
|
35
37
|
context 'when there are no registered groups' do
|
38
|
+
let(:group_name) { '' }
|
39
|
+
|
36
40
|
before { Vedeu.groups.reset }
|
37
41
|
|
38
|
-
it { proc {
|
42
|
+
it { proc { subject }.must_raise(ModelNotFound) }
|
39
43
|
end
|
40
44
|
|
41
45
|
context 'when there are registered groups' do
|
46
|
+
let(:group_name) { 'elements' }
|
47
|
+
|
48
|
+
before do
|
49
|
+
Vedeu::Group.new(name: group_name, members: 'aluminium').store
|
50
|
+
end
|
51
|
+
|
52
|
+
it { Vedeu.buffers.expects(:render).with('aluminium'); subject }
|
42
53
|
end
|
43
54
|
end
|
44
55
|
|
@@ -47,14 +58,7 @@ module Vedeu
|
|
47
58
|
|
48
59
|
subject { described.by_name(interface_name) }
|
49
60
|
|
50
|
-
|
51
|
-
let(:interface_name) { '' }
|
52
|
-
|
53
|
-
it { proc { described.by_name('') }.must_raise(ModelNotFound) }
|
54
|
-
end
|
55
|
-
|
56
|
-
context 'when the interface or buffer is found' do
|
57
|
-
end
|
61
|
+
it { Vedeu.buffers.expects(:render).with(interface_name); subject }
|
58
62
|
end
|
59
63
|
|
60
64
|
end # Refresh
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
class DummyRenderer
|
6
|
+
def self.render
|
7
|
+
:dummy
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class FooRenderer
|
12
|
+
def self.render
|
13
|
+
:foo
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe Renderers do
|
18
|
+
|
19
|
+
let(:described) { Vedeu::Renderers }
|
20
|
+
|
21
|
+
before { Vedeu::Renderers.reset }
|
22
|
+
after { Vedeu::Renderers.reset }
|
23
|
+
|
24
|
+
describe '.renderers' do
|
25
|
+
subject { described.renderers }
|
26
|
+
|
27
|
+
it { subject.must_be_instance_of(Module) }
|
28
|
+
|
29
|
+
# context 'API' do
|
30
|
+
# before { Vedeu::Renderers.renderer(*renderers) }
|
31
|
+
|
32
|
+
# subject { Vedeu.renderers.render }
|
33
|
+
|
34
|
+
# context 'when a single renderer is defined' do
|
35
|
+
# let(:renderers) { DummyRenderer }
|
36
|
+
|
37
|
+
# it { subject.must_equal([:dummy]) }
|
38
|
+
# end
|
39
|
+
|
40
|
+
# context 'when multiple renderers are defined' do
|
41
|
+
# let(:renderers) { [DummyRenderer, FooRenderer] }
|
42
|
+
|
43
|
+
# it { subject.must_equal([:dummy, :foo]) }
|
44
|
+
# end
|
45
|
+
|
46
|
+
# context 'when no renderers are defined' do
|
47
|
+
# let(:renderers) {}
|
48
|
+
|
49
|
+
# it { subject.must_equal([]) }
|
50
|
+
# end
|
51
|
+
# end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '.renderer' do
|
55
|
+
let(:renderers) {}
|
56
|
+
|
57
|
+
subject { described.renderer(*renderers) }
|
58
|
+
|
59
|
+
it { subject.must_be_instance_of(Set) }
|
60
|
+
|
61
|
+
context 'with a single renderer' do
|
62
|
+
let(:renderers) { DummyRenderer }
|
63
|
+
|
64
|
+
it { subject.size.must_equal(1) }
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'with multiple renderers' do
|
68
|
+
let(:renderers) { [DummyRenderer, FooRenderer] }
|
69
|
+
|
70
|
+
it { subject.size.must_equal(2) }
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'with no renderer' do
|
74
|
+
let(:renderers) {}
|
75
|
+
|
76
|
+
it { subject.size.must_equal(0) }
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe '.reset' do
|
81
|
+
subject { described.reset }
|
82
|
+
|
83
|
+
it { subject.must_be_instance_of(Set) }
|
84
|
+
it { subject.size.must_equal(0) }
|
85
|
+
end
|
86
|
+
|
87
|
+
describe '.storage' do
|
88
|
+
subject { described.storage }
|
89
|
+
|
90
|
+
it { subject.must_be_instance_of(Set) }
|
91
|
+
it { subject.size.must_equal(0) }
|
92
|
+
end
|
93
|
+
|
94
|
+
end # Renderers
|
95
|
+
|
96
|
+
end # Vedeu
|
@@ -27,7 +27,7 @@ module Vedeu
|
|
27
27
|
context 'when a path is given' do
|
28
28
|
let(:path) { '/tmp/test_vedeu_html_renderer.html' }
|
29
29
|
|
30
|
-
#it { subject.must_equal('') }
|
30
|
+
# it { subject.must_equal('') }
|
31
31
|
end
|
32
32
|
|
33
33
|
context 'when a path is not given' do
|
@@ -48,20 +48,24 @@ module Vedeu
|
|
48
48
|
let(:output) {
|
49
49
|
[
|
50
50
|
[
|
51
|
-
Vedeu::Char.new(
|
52
|
-
Vedeu::Char.new(
|
53
|
-
Vedeu::Char.new(
|
54
|
-
Vedeu::Char.new(
|
51
|
+
Vedeu::Char.new(value: 't'),
|
52
|
+
Vedeu::Char.new(value: 'e'),
|
53
|
+
Vedeu::Char.new(value: 's'),
|
54
|
+
Vedeu::Char.new(value: 't'),
|
55
55
|
]
|
56
56
|
]
|
57
57
|
}
|
58
58
|
|
59
59
|
it { subject.must_equal(
|
60
60
|
"<tr>\n" \
|
61
|
-
"<td style='background:#000;color:#222;border:1px #000 solid;'>
|
62
|
-
"
|
63
|
-
|
64
|
-
"
|
61
|
+
"<td style='background:#000;color:#222;border:1px #000 solid;'>" \
|
62
|
+
"t</td>\n" \
|
63
|
+
"<td style='background:#000;color:#222;border:1px #000 solid;'>" \
|
64
|
+
"e</td>\n" \
|
65
|
+
"<td style='background:#000;color:#222;border:1px #000 solid;'>" \
|
66
|
+
"s</td>\n" \
|
67
|
+
"<td style='background:#000;color:#222;border:1px #000 solid;'>" \
|
68
|
+
"t</td>\n" \
|
65
69
|
"</tr>\n") }
|
66
70
|
end
|
67
71
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe JSONRenderer do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::JSONRenderer }
|
8
|
+
let(:instance) { described.new(output) }
|
9
|
+
let(:output) {}
|
10
|
+
|
11
|
+
describe '#initialize' do
|
12
|
+
it { instance.must_be_instance_of(Vedeu::JSONRenderer) }
|
13
|
+
it { instance.instance_variable_get('@output').must_equal(output) }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '.render' do
|
17
|
+
subject { described.render(output) }
|
18
|
+
|
19
|
+
it { subject.must_be_instance_of(String) }
|
20
|
+
|
21
|
+
context 'when the output is empty' do
|
22
|
+
it { subject.must_equal('') }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when the output is not empty' do
|
26
|
+
let(:colour) {
|
27
|
+
Vedeu::Colour.new(foreground: '#ff0000', background: '#ffffff')
|
28
|
+
}
|
29
|
+
let(:output) {
|
30
|
+
[
|
31
|
+
[
|
32
|
+
Vedeu::Char.new(value: 'a',
|
33
|
+
colour: colour,
|
34
|
+
position: Vedeu::Position[5, 3])
|
35
|
+
]
|
36
|
+
]
|
37
|
+
}
|
38
|
+
it { subject.must_equal(
|
39
|
+
"{\"border\":\"\",\"colour\":{\"" \
|
40
|
+
"background\":\"\\u001b[48;2;255;255;255m\"," \
|
41
|
+
"\"foreground\":\"\\u001b[38;2;255;0;0m\"}," \
|
42
|
+
"\"parent\":{\"" \
|
43
|
+
"background\":\"\",\"foreground\":\"\",\"style\":\"\"}," \
|
44
|
+
"\"position\":{\"y\":5,\"x\":3},\"style\":\"\"," \
|
45
|
+
"\"value\":\"a\"}\n\n"
|
46
|
+
) }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end # JSONRenderer
|
51
|
+
|
52
|
+
end # Vedeu
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe NullRenderer do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::NullRenderer }
|
8
|
+
|
9
|
+
describe '.render' do
|
10
|
+
let(:args) {}
|
11
|
+
|
12
|
+
subject { described.render(*args) }
|
13
|
+
|
14
|
+
it { subject.must_be_instance_of(NilClass) }
|
15
|
+
end
|
16
|
+
|
17
|
+
end # NullRenderer
|
18
|
+
|
19
|
+
end # Vedeu
|