vedeu 0.4.18 → 0.4.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/Rakefile +1 -0
- data/bin/vedeu_drb_server +0 -1
- data/bin/vedeu_test +0 -1
- data/config/rubocop_enabled.yml +1 -1
- data/examples/borders_app.rb +0 -1
- data/examples/colours_app.rb +0 -1
- data/examples/cursor_app.rb +0 -1
- data/examples/drb_app.rb +0 -1
- data/examples/geometry_app.rb +0 -1
- data/examples/hello_world.rb +0 -1
- data/examples/lines_app.rb +0 -1
- data/examples/material_colours_app.rb +0 -1
- data/examples/typed_commands/typed_commands_app.rb +0 -1
- data/examples/view_templates_app/view_templates_app.rb +0 -1
- data/lib/vedeu/api.rb +2 -1
- data/lib/vedeu/application.rb +3 -2
- data/lib/vedeu/bindings.rb +3 -5
- data/lib/vedeu/buffers/buffer.rb +8 -11
- data/lib/vedeu/buffers/display_buffer.rb +0 -2
- data/lib/vedeu/configuration/api.rb +1 -4
- data/lib/vedeu/configuration/cli.rb +153 -74
- data/lib/vedeu/configuration/configuration.rb +1 -2
- data/lib/vedeu/cursor/cursor.rb +0 -4
- data/lib/vedeu/cursor/move.rb +3 -6
- data/lib/vedeu/cursor/refresh_cursor.rb +12 -2
- data/lib/vedeu/distributed/client.rb +3 -2
- data/lib/vedeu/distributed/server.rb +4 -3
- data/lib/vedeu/distributed/subprocess.rb +3 -4
- data/lib/vedeu/distributed/test_application.rb +0 -1
- data/lib/vedeu/distributed/uri.rb +0 -1
- data/lib/vedeu/dsl/components/border.rb +3 -4
- data/lib/vedeu/dsl/components/geometry.rb +1 -5
- data/lib/vedeu/dsl/components/keymap.rb +1 -3
- data/lib/vedeu/dsl/components/menu.rb +1 -2
- data/lib/vedeu/dsl/composition.rb +3 -4
- data/lib/vedeu/dsl/group.rb +1 -4
- data/lib/vedeu/dsl/interface.rb +3 -10
- data/lib/vedeu/dsl/line.rb +3 -4
- data/lib/vedeu/dsl/shared/text.rb +0 -3
- data/lib/vedeu/dsl/stream.rb +3 -4
- data/lib/vedeu/dsl/view.rb +0 -3
- data/lib/vedeu/events/event.rb +3 -3
- data/lib/vedeu/events/trigger.rb +3 -2
- data/lib/vedeu/geometry/area.rb +0 -1
- data/lib/vedeu/geometry/canvas.rb +0 -1
- data/lib/vedeu/geometry/coordinate.rb +6 -7
- data/lib/vedeu/geometry/dimension.rb +3 -2
- data/lib/vedeu/geometry/geometry.rb +0 -6
- data/lib/vedeu/geometry/grid.rb +3 -2
- data/lib/vedeu/geometry/index_position.rb +0 -1
- data/lib/vedeu/geometry/position.rb +0 -1
- data/lib/vedeu/geometry/position_index.rb +0 -1
- data/lib/vedeu/geometry/position_validator.rb +6 -68
- data/lib/vedeu/input/all.rb +0 -2
- data/lib/vedeu/input/input.rb +3 -2
- data/lib/vedeu/input/key.rb +0 -1
- data/lib/vedeu/input/keymap.rb +4 -7
- data/lib/vedeu/input/mapper.rb +3 -2
- data/lib/vedeu/launcher.rb +3 -2
- data/lib/vedeu/main_loop.rb +1 -1
- data/lib/vedeu/models/cell.rb +0 -1
- data/lib/vedeu/models/char.rb +0 -1
- data/lib/vedeu/models/composition.rb +1 -7
- data/lib/vedeu/models/group.rb +0 -3
- data/lib/vedeu/models/interface.rb +0 -3
- data/lib/vedeu/models/line.rb +0 -4
- data/lib/vedeu/models/menu.rb +5 -8
- data/lib/vedeu/models/stream.rb +0 -4
- data/lib/vedeu/null/all.rb +11 -0
- data/lib/vedeu/null/border.rb +3 -1
- data/lib/vedeu/null/buffer.rb +0 -1
- data/lib/vedeu/null/generic.rb +4 -1
- data/lib/vedeu/null/geometry.rb +0 -1
- data/lib/vedeu/null/interface.rb +36 -7
- data/lib/vedeu/output/background.rb +0 -1
- data/lib/vedeu/output/border.rb +1 -6
- data/lib/vedeu/output/clear.rb +3 -2
- data/lib/vedeu/output/colour.rb +6 -18
- data/lib/vedeu/output/compressor.rb +5 -2
- data/lib/vedeu/output/esc.rb +4 -1
- data/lib/vedeu/output/foreground.rb +0 -5
- data/lib/vedeu/output/html_char.rb +3 -2
- data/lib/vedeu/output/output.rb +1 -5
- data/lib/vedeu/output/refresh.rb +1 -1
- data/lib/vedeu/output/renderers/all.rb +0 -1
- data/lib/vedeu/output/renderers/escape_sequence.rb +3 -2
- data/lib/vedeu/output/renderers/file.rb +85 -80
- data/lib/vedeu/output/renderers/html.rb +77 -72
- data/lib/vedeu/output/renderers/json.rb +45 -42
- data/lib/vedeu/output/renderers/null.rb +11 -8
- data/lib/vedeu/output/renderers/terminal.rb +41 -36
- data/lib/vedeu/output/renderers/text.rb +41 -36
- data/lib/vedeu/output/style.rb +0 -3
- data/lib/vedeu/output/text.rb +3 -2
- data/lib/vedeu/output/viewport.rb +3 -2
- data/lib/vedeu/output/virtual_terminal.rb +0 -1
- data/lib/vedeu/output/wordwrap.rb +3 -2
- data/lib/vedeu/repositories/all.rb +7 -6
- data/lib/vedeu/repositories/collection.rb +0 -1
- data/lib/vedeu/repositories/collections/chars.rb +0 -1
- data/lib/vedeu/repositories/collections/events.rb +0 -1
- data/lib/vedeu/repositories/collections/interfaces.rb +0 -1
- data/lib/vedeu/repositories/collections/keys.rb +0 -1
- data/lib/vedeu/repositories/collections/lines.rb +0 -1
- data/lib/vedeu/repositories/collections/streams.rb +0 -1
- data/lib/vedeu/repositories/model.rb +0 -1
- data/lib/vedeu/repositories/registerable.rb +29 -0
- data/lib/vedeu/repositories/repositories/background_colours.rb +0 -1
- data/lib/vedeu/repositories/repositories/borders.rb +2 -13
- data/lib/vedeu/repositories/repositories/buffers.rb +2 -13
- data/lib/vedeu/repositories/repositories/colours.rb +0 -1
- data/lib/vedeu/repositories/repositories/cursors.rb +1 -2
- data/lib/vedeu/repositories/repositories/events_repository.rb +0 -1
- data/lib/vedeu/repositories/repositories/foreground_colours.rb +0 -1
- data/lib/vedeu/repositories/repositories/geometries.rb +2 -13
- data/lib/vedeu/repositories/repositories/groups.rb +1 -2
- data/lib/vedeu/repositories/repositories/interfaces_repository.rb +2 -14
- data/lib/vedeu/repositories/repositories/keymaps.rb +1 -2
- data/lib/vedeu/repositories/repositories/menus.rb +1 -2
- data/lib/vedeu/repositories/repository.rb +14 -5
- data/lib/vedeu/storage/all.rb +0 -1
- data/lib/vedeu/storage/associative_store.rb +0 -1
- data/lib/vedeu/storage/conveyor_store.rb +0 -1
- data/lib/vedeu/storage/fifo_store.rb +0 -1
- data/lib/vedeu/support/log.rb +0 -3
- data/lib/vedeu/support/options.rb +3 -2
- data/lib/vedeu/support/template.rb +3 -4
- data/lib/vedeu/support/terminal.rb +0 -2
- data/lib/vedeu/support/trace.rb +6 -7
- data/lib/vedeu/support/visibility.rb +1 -2
- data/lib/vedeu.rb +3 -5
- data/test/lib/vedeu/buffers/buffer_test.rb +48 -13
- data/test/lib/vedeu/configuration/cli_test.rb +5 -4
- data/test/lib/vedeu/cursor/refresh_cursor_test.rb +37 -15
- data/test/lib/vedeu/distributed/subprocess_test.rb +1 -0
- data/test/lib/vedeu/dsl/shared/use_test.rb +1 -6
- data/test/lib/vedeu/main_loop_test.rb +11 -0
- data/test/lib/vedeu/null/interface_test.rb +27 -0
- data/test/lib/vedeu/output/output_test.rb +17 -10
- data/test/lib/vedeu/output/presentation_test.rb +35 -7
- data/test/lib/vedeu/output/renderers/escape_sequence_test.rb +50 -0
- data/test/lib/vedeu/output/renderers/file_test.rb +34 -30
- data/test/lib/vedeu/output/renderers/html_test.rb +61 -57
- data/test/lib/vedeu/output/renderers/json_test.rb +40 -36
- data/test/lib/vedeu/output/renderers/null_test.rb +12 -8
- data/test/lib/vedeu/output/renderers/terminal_test.rb +17 -13
- data/test/lib/vedeu/output/renderers/text_test.rb +17 -13
- data/test/lib/vedeu/repositories/model_test.rb +1 -1
- data/test/lib/vedeu/repositories/registerable_test.rb +28 -0
- data/test/lib/vedeu/storage/associative_store_test.rb +7 -0
- data/test/lib/vedeu/storage/conveyor_store_test.rb +7 -0
- data/test/lib/vedeu/storage/fifo_store_test.rb +7 -0
- data/test/support/helpers/model_test_class.rb +6 -2
- data/test/test_helper.rb +2 -0
- data/vedeu.gemspec +3 -2
- metadata +23 -6
- data/test/lib/vedeu/output/renderers/escape_sequence_renderer_test.rb +0 -46
@@ -4,22 +4,26 @@ module Vedeu
|
|
4
4
|
|
5
5
|
describe Buffer do
|
6
6
|
|
7
|
-
let(:described)
|
8
|
-
let(:instance)
|
9
|
-
let(:attributes)
|
7
|
+
let(:described) { Vedeu::Buffer }
|
8
|
+
let(:instance) { described.new(attributes) }
|
9
|
+
let(:attributes) {
|
10
10
|
{
|
11
|
-
name:
|
12
|
-
back:
|
13
|
-
front:
|
14
|
-
previous:
|
11
|
+
name: _name,
|
12
|
+
back: back,
|
13
|
+
front: front,
|
14
|
+
previous: previous,
|
15
15
|
}
|
16
16
|
}
|
17
|
-
let(:_name)
|
18
|
-
let(:back)
|
19
|
-
let(:front)
|
20
|
-
let(:previous)
|
21
|
-
|
22
|
-
|
17
|
+
let(:_name) { 'krypton' }
|
18
|
+
let(:back) {}
|
19
|
+
let(:front) {}
|
20
|
+
let(:previous) {}
|
21
|
+
let(:interface) {}
|
22
|
+
|
23
|
+
before do
|
24
|
+
Vedeu.stubs(:trigger)
|
25
|
+
# Vedeu.interfaces.stubs(:by_name).returns(interface)
|
26
|
+
end
|
23
27
|
|
24
28
|
describe '#initialize' do
|
25
29
|
it { instance.must_be_instance_of(described) }
|
@@ -61,6 +65,37 @@ module Vedeu
|
|
61
65
|
end
|
62
66
|
end
|
63
67
|
|
68
|
+
describe '#clear' do
|
69
|
+
subject { instance.clear }
|
70
|
+
|
71
|
+
context 'when the clear buffer is empty' do
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'when the clear buffer is not empty' do
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#hide' do
|
79
|
+
subject { instance.hide }
|
80
|
+
|
81
|
+
context 'when the interface is visible' do
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'when the interface is not visible' do
|
85
|
+
it { subject.must_be_instance_of(NilClass) }
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe '#show' do
|
90
|
+
subject { instance.show }
|
91
|
+
|
92
|
+
context 'when the interface is visible' do
|
93
|
+
end
|
94
|
+
|
95
|
+
context 'when the interface is not visible' do
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
64
99
|
# describe '#render' do
|
65
100
|
# before { Vedeu::Output.stubs(:render) }
|
66
101
|
|
@@ -6,16 +6,17 @@ module Vedeu
|
|
6
6
|
|
7
7
|
describe CLI do
|
8
8
|
|
9
|
-
let(:described) { CLI
|
9
|
+
let(:described) { Vedeu::Config::CLI }
|
10
|
+
let(:instance) { described.new(args) }
|
10
11
|
let(:args) { [] }
|
11
12
|
|
12
13
|
before { Configuration.reset! }
|
13
14
|
after { test_configuration }
|
14
15
|
|
15
16
|
describe '#initialize' do
|
16
|
-
it {
|
17
|
-
it {
|
18
|
-
it {
|
17
|
+
it { instance.must_be_instance_of(described) }
|
18
|
+
it { instance.instance_variable_get('@args').must_equal(args) }
|
19
|
+
it { instance.instance_variable_get('@options').must_equal({}) }
|
19
20
|
end
|
20
21
|
|
21
22
|
describe '#colour_mode' do
|
@@ -7,9 +7,20 @@ module Vedeu
|
|
7
7
|
let(:described) { Vedeu::RefreshCursor }
|
8
8
|
let(:instance) { described.new(_name) }
|
9
9
|
let(:_name) { 'refresh_cursor' }
|
10
|
+
let(:expected) {}
|
11
|
+
let(:ox) { 0 }
|
12
|
+
let(:oy) { 0 }
|
10
13
|
|
11
14
|
before do
|
12
|
-
Vedeu
|
15
|
+
Vedeu.geometry 'refresh_cursor' do
|
16
|
+
x 1
|
17
|
+
xn 3
|
18
|
+
y 1
|
19
|
+
yn 3
|
20
|
+
end
|
21
|
+
Vedeu::Cursor.new({ name: 'refresh_cursor', ox: ox, oy: oy }).store
|
22
|
+
|
23
|
+
Vedeu::Terminal.stubs(:output).returns(expected)
|
13
24
|
end
|
14
25
|
|
15
26
|
describe '#initialize' do
|
@@ -17,20 +28,31 @@ module Vedeu
|
|
17
28
|
it { instance.instance_variable_get('@name').must_equal(_name) }
|
18
29
|
end
|
19
30
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
describe '.render' do
|
32
|
+
subject { described.render(_name) }
|
33
|
+
|
34
|
+
it 'renders the cursor in the terminal' do
|
35
|
+
Vedeu::Terminal.expects(:output).with("\e[1;1H\e[?25l")
|
36
|
+
subject
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'when the cursors offset position is outside the viewable area' do
|
40
|
+
let(:ox) { 3 }
|
41
|
+
let(:oy) { 3 }
|
42
|
+
|
43
|
+
it 'refreshes the view' do
|
44
|
+
Vedeu::Refresh.expects(:by_name)
|
45
|
+
subject
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when the cursors offset position is inside the viewable area' do
|
50
|
+
it 'does not refresh the view' do
|
51
|
+
Vedeu::Refresh.expects(:by_name).never
|
52
|
+
subject
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
34
56
|
|
35
57
|
end # RefreshCursor
|
36
58
|
|
@@ -24,13 +24,8 @@ module Vedeu
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
describe '
|
27
|
+
describe '#use' do
|
28
28
|
context 'when the model exists' do
|
29
|
-
context 'and the attribute exists' do
|
30
|
-
end
|
31
|
-
|
32
|
-
context 'but the attribute does not exist' do
|
33
|
-
end
|
34
29
|
end
|
35
30
|
|
36
31
|
context 'when the model does not exist' do
|
@@ -19,6 +19,17 @@ module Vedeu
|
|
19
19
|
it { subject; described.instance_variable_get('@loop').must_equal(false) }
|
20
20
|
end
|
21
21
|
|
22
|
+
describe '.safe_exit_point!' do
|
23
|
+
subject { described.safe_exit_point! }
|
24
|
+
|
25
|
+
context 'when the application has started' do
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'when the application has not started' do
|
29
|
+
it { Vedeu.expects(:trigger); subject }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
22
33
|
end # MainLoop
|
23
34
|
|
24
35
|
end # Vedeu
|
@@ -6,6 +6,33 @@ module Vedeu
|
|
6
6
|
|
7
7
|
describe Interface do
|
8
8
|
|
9
|
+
let(:described) { Vedeu::Null::Interface }
|
10
|
+
let(:instance) { described.new(_name) }
|
11
|
+
let(:_name) {}
|
12
|
+
|
13
|
+
describe '#initialize' do
|
14
|
+
it { instance.must_be_instance_of(Vedeu::Null::Interface) }
|
15
|
+
it { instance.instance_variable_get('@name').must_equal(_name) }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#attributes' do
|
19
|
+
subject { instance.attributes }
|
20
|
+
|
21
|
+
it { subject.must_be_instance_of(Hash) }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#store' do
|
25
|
+
subject { instance.store }
|
26
|
+
|
27
|
+
it { subject.must_be_instance_of(Vedeu::Null::Interface) }
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#visible?' do
|
31
|
+
subject { instance.visible? }
|
32
|
+
|
33
|
+
it { subject.must_be_instance_of(FalseClass) }
|
34
|
+
end
|
35
|
+
|
9
36
|
end # Interface
|
10
37
|
|
11
38
|
end # Null
|
@@ -24,16 +24,23 @@ module Vedeu
|
|
24
24
|
subject { described.render(content) }
|
25
25
|
|
26
26
|
context 'when DRb is enabled' do
|
27
|
-
let(:drb)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
27
|
+
let(:drb) { true }
|
28
|
+
let(:virtual_buffer) { [] }
|
29
|
+
|
30
|
+
before do
|
31
|
+
Vedeu::Renderers::HTML.stubs(:to_file)
|
32
|
+
Vedeu::VirtualBuffer.stubs(:retrieve).returns(virtual_buffer)
|
33
|
+
end
|
34
|
+
|
35
|
+
it {
|
36
|
+
Vedeu.expects(:trigger).with(:_drb_store_output_, content)
|
37
|
+
subject
|
38
|
+
}
|
39
|
+
|
40
|
+
it 'writes the virtual buffer to a file' do
|
41
|
+
Vedeu::Renderers::HTML.expects(:to_file).with(virtual_buffer)
|
42
|
+
subject
|
43
|
+
end
|
37
44
|
end
|
38
45
|
|
39
46
|
it { Vedeu.renderers.expects(:render).with(content); subject }
|
@@ -20,40 +20,68 @@ module Vedeu
|
|
20
20
|
class PresentationTestClass
|
21
21
|
include Presentation
|
22
22
|
|
23
|
+
attr_reader :attributes
|
24
|
+
|
25
|
+
def initialize(attributes = {})
|
26
|
+
@attributes = attributes
|
27
|
+
end
|
28
|
+
|
23
29
|
def parent
|
24
30
|
ParentPresentationTestClass.new
|
25
31
|
end
|
26
32
|
|
27
|
-
def attributes
|
28
|
-
{
|
29
|
-
colour: { background: '#000033', foreground: '#aadd00' },
|
30
|
-
style: ['bold']
|
31
|
-
}
|
32
|
-
end
|
33
33
|
end # PresentationTestClass
|
34
34
|
|
35
35
|
describe Presentation do
|
36
36
|
|
37
|
-
let(:receiver) { PresentationTestClass.new }
|
37
|
+
let(:receiver) { PresentationTestClass.new(attributes) }
|
38
|
+
let(:attributes) {
|
39
|
+
{
|
40
|
+
colour: { background: background, foreground: foreground },
|
41
|
+
style: ['bold']
|
42
|
+
}
|
43
|
+
}
|
44
|
+
let(:background) { '#000033' }
|
45
|
+
let(:foreground) { '#aadd00' }
|
38
46
|
|
39
47
|
describe '#background' do
|
40
48
|
subject { receiver.background }
|
41
49
|
|
42
50
|
it { subject.must_be_instance_of(Vedeu::Background) }
|
51
|
+
it { subject.colour.must_equal('#000033') }
|
52
|
+
|
53
|
+
context 'no background value' do
|
54
|
+
let(:background) {}
|
55
|
+
|
56
|
+
it { subject.must_be_instance_of(Vedeu::Background) }
|
57
|
+
it { subject.colour.must_equal('') }
|
58
|
+
end
|
43
59
|
end
|
44
60
|
|
45
61
|
describe '#foreground' do
|
46
62
|
subject { receiver.foreground }
|
47
63
|
|
48
64
|
it { subject.must_be_instance_of(Vedeu::Foreground) }
|
65
|
+
it { subject.colour.must_equal('#aadd00') }
|
66
|
+
|
67
|
+
context 'no foreground value' do
|
68
|
+
let(:foreground) {}
|
69
|
+
|
70
|
+
it { subject.must_be_instance_of(Vedeu::Foreground) }
|
71
|
+
it { subject.colour.must_equal('') }
|
72
|
+
end
|
49
73
|
end
|
50
74
|
|
51
75
|
describe '#parent_background' do
|
52
76
|
subject { receiver.parent_background }
|
77
|
+
|
78
|
+
it { subject.must_be_instance_of(Vedeu::Background) }
|
53
79
|
end
|
54
80
|
|
55
81
|
describe '#parent_foreground' do
|
56
82
|
subject { receiver.parent_foreground }
|
83
|
+
|
84
|
+
it { subject.must_be_instance_of(Vedeu::Foreground) }
|
57
85
|
end
|
58
86
|
|
59
87
|
describe '#colour' do
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Renderers
|
6
|
+
|
7
|
+
describe EscapeSequence do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Renderers::EscapeSequence }
|
10
|
+
let(:instance) { described.new(output) }
|
11
|
+
let(:output) {}
|
12
|
+
|
13
|
+
describe '#initialize' do
|
14
|
+
it { instance.must_be_instance_of(described) }
|
15
|
+
it { instance.instance_variable_get('@output').must_equal(output) }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.render' do
|
19
|
+
subject { described.render(output) }
|
20
|
+
|
21
|
+
it { subject.must_be_instance_of(String) }
|
22
|
+
|
23
|
+
context 'when there is no output' do
|
24
|
+
it { subject.must_equal('') }
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when there is output' do
|
28
|
+
let(:output) {
|
29
|
+
[
|
30
|
+
Vedeu::Char.new(value: 't', colour: { background: '#ff0000', foreground: '#ffffff' }),
|
31
|
+
Vedeu::Char.new(value: 'e', colour: { background: '#ffff00', foreground: '#000000' }),
|
32
|
+
Vedeu::Char.new(value: 's', colour: { background: '#00ff00', foreground: '#000000' }),
|
33
|
+
Vedeu::Char.new(value: 't', colour: { background: '#00ffff', foreground: '#000000' }),
|
34
|
+
]
|
35
|
+
}
|
36
|
+
|
37
|
+
it { subject.must_equal(
|
38
|
+
"\\e[38;2;255;255;255m\\e[48;2;255;0;0mt\n" \
|
39
|
+
"\\e[38;2;0;0;0m\\e[48;2;255;255;0me\n" \
|
40
|
+
"\\e[38;2;0;0;0m\\e[48;2;0;255;0ms\n" \
|
41
|
+
"\\e[38;2;0;0;0m\\e[48;2;0;255;255mt\n")
|
42
|
+
}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end # EscapeSequence
|
47
|
+
|
48
|
+
end # Renderers
|
49
|
+
|
50
|
+
end # Vedeu
|
@@ -2,46 +2,50 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
{
|
12
|
-
|
5
|
+
module Renderers
|
6
|
+
|
7
|
+
describe File do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Renderers::File }
|
10
|
+
let(:instance) { described.new(output, options) }
|
11
|
+
let(:output) {}
|
12
|
+
let(:options) {
|
13
|
+
{
|
14
|
+
timestamp: timestamp
|
15
|
+
}
|
13
16
|
}
|
14
|
-
|
15
|
-
|
17
|
+
let(:timestamp) { true }
|
18
|
+
|
19
|
+
describe '#initialize' do
|
20
|
+
it { instance.must_be_instance_of(described) }
|
21
|
+
it { instance.instance_variable_get('@output').must_equal(output) }
|
22
|
+
it { instance.instance_variable_get('@options').must_equal(options) }
|
23
|
+
end
|
16
24
|
|
17
|
-
|
18
|
-
|
19
|
-
it { instance.instance_variable_get('@output').must_equal(output) }
|
20
|
-
it { instance.instance_variable_get('@options').must_equal(options) }
|
21
|
-
end
|
25
|
+
describe '.render' do
|
26
|
+
let(:_time) { Time.new(2015, 4, 12, 20, 05) }
|
22
27
|
|
23
|
-
|
24
|
-
let(:_time) { Time.new(2015, 4, 12, 20, 05) }
|
28
|
+
before { File.stubs(:open) }
|
25
29
|
|
26
|
-
|
30
|
+
subject { described.render(output, options) }
|
27
31
|
|
28
|
-
|
32
|
+
it { subject.must_be_instance_of(String) }
|
29
33
|
|
30
|
-
|
34
|
+
# context 'when the timestamp option is true' do
|
35
|
+
# before { Time.stubs(:now).returns(_time) }
|
31
36
|
|
32
|
-
|
33
|
-
|
37
|
+
# it { File.expects(:open).with('/tmp/out_1428865500.0', 'w'); subject }
|
38
|
+
# end
|
34
39
|
|
35
|
-
|
36
|
-
|
40
|
+
# context 'when the timestamp option is false' do
|
41
|
+
# let(:timestamp) { false }
|
37
42
|
|
38
|
-
|
39
|
-
|
43
|
+
# it { File.expects(:open).with('/tmp/out', 'w'); subject }
|
44
|
+
# end
|
45
|
+
end
|
40
46
|
|
41
|
-
|
42
|
-
# end
|
43
|
-
end
|
47
|
+
end # File
|
44
48
|
|
45
|
-
end # Renderers
|
49
|
+
end # Renderers
|
46
50
|
|
47
51
|
end # Vedeu
|
@@ -2,85 +2,89 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
|
5
|
+
module Renderers
|
6
6
|
|
7
|
-
|
8
|
-
let(:instance) { described.new(output) }
|
9
|
-
let(:output) {}
|
7
|
+
describe HTML do
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
9
|
+
let(:described) { Vedeu::Renderers::HTML }
|
10
|
+
let(:instance) { described.new(output) }
|
11
|
+
let(:output) {}
|
15
12
|
|
16
|
-
|
17
|
-
|
13
|
+
describe '#initialize' do
|
14
|
+
it { instance.must_be_instance_of(described) }
|
15
|
+
it { instance.instance_variable_get('@output').must_equal(output) }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.render' do
|
19
|
+
before { ::File.stubs(:open) }
|
18
20
|
|
19
|
-
|
21
|
+
subject { described.render(output) }
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
+
it { subject.must_be_instance_of(String) }
|
24
|
+
end
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
+
describe '.to_file' do
|
27
|
+
before { ::File.stubs(:open) }
|
26
28
|
|
27
|
-
|
29
|
+
subject { described.to_file(output, path) }
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
+
context 'when a path is given' do
|
32
|
+
let(:path) { '/tmp/test_vedeu_html_renderer.html' }
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
it do
|
35
|
+
::File.expects(:open)
|
36
|
+
subject
|
37
|
+
end
|
35
38
|
end
|
36
|
-
end
|
37
39
|
|
38
|
-
|
39
|
-
|
40
|
-
|
40
|
+
context 'when a path is not given' do
|
41
|
+
let(:path) {}
|
42
|
+
let(:_time) { Time.new(2015, 4, 12, 16, 55) }
|
41
43
|
|
42
|
-
|
44
|
+
before { Time.stubs(:now).returns(_time) }
|
43
45
|
|
44
|
-
|
45
|
-
|
46
|
-
|
46
|
+
it do
|
47
|
+
::File.expects(:open)#.with('/tmp/vedeu_html_1428854100.html', 'w')
|
48
|
+
subject
|
49
|
+
end
|
47
50
|
end
|
48
51
|
end
|
49
|
-
end
|
50
52
|
|
51
|
-
|
52
|
-
|
53
|
+
describe '#html_body' do
|
54
|
+
subject { instance.html_body }
|
53
55
|
|
54
|
-
|
56
|
+
it { subject.must_be_instance_of(String) }
|
55
57
|
|
56
|
-
|
58
|
+
it { subject.must_equal('') }
|
57
59
|
|
58
|
-
|
59
|
-
|
60
|
-
[
|
60
|
+
context 'when there is output' do
|
61
|
+
let(:output) {
|
61
62
|
[
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
[
|
64
|
+
Vedeu::Char.new(value: 't'),
|
65
|
+
Vedeu::Char.new(value: 'e'),
|
66
|
+
Vedeu::Char.new(value: 's'),
|
67
|
+
Vedeu::Char.new(value: 't'),
|
68
|
+
]
|
66
69
|
]
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
"
|
75
|
-
|
76
|
-
"
|
77
|
-
|
78
|
-
"
|
79
|
-
|
80
|
-
|
70
|
+
}
|
71
|
+
|
72
|
+
it { subject.must_equal(
|
73
|
+
"<tr>\n" \
|
74
|
+
"<td style='background:#000;color:#222;border:1px #000 solid;'>" \
|
75
|
+
"t</td>\n" \
|
76
|
+
"<td style='background:#000;color:#222;border:1px #000 solid;'>" \
|
77
|
+
"e</td>\n" \
|
78
|
+
"<td style='background:#000;color:#222;border:1px #000 solid;'>" \
|
79
|
+
"s</td>\n" \
|
80
|
+
"<td style='background:#000;color:#222;border:1px #000 solid;'>" \
|
81
|
+
"t</td>\n" \
|
82
|
+
"</tr>\n") }
|
83
|
+
end
|
81
84
|
end
|
82
|
-
end
|
83
85
|
|
84
|
-
|
86
|
+
end # HTML
|
87
|
+
|
88
|
+
end # Renderers
|
85
89
|
|
86
90
|
end # Vedeu
|