vedeu 0.0.25 → 0.0.26
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/README.md +10 -9
- data/Rakefile +0 -10
- data/bin/composition +1 -1
- data/examples/single_interface_app.rb +7 -4
- data/lib/vedeu.rb +19 -48
- data/lib/vedeu/application.rb +8 -7
- data/lib/vedeu/configuration.rb +4 -4
- data/lib/vedeu/input/input.rb +3 -0
- data/lib/vedeu/launcher.rb +3 -0
- data/lib/vedeu/models/background.rb +13 -0
- data/lib/vedeu/models/coercions.rb +21 -0
- data/lib/vedeu/models/colour.rb +22 -0
- data/lib/vedeu/{repository → models}/command.rb +2 -0
- data/lib/vedeu/models/composition.rb +30 -0
- data/lib/vedeu/models/foreground.rb +13 -0
- data/lib/vedeu/models/interface.rb +62 -0
- data/lib/vedeu/models/interface_collection.rb +24 -0
- data/lib/vedeu/models/line.rb +22 -0
- data/lib/vedeu/models/line_collection.rb +27 -0
- data/lib/vedeu/models/presentation.rb +13 -0
- data/lib/vedeu/models/stream.rb +21 -0
- data/lib/vedeu/models/stream_collection.rb +27 -0
- data/lib/vedeu/models/style_collection.rb +23 -0
- data/lib/vedeu/output/interface_renderer.rb +62 -0
- data/lib/vedeu/output/output.rb +6 -5
- data/lib/vedeu/process/process.rb +15 -31
- data/lib/vedeu/repository/command_repository.rb +13 -14
- data/lib/vedeu/repository/interface_repository.rb +12 -13
- data/lib/vedeu/repository/repository.rb +2 -0
- data/lib/vedeu/{output → support}/cursor.rb +2 -0
- data/lib/vedeu/support/esc.rb +112 -0
- data/lib/vedeu/support/events.rb +21 -0
- data/lib/vedeu/support/geometry.rb +66 -0
- data/lib/vedeu/support/parser.rb +27 -0
- data/lib/vedeu/support/terminal.rb +31 -134
- data/lib/vedeu/{output → support}/translator.rb +12 -8
- data/lib/vedeu/{output → support}/wordwrap.rb +2 -4
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/application_test.rb +7 -2
- data/test/lib/vedeu/configuration_test.rb +13 -8
- data/test/lib/vedeu/input/input_test.rb +2 -1
- data/test/lib/vedeu/launcher_test.rb +7 -2
- data/test/lib/vedeu/models/background_test.rb +35 -0
- data/test/lib/vedeu/models/colour_test.rb +71 -0
- data/test/lib/vedeu/models/command_test.rb +109 -0
- data/test/lib/vedeu/models/composition_test.rb +187 -0
- data/test/lib/vedeu/models/foreground_test.rb +35 -0
- data/test/lib/vedeu/models/interface_collection_test.rb +57 -0
- data/test/lib/vedeu/models/interface_test.rb +220 -0
- data/test/lib/vedeu/models/line_collection_test.rb +69 -0
- data/test/lib/vedeu/models/line_test.rb +76 -0
- data/test/lib/vedeu/models/presentation_test.rb +8 -0
- data/test/lib/vedeu/models/stream_collection_test.rb +57 -0
- data/test/lib/vedeu/models/stream_test.rb +76 -0
- data/test/lib/vedeu/models/style_collection_test.rb +22 -0
- data/test/lib/vedeu/output/interface_renderer_test.rb +12 -0
- data/test/lib/vedeu/output/output_test.rb +15 -30
- data/test/lib/vedeu/process/process_test.rb +22 -44
- data/test/lib/vedeu/repository/command_repository_test.rb +22 -16
- data/test/lib/vedeu/repository/interface_repository_test.rb +62 -14
- data/test/lib/vedeu/repository/repository_test.rb +1 -0
- data/test/lib/vedeu/repository/storage_test.rb +13 -6
- data/test/lib/vedeu/{output → support}/cursor_test.rb +1 -0
- data/test/lib/vedeu/support/esc_test.rb +348 -0
- data/test/lib/vedeu/support/events_test.rb +37 -0
- data/test/lib/vedeu/support/exit_test.rb +1 -0
- data/test/lib/vedeu/support/geometry_test.rb +131 -0
- data/test/lib/vedeu/support/parser_test.rb +56 -0
- data/test/lib/vedeu/support/queue_test.rb +1 -0
- data/test/lib/vedeu/support/terminal_test.rb +1 -119
- data/test/lib/vedeu/{output → support}/translator_test.rb +17 -12
- data/test/lib/vedeu/{output → support}/wordwrap_test.rb +1 -0
- data/test/lib/vedeu/version_test.rb +1 -0
- data/test/lib/vedeu_test.rb +1 -0
- data/{lib/vedeu/repository → test/support}/dummy_command.rb +0 -0
- data/{lib/vedeu/repository → test/support}/dummy_interface.rb +0 -0
- data/test/support/json/int1_lin1_str1.json +10 -0
- data/test/support/json/int1_lin1_str3.json +18 -0
- data/test/support/json/int1_lin2_str1.json +17 -0
- data/test/support/json/int1_lin2_str3.json +33 -0
- data/test/support/json/int1_lin2_str3_styles.json +43 -0
- data/test/support/json/int2_lin1_str1.json +20 -0
- data/test/support/json/int2_lin1_str3.json +36 -0
- data/test/support/json/int2_lin2_str1.json +34 -0
- data/test/support/json/int2_lin2_str3.json +66 -0
- data/test/support/json/int2_lin2_str3_styles.json +158 -0
- data/test/support/output_1.json +9 -0
- data/test/support/output_1.rb +14 -0
- data/test/support/output_2.json +1 -0
- data/test/support/output_2.rb +19 -0
- data/test/test_helper.rb +0 -2
- data/vedeu.gemspec +0 -3
- metadata +98 -150
- data/config/cucumber.yml +0 -8
- data/documentation/composition.ebnf +0 -7
- data/documentation/diagram/ColourDirective.png +0 -0
- data/documentation/diagram/Directive.png +0 -0
- data/documentation/diagram/Interface.png +0 -0
- data/documentation/diagram/Output.png +0 -0
- data/documentation/diagram/PositionDirective.png +0 -0
- data/documentation/diagram/Stream.png +0 -0
- data/documentation/diagram/StyleDirective.png +0 -0
- data/documentation/diagram/rr-1.35.837.png +0 -0
- data/documentation/index.html +0 -325
- data/features/getting_started.feature +0 -10
- data/features/step_definitions/vedeu_steps.rb +0 -11
- data/features/support/env.rb +0 -12
- data/lib/vedeu/output/background.rb +0 -27
- data/lib/vedeu/output/base.rb +0 -57
- data/lib/vedeu/output/buffer/composition.rb +0 -24
- data/lib/vedeu/output/buffer/formatting.rb +0 -25
- data/lib/vedeu/output/buffer/interface.rb +0 -14
- data/lib/vedeu/output/buffer/line.rb +0 -14
- data/lib/vedeu/output/buffer/stream.rb +0 -14
- data/lib/vedeu/output/buffer/style.rb +0 -11
- data/lib/vedeu/output/colour.rb +0 -39
- data/lib/vedeu/output/compositor.rb +0 -72
- data/lib/vedeu/output/directive.rb +0 -63
- data/lib/vedeu/output/esc.rb +0 -61
- data/lib/vedeu/output/foreground.rb +0 -27
- data/lib/vedeu/output/geometry.rb +0 -71
- data/lib/vedeu/output/layer.rb +0 -9
- data/lib/vedeu/output/menu.rb +0 -26
- data/lib/vedeu/output/position.rb +0 -35
- data/lib/vedeu/output/style.rb +0 -38
- data/lib/vedeu/repository/interface.rb +0 -62
- data/lib/vedeu/support/json_parser.rb +0 -25
- data/lib/vedeu/support/options.rb +0 -4
- data/test/lib/vedeu/output/background_test.rb +0 -67
- data/test/lib/vedeu/output/base_test.rb +0 -8
- data/test/lib/vedeu/output/buffer/composition_test.rb +0 -57
- data/test/lib/vedeu/output/buffer/formatting_test.rb +0 -9
- data/test/lib/vedeu/output/buffer/interface_test.rb +0 -38
- data/test/lib/vedeu/output/buffer/line_test.rb +0 -64
- data/test/lib/vedeu/output/buffer/stream_test.rb +0 -61
- data/test/lib/vedeu/output/buffer/style_test.rb +0 -8
- data/test/lib/vedeu/output/colour_test.rb +0 -104
- data/test/lib/vedeu/output/compositor_test.rb +0 -247
- data/test/lib/vedeu/output/directive_test.rb +0 -82
- data/test/lib/vedeu/output/esc_test.rb +0 -175
- data/test/lib/vedeu/output/foreground_test.rb +0 -67
- data/test/lib/vedeu/output/geometry_test.rb +0 -190
- data/test/lib/vedeu/output/layer_test.rb +0 -35
- data/test/lib/vedeu/output/menu_test.rb +0 -13
- data/test/lib/vedeu/output/position_test.rb +0 -48
- data/test/lib/vedeu/output/style_test.rb +0 -132
- data/test/lib/vedeu/repository/command_test.rb +0 -73
- data/test/lib/vedeu/repository/dummy_command_test.rb +0 -27
- data/test/lib/vedeu/repository/dummy_interface_test.rb +0 -7
- data/test/lib/vedeu/repository/interface_test.rb +0 -79
- data/test/lib/vedeu/support/json_parser_test.rb +0 -45
- data/test/support/composition.json +0 -47
- data/test/support/composition.rb +0 -5
- data/test/support/composition.xml +0 -36
- data/test/support/multi_interface.json +0 -34
- data/test/support/single_interface.json +0 -19
@@ -1,38 +0,0 @@
|
|
1
|
-
require_relative '../../../../test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
module Buffer
|
5
|
-
describe Interface do
|
6
|
-
let(:described_class) { Interface }
|
7
|
-
let(:described_instance) { described_class.new(attributes) }
|
8
|
-
let(:subject) { described_instance }
|
9
|
-
let(:attributes) { { name: 'dummy', line: [] } }
|
10
|
-
|
11
|
-
it 'returns a Interface instance' do
|
12
|
-
subject.must_be_instance_of(Interface)
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'has a name attribute' do
|
16
|
-
subject.name.must_be_instance_of(String)
|
17
|
-
|
18
|
-
subject.name.must_equal('dummy')
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'has a line attribute' do
|
22
|
-
subject.line.must_be_instance_of(Array)
|
23
|
-
|
24
|
-
subject.line.must_equal([])
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '#to_compositor' do
|
28
|
-
let(:subject) { described_instance.to_compositor }
|
29
|
-
|
30
|
-
it 'returns an Array' do
|
31
|
-
subject.must_be_instance_of(Array)
|
32
|
-
|
33
|
-
subject.must_equal([])
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
require_relative '../../../../test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
module Buffer
|
5
|
-
describe Line do
|
6
|
-
let(:described_class) { Line }
|
7
|
-
let(:described_instance) { described_class.new(attributes) }
|
8
|
-
let(:subject) { described_instance }
|
9
|
-
let(:attributes) {
|
10
|
-
{
|
11
|
-
style: 'normal',
|
12
|
-
foreground: :red,
|
13
|
-
background: :black,
|
14
|
-
stream: []
|
15
|
-
}
|
16
|
-
}
|
17
|
-
|
18
|
-
it 'returns a Line instance' do
|
19
|
-
subject.must_be_instance_of(Line)
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'has a style attribute' do
|
23
|
-
subject.style.must_be_instance_of(Array)
|
24
|
-
|
25
|
-
subject.style.must_equal([:normal])
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'has a foreground attribute' do
|
29
|
-
subject.foreground.must_be_instance_of(Symbol)
|
30
|
-
|
31
|
-
subject.foreground.must_equal(:red)
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'has a background attribute' do
|
35
|
-
subject.background.must_be_instance_of(Symbol)
|
36
|
-
|
37
|
-
subject.background.must_equal(:black)
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'has a stream attribute' do
|
41
|
-
subject.stream.must_be_instance_of(Array)
|
42
|
-
|
43
|
-
subject.stream.must_equal([])
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '#to_compositor' do
|
47
|
-
let(:subject) { described_instance.to_compositor }
|
48
|
-
|
49
|
-
it 'returns an Array' do
|
50
|
-
subject.must_be_instance_of(Array)
|
51
|
-
|
52
|
-
subject.must_equal(
|
53
|
-
[
|
54
|
-
{
|
55
|
-
style: [:normal],
|
56
|
-
colour: [:red, :black]
|
57
|
-
}
|
58
|
-
]
|
59
|
-
)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
require_relative '../../../../test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
module Buffer
|
5
|
-
describe Stream do
|
6
|
-
let(:described_class) { Stream }
|
7
|
-
let(:described_instance) { described_class.new(attributes) }
|
8
|
-
let(:subject) { described_instance }
|
9
|
-
let(:attributes) {
|
10
|
-
{
|
11
|
-
style: 'normal',
|
12
|
-
foreground: :red,
|
13
|
-
background: :black,
|
14
|
-
text: 'Some text'
|
15
|
-
}
|
16
|
-
}
|
17
|
-
|
18
|
-
it 'returns a Stream instance' do
|
19
|
-
subject.must_be_instance_of(Stream)
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'has a foreground attribute' do
|
23
|
-
subject.foreground.must_be_instance_of(Symbol)
|
24
|
-
|
25
|
-
subject.foreground.must_equal(:red)
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'has a background attribute' do
|
29
|
-
subject.background.must_be_instance_of(Symbol)
|
30
|
-
|
31
|
-
subject.background.must_equal(:black)
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'has a text attribute' do
|
35
|
-
subject.text.must_be_instance_of(String)
|
36
|
-
|
37
|
-
subject.text.must_equal('Some text')
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'has a style attribute' do
|
41
|
-
subject.style.must_be_instance_of(Array)
|
42
|
-
|
43
|
-
subject.style.must_equal([:normal])
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '#to_compositor' do
|
47
|
-
let(:subject) { described_instance.to_compositor }
|
48
|
-
|
49
|
-
it 'returns a Hash' do
|
50
|
-
subject.must_be_instance_of(Hash)
|
51
|
-
|
52
|
-
subject.must_equal({
|
53
|
-
style: [:normal],
|
54
|
-
colour: [:red, :black],
|
55
|
-
text: "Some text"
|
56
|
-
})
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,104 +0,0 @@
|
|
1
|
-
require_relative '../../../test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
describe Colour do
|
5
|
-
let(:described_class) { Colour }
|
6
|
-
let(:described_instance) { described_class.new }
|
7
|
-
let(:subject) { described_instance }
|
8
|
-
let(:pair) { [] }
|
9
|
-
|
10
|
-
it 'returns a Colour instance' do
|
11
|
-
subject.must_be_instance_of(Colour)
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'sets an instance variable' do
|
15
|
-
subject.instance_variable_get('@pair').must_equal([])
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '.set' do
|
19
|
-
let(:subject) { described_class.set(pair) }
|
20
|
-
|
21
|
-
it 'returns a String' do
|
22
|
-
subject.must_be_instance_of(String)
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'when the foreground and background are specified as symbols' do
|
26
|
-
context 'when both the foreground and background is specified' do
|
27
|
-
let(:pair) { [:red, :yellow] }
|
28
|
-
|
29
|
-
it 'returns the code for red on yellow' do
|
30
|
-
subject.must_equal("\e[38;2;31m\e[48;2;43m")
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'when a foreground is specified' do
|
35
|
-
let(:pair) { [:blue] }
|
36
|
-
|
37
|
-
it 'returns the code for blue on default' do
|
38
|
-
subject.must_equal("\e[38;2;34m\e[48;2;49m")
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'when a background is specified' do
|
43
|
-
let(:pair) { [nil, :cyan] }
|
44
|
-
|
45
|
-
it 'returns the code for default with cyan background' do
|
46
|
-
subject.must_equal("\e[38;2;39m\e[48;2;46m")
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context 'when an invalid foreground/background is specified' do
|
51
|
-
let(:pair) { [:melon, :raspberry] }
|
52
|
-
|
53
|
-
it 'returns the default code' do
|
54
|
-
subject.must_equal("\e[38;2;39m\e[48;2;49m")
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'when no foreground/background is specified' do
|
59
|
-
let(:pair) { [] }
|
60
|
-
|
61
|
-
it 'return an empty string' do
|
62
|
-
subject.must_equal('')
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
context 'when the foreground and background are specified as strings' do
|
68
|
-
let(:pair) { ['#ff0000', '#0000ff'] }
|
69
|
-
|
70
|
-
it 'returns the default code' do
|
71
|
-
subject.must_equal("\e[38;5;196m\e[48;5;21m")
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
describe '.reset' do
|
77
|
-
let(:subject) { described_class.reset }
|
78
|
-
|
79
|
-
it 'returns a String' do
|
80
|
-
subject.must_be_instance_of(String)
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'returns an escape sequence' do
|
84
|
-
subject.must_equal("\e[38;2;39m\e[48;2;49m")
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe '#foreground' do
|
89
|
-
let(:subject) { described_instance.foreground }
|
90
|
-
|
91
|
-
it 'returns a String' do
|
92
|
-
subject.must_be_instance_of(String)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
describe '#background' do
|
97
|
-
let(:subject) { described_instance.background }
|
98
|
-
|
99
|
-
it 'returns a String' do
|
100
|
-
subject.must_be_instance_of(String)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
@@ -1,247 +0,0 @@
|
|
1
|
-
require_relative '../../../test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
describe Compositor do
|
5
|
-
let(:described_class) { Compositor }
|
6
|
-
let(:described_instance) { described_class.new(attributes) }
|
7
|
-
let(:subject) { described_instance }
|
8
|
-
let(:attributes) { { interface: 'dummy', stream: stream } }
|
9
|
-
let(:stream) { [[]] }
|
10
|
-
let(:composition) {}
|
11
|
-
|
12
|
-
before do
|
13
|
-
InterfaceRepository.create({ name: 'dummy', width: 15, height: 2 })
|
14
|
-
end
|
15
|
-
|
16
|
-
after do
|
17
|
-
InterfaceRepository.reset
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'returns a Compositor instance' do
|
21
|
-
subject.must_be_instance_of(Compositor)
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'sets an instance variable' do
|
25
|
-
subject.instance_variable_get('@attributes').must_equal(attributes)
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'sets an instance variable' do
|
29
|
-
subject.instance_variable_get('@interface').must_equal(attributes[:interface])
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'sets an instance variable' do
|
33
|
-
subject.instance_variable_get('@stream').must_equal(attributes[:stream])
|
34
|
-
end
|
35
|
-
|
36
|
-
describe '#arrange' do
|
37
|
-
let(:subject) { described_class.new(attributes).arrange }
|
38
|
-
|
39
|
-
context 'when empty' do
|
40
|
-
let(:stream) { [[]] }
|
41
|
-
let(:composition) {
|
42
|
-
[
|
43
|
-
[
|
44
|
-
"\e[38;2;39m\e[48;2;49m\e[1;1H \e[1;1H\e[38;2;39m\e[48;2;49m\e[?25h",
|
45
|
-
"\e[38;2;39m\e[48;2;49m\e[2;1H \e[2;1H\e[38;2;39m\e[48;2;49m\e[?25h"
|
46
|
-
]
|
47
|
-
]
|
48
|
-
}
|
49
|
-
|
50
|
-
it 'returns the initial state of the interface' do
|
51
|
-
subject.must_equal(composition)
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'returns an Array' do
|
55
|
-
subject.must_be_instance_of(Array)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'when unstyled' do
|
60
|
-
context 'and a single line' do
|
61
|
-
let(:stream) { [[{ text: 'Some text...' }]] }
|
62
|
-
let(:composition) {
|
63
|
-
[
|
64
|
-
[
|
65
|
-
"\e[38;2;39m\e[48;2;49m\e[1;1H \e[1;1HSome text...\e[38;2;39m\e[48;2;49m\e[?25h",
|
66
|
-
"\e[38;2;39m\e[48;2;49m\e[2;1H \e[2;1H\e[38;2;39m\e[48;2;49m\e[?25h"
|
67
|
-
]
|
68
|
-
]
|
69
|
-
}
|
70
|
-
|
71
|
-
it 'returns the enqueued composition' do
|
72
|
-
subject.must_equal(composition)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
context 'and multi-line' do
|
77
|
-
let(:stream) {
|
78
|
-
[
|
79
|
-
[{ text: 'Some text...' }],
|
80
|
-
[{ text: 'Some more text...' }]
|
81
|
-
]
|
82
|
-
}
|
83
|
-
let(:composition) {
|
84
|
-
[
|
85
|
-
[
|
86
|
-
"\e[38;2;39m\e[48;2;49m\e[1;1H \e[1;1HSome text...\e[38;2;39m\e[48;2;49m\e[?25h",
|
87
|
-
"\e[38;2;39m\e[48;2;49m\e[2;1H \e[2;1HSome more tex...\e[38;2;39m\e[48;2;49m\e[?25h"
|
88
|
-
]
|
89
|
-
]
|
90
|
-
}
|
91
|
-
|
92
|
-
it 'returns the enqueued composition' do
|
93
|
-
subject.must_equal(composition)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
context 'but is a string containing new-lines' do
|
98
|
-
let(:stream) { [[{ text: "Some text...\nSome more text..." }]] }
|
99
|
-
let(:composition) {
|
100
|
-
[
|
101
|
-
[
|
102
|
-
"\e[38;2;39m\e[48;2;49m\e[1;1H \e[1;1HSome text...
|
103
|
-
...\e[38;2;39m\e[48;2;49m\e[?25h",
|
104
|
-
"\e[38;2;39m\e[48;2;49m\e[2;1H \e[2;1H\e[38;2;39m\e[48;2;49m\e[?25h"
|
105
|
-
]
|
106
|
-
]
|
107
|
-
}
|
108
|
-
|
109
|
-
it 'returns the enqueued composition' do
|
110
|
-
skip # The newline in the composition is not the desired behaviour. Wordwrap is the culprit.
|
111
|
-
subject.must_equal(composition)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
context 'when styled' do
|
117
|
-
context 'with colour pair' do
|
118
|
-
context 'and a single line' do
|
119
|
-
let(:stream) {
|
120
|
-
[
|
121
|
-
[{ colour: [:red, :white], text: 'Some text...' }, { colour: :default }]
|
122
|
-
]
|
123
|
-
}
|
124
|
-
let(:composition) {
|
125
|
-
[
|
126
|
-
[
|
127
|
-
"\e[38;2;39m\e[48;2;49m\e[1;1H \e[1;1H\e[38;2;31m\e[48;2;47mSome text...\e[38;5;39m\e[48;5;49m\e[38;2;39m\e[48;2;49m\e[?25h",
|
128
|
-
"\e[38;2;39m\e[48;2;49m\e[2;1H \e[2;1H\e[38;2;39m\e[48;2;49m\e[?25h"
|
129
|
-
]
|
130
|
-
]
|
131
|
-
}
|
132
|
-
|
133
|
-
it 'returns the enqueued composition' do
|
134
|
-
subject.must_equal(composition)
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
context 'and multi-line' do
|
139
|
-
let(:stream) {
|
140
|
-
[
|
141
|
-
[{ colour: [:red, :white], text: 'Some text...' }],
|
142
|
-
[{ colour: [:blue, :yellow], text: 'Some more text...' }]
|
143
|
-
]
|
144
|
-
}
|
145
|
-
let(:composition) {
|
146
|
-
[
|
147
|
-
[
|
148
|
-
"\e[38;2;39m\e[48;2;49m\e[1;1H \e[1;1H\e[38;2;31m\e[48;2;47mSome text...\e[38;2;39m\e[48;2;49m\e[?25h",
|
149
|
-
"\e[38;2;39m\e[48;2;49m\e[2;1H \e[2;1H\e[38;2;34m\e[48;2;43mSome more tex...\e[38;2;39m\e[48;2;49m\e[?25h"
|
150
|
-
]
|
151
|
-
]
|
152
|
-
}
|
153
|
-
|
154
|
-
it 'returns the enqueued composition' do
|
155
|
-
subject.must_equal(composition)
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
context 'with a style' do
|
161
|
-
context 'and a single line' do
|
162
|
-
let(:stream) {
|
163
|
-
[
|
164
|
-
[{ style: :bold, text: 'Some text...' }, { style: :bold_off }]
|
165
|
-
]
|
166
|
-
}
|
167
|
-
let(:composition) {
|
168
|
-
[
|
169
|
-
[
|
170
|
-
"\e[38;2;39m\e[48;2;49m\e[1;1H \e[1;1H\e[1mSome text...\e[21m\e[38;2;39m\e[48;2;49m\e[?25h",
|
171
|
-
"\e[38;2;39m\e[48;2;49m\e[2;1H \e[2;1H\e[38;2;39m\e[48;2;49m\e[?25h"
|
172
|
-
]
|
173
|
-
]
|
174
|
-
}
|
175
|
-
|
176
|
-
it 'returns the enqueued composition' do
|
177
|
-
subject.must_equal(composition)
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
context 'and multi-line' do
|
182
|
-
let(:stream) {
|
183
|
-
[
|
184
|
-
[{ style: :negative, text: 'Some text...' }],
|
185
|
-
[{ style: :underline, text: 'Some more text...' }]
|
186
|
-
]
|
187
|
-
}
|
188
|
-
let(:composition) {
|
189
|
-
[
|
190
|
-
[
|
191
|
-
"\e[38;2;39m\e[48;2;49m\e[1;1H \e[1;1H\e[7mSome text...\e[38;2;39m\e[48;2;49m\e[?25h",
|
192
|
-
"\e[38;2;39m\e[48;2;49m\e[2;1H \e[2;1H\e[4mSome more tex...\e[38;2;39m\e[48;2;49m\e[?25h"
|
193
|
-
]
|
194
|
-
]
|
195
|
-
}
|
196
|
-
|
197
|
-
it 'returns the enqueued composition' do
|
198
|
-
subject.must_equal(composition)
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
context 'with an unknown style' do
|
204
|
-
let(:stream) {
|
205
|
-
[
|
206
|
-
[{ style: :unknown, text: 'Some text...' }]
|
207
|
-
]
|
208
|
-
}
|
209
|
-
let(:composition) {
|
210
|
-
[
|
211
|
-
[
|
212
|
-
"\e[38;2;39m\e[48;2;49m\e[1;1H \e[1;1HSome text...\e[38;2;39m\e[48;2;49m\e[?25h",
|
213
|
-
"\e[38;2;39m\e[48;2;49m\e[2;1H \e[2;1H\e[38;2;39m\e[48;2;49m\e[?25h"
|
214
|
-
]
|
215
|
-
]
|
216
|
-
}
|
217
|
-
|
218
|
-
it 'returns the enqueued composition' do
|
219
|
-
subject.must_equal(composition)
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
context 'with a complicated stream' do
|
224
|
-
let(:stream) {
|
225
|
-
[
|
226
|
-
[{:style=>[:normal], :colour=>[:red, :black]}, {:style=>[:underline, :negative], :colour=>[:yellow, :black], :text=>"Some text..."}, {:style=>[:normal], :colour=>[:green, :black], :text=>"Some more text..."}],
|
227
|
-
[{:style=>[], :colour=>[]}, {:style=>[], :colour=>[], :text=>"Even more text..."}]
|
228
|
-
]
|
229
|
-
}
|
230
|
-
|
231
|
-
let(:composition) {
|
232
|
-
[
|
233
|
-
[
|
234
|
-
"\e[38;2;39m\e[48;2;49m\e[1;1H \e[1;1H\e[38;2;31m\e[48;2;40m\e[24m\e[21m\e[27m\e[38;2;33m\e[48;2;40m\e[4m\e[7mSome text...\e[38;2;32m\e[48;2;40m\e[24m\e[21m\e[27mSome more tex...\e[38;2;39m\e[48;2;49m\e[?25h",
|
235
|
-
"\e[38;2;39m\e[48;2;49m\e[2;1H \e[2;1HEven more tex...\e[38;2;39m\e[48;2;49m\e[?25h"
|
236
|
-
]
|
237
|
-
]
|
238
|
-
}
|
239
|
-
|
240
|
-
it 'returns the enqueued composition' do
|
241
|
-
subject.must_equal(composition)
|
242
|
-
end
|
243
|
-
end
|
244
|
-
end
|
245
|
-
end
|
246
|
-
end
|
247
|
-
end
|