vedeu 0.0.30 → 0.0.31
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/Rakefile +4 -4
- data/lib/vedeu/configuration.rb +2 -2
- data/lib/vedeu/launcher.rb +2 -2
- data/lib/vedeu/models/command.rb +1 -1
- data/lib/vedeu/models/interface.rb +4 -0
- data/lib/vedeu/output/interface_renderer.rb +1 -1
- data/lib/vedeu/output/template.rb +23 -0
- data/lib/vedeu/output/text_adaptor.rb +1 -1
- data/lib/vedeu/process/process.rb +5 -1
- data/lib/vedeu/repository/command_repository.rb +3 -5
- data/lib/vedeu/repository/event_repository.rb +27 -0
- data/lib/vedeu/repository/interface_repository.rb +8 -6
- data/lib/vedeu/repository/storage.rb +2 -0
- data/lib/vedeu/support/esc.rb +2 -1
- data/lib/vedeu/support/geometry.rb +11 -23
- data/lib/vedeu/support/parser.rb +1 -1
- data/lib/vedeu/support/queue.rb +3 -1
- data/lib/vedeu.rb +18 -1
- data/test/example_app/bin/app +9 -0
- data/test/example_app/lib/app.rb +63 -0
- data/test/lib/vedeu/application_test.rb +6 -36
- data/test/lib/vedeu/configuration_test.rb +5 -31
- data/test/lib/vedeu/input/input_test.rb +4 -16
- data/test/lib/vedeu/launcher_test.rb +6 -15
- data/test/lib/vedeu/models/background_test.rb +5 -21
- data/test/lib/vedeu/models/colour_test.rb +18 -49
- data/test/lib/vedeu/models/command_test.rb +19 -83
- data/test/lib/vedeu/models/composition_test.rb +78 -175
- data/test/lib/vedeu/models/foreground_test.rb +4 -21
- data/test/lib/vedeu/models/interface_collection_test.rb +13 -45
- data/test/lib/vedeu/models/interface_test.rb +71 -195
- data/test/lib/vedeu/models/line_collection_test.rb +13 -52
- data/test/lib/vedeu/models/line_test.rb +17 -61
- data/test/lib/vedeu/models/presentation_test.rb +6 -19
- data/test/lib/vedeu/models/stream_collection_test.rb +10 -42
- data/test/lib/vedeu/models/stream_test.rb +16 -54
- data/test/lib/vedeu/models/style_collection_test.rb +1 -10
- data/test/lib/vedeu/output/interface_renderer_test.rb +7 -38
- data/test/lib/vedeu/output/output_test.rb +1 -18
- data/test/lib/vedeu/output/template.rb +20 -0
- data/test/lib/vedeu/output/text_adaptor_test.rb +9 -46
- data/test/lib/vedeu/process/process_test.rb +36 -38
- data/test/lib/vedeu/repository/command_repository_test.rb +16 -45
- data/test/lib/vedeu/repository/interface_repository_test.rb +36 -74
- data/test/lib/vedeu/repository/repository_test.rb +9 -33
- data/test/lib/vedeu/repository/storage_test.rb +7 -42
- data/test/lib/vedeu/support/esc_test.rb +46 -130
- data/test/lib/vedeu/support/event_repository_test.rb +31 -0
- data/test/lib/vedeu/support/exit_test.rb +1 -9
- data/test/lib/vedeu/support/geometry_test.rb +81 -105
- data/test/lib/vedeu/support/parser_test.rb +10 -54
- data/test/lib/vedeu/support/parsing/hash_parser_test.rb +18 -33
- data/test/lib/vedeu/support/parsing/json_parser_test.rb +4 -23
- data/test/lib/vedeu/support/queue_test.rb +33 -57
- data/test/lib/vedeu/support/terminal_test.rb +21 -52
- data/test/lib/vedeu/support/translator_test.rb +16 -33
- data/test/lib/vedeu/support/wordwrap_test.rb +29 -46
- data/test/lib/vedeu_test.rb +3 -5
- data/test/support/template.erb +3 -0
- data/test/test_helper.rb +1 -12
- data/vedeu.gemspec +8 -10
- metadata +26 -38
- data/lib/vedeu/support/events.rb +0 -21
- data/lib/vedeu/version.rb +0 -3
- data/test/lib/vedeu/support/events_test.rb +0 -45
- data/test/lib/vedeu/version_test.rb +0 -12
- data/test/support/output_1.json +0 -9
- data/test/support/output_1.rb +0 -14
|
@@ -4,31 +4,15 @@ require_relative '../../../../lib/vedeu/models/colour'
|
|
|
4
4
|
|
|
5
5
|
module Vedeu
|
|
6
6
|
describe Background do
|
|
7
|
-
let(:described_class) { Background }
|
|
8
|
-
let(:described_instance) { Vedeu::Colour.new(attributes) }
|
|
9
|
-
let(:attributes) {
|
|
10
|
-
{
|
|
11
|
-
background: '#00ff00'
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
7
|
describe '#background' do
|
|
16
|
-
let(:subject) { described_instance.background }
|
|
17
|
-
|
|
18
|
-
it 'returns a String' do
|
|
19
|
-
subject.must_be_instance_of(String)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
8
|
it 'returns an escape sequence' do
|
|
23
|
-
|
|
9
|
+
Colour.new({
|
|
10
|
+
background: '#00ff00'
|
|
11
|
+
}).background.must_equal("\e[48;5;46m")
|
|
24
12
|
end
|
|
25
13
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
it 'returns an escape sequence' do
|
|
30
|
-
subject.must_equal('')
|
|
31
|
-
end
|
|
14
|
+
it 'returns an empty string when the foreground is missing' do
|
|
15
|
+
Colour.new.background.must_equal('')
|
|
32
16
|
end
|
|
33
17
|
end
|
|
34
18
|
end
|
|
@@ -3,68 +3,37 @@ require_relative '../../../../lib/vedeu/models/colour'
|
|
|
3
3
|
|
|
4
4
|
module Vedeu
|
|
5
5
|
describe Colour do
|
|
6
|
-
let(:described_class) { Colour }
|
|
7
|
-
let(:described_instance) { described_class.new(attributes) }
|
|
8
|
-
let(:attributes) {
|
|
9
|
-
{
|
|
10
|
-
foreground: '#ff0000',
|
|
11
|
-
background: '#000000'
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
describe '#initialize' do
|
|
16
|
-
let(:subject) { described_instance }
|
|
17
|
-
|
|
18
|
-
it 'returns a Colour instance' do
|
|
19
|
-
subject.must_be_instance_of(Colour)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
6
|
describe '#to_json' do
|
|
24
|
-
let(:subject) { described_instance.to_json }
|
|
25
|
-
|
|
26
|
-
it 'returns a String' do
|
|
27
|
-
subject.must_be_instance_of(String)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
7
|
it 'returns the model as JSON' do
|
|
31
|
-
|
|
8
|
+
Colour.new({
|
|
9
|
+
foreground: '#ff0000',
|
|
10
|
+
background: '#000000'
|
|
11
|
+
}).to_json.must_equal("{\"foreground\":\"\\u001b[38;5;196m\",\"background\":\"\\u001b[48;5;16m\"}")
|
|
32
12
|
end
|
|
33
13
|
end
|
|
34
14
|
|
|
35
15
|
describe '#to_s' do
|
|
36
|
-
let(:subject) { described_instance.to_s }
|
|
37
|
-
|
|
38
|
-
it 'returns a String' do
|
|
39
|
-
subject.must_be_instance_of(String)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
16
|
it 'returns an escape sequence' do
|
|
43
|
-
|
|
17
|
+
Colour.new({
|
|
18
|
+
foreground: '#ff0000',
|
|
19
|
+
background: '#000000'
|
|
20
|
+
}).to_s.must_equal("\e[38;5;196m\e[48;5;16m")
|
|
44
21
|
end
|
|
45
22
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
subject.must_equal("\e[48;5;16m")
|
|
51
|
-
end
|
|
23
|
+
it 'returns an escape sequence when the foreground is missing' do
|
|
24
|
+
Colour.new({
|
|
25
|
+
background: '#000000'
|
|
26
|
+
}).to_s.must_equal("\e[48;5;16m")
|
|
52
27
|
end
|
|
53
28
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
subject.must_equal("\e[38;5;196m")
|
|
59
|
-
end
|
|
29
|
+
it 'returns an escape sequence when the background is missing' do
|
|
30
|
+
Colour.new({
|
|
31
|
+
foreground: '#ff0000',
|
|
32
|
+
}).to_s.must_equal("\e[38;5;196m")
|
|
60
33
|
end
|
|
61
34
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
it 'returns an empty string' do
|
|
66
|
-
subject.must_equal('')
|
|
67
|
-
end
|
|
35
|
+
it 'returns an empty string when both are missing' do
|
|
36
|
+
Colour.new.to_s.must_equal('')
|
|
68
37
|
end
|
|
69
38
|
end
|
|
70
39
|
end
|
|
@@ -4,105 +4,41 @@ require_relative '../../../../lib/vedeu/models/command'
|
|
|
4
4
|
|
|
5
5
|
module Vedeu
|
|
6
6
|
describe Command do
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
let(:subject) { described_instance }
|
|
10
|
-
let(:attributes) {
|
|
11
|
-
{
|
|
12
|
-
name: 'dummy',
|
|
13
|
-
entity: DummyCommand,
|
|
14
|
-
keyword: "dummy",
|
|
15
|
-
keypress: "d",
|
|
16
|
-
arguments: []
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
describe '#initialize' do
|
|
21
|
-
let(:subject) { described_instance }
|
|
22
|
-
|
|
23
|
-
it 'returns a Command instance' do
|
|
24
|
-
subject.must_be_instance_of(Command)
|
|
25
|
-
end
|
|
7
|
+
it 'has a name attribute' do
|
|
8
|
+
Command.new({ name: 'dummy' }).name.must_equal('dummy')
|
|
26
9
|
end
|
|
27
10
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
it 'returns a String' do
|
|
32
|
-
subject.must_be_instance_of(String)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it 'has a name attribute' do
|
|
36
|
-
subject.must_equal('dummy')
|
|
37
|
-
end
|
|
11
|
+
it 'has an entity attribute' do
|
|
12
|
+
Command.new({ entity: DummyCommand }).entity.must_equal(DummyCommand)
|
|
38
13
|
end
|
|
39
14
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
it 'returns a Class' do
|
|
44
|
-
subject.must_be_instance_of(Class)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it 'has an entity attribute' do
|
|
48
|
-
subject.must_equal(DummyCommand)
|
|
49
|
-
end
|
|
15
|
+
it 'has a keypress attribute' do
|
|
16
|
+
Command.new({ keypress: 'd' }).keypress.must_equal('d')
|
|
50
17
|
end
|
|
51
18
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
it 'returns a String' do
|
|
56
|
-
subject.must_be_instance_of(String)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it 'has a keypress attribute' do
|
|
60
|
-
subject.must_equal('d')
|
|
61
|
-
end
|
|
19
|
+
it 'has an keyword attribute' do
|
|
20
|
+
Command.new({ keyword: 'dummy' }).keyword.must_equal('dummy')
|
|
62
21
|
end
|
|
63
22
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
it 'returns a String' do
|
|
68
|
-
subject.must_be_instance_of(String)
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it 'has an keyword attribute' do
|
|
72
|
-
subject.must_equal('dummy')
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
describe '#arguments' do
|
|
77
|
-
let(:subject) { described_instance.arguments }
|
|
78
|
-
|
|
79
|
-
it 'returns a String' do
|
|
80
|
-
subject.must_be_instance_of(Array)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
it 'has an arguments attribute' do
|
|
84
|
-
subject.must_equal([])
|
|
85
|
-
end
|
|
23
|
+
it 'has an arguments attribute' do
|
|
24
|
+
Command.new({ arguments: [] }).arguments.must_equal([])
|
|
86
25
|
end
|
|
87
26
|
|
|
88
27
|
describe '#execute' do
|
|
89
|
-
let(:subject) { described_instance.execute(args) }
|
|
90
|
-
let(:args) { [] }
|
|
91
|
-
|
|
92
|
-
it 'returns a Symbol' do
|
|
93
|
-
subject.must_be_instance_of(Symbol)
|
|
94
|
-
end
|
|
95
|
-
|
|
96
28
|
it 'returns the result of execution' do
|
|
97
|
-
|
|
29
|
+
Command.new({
|
|
30
|
+
name: 'dummy',
|
|
31
|
+
entity: DummyCommand,
|
|
32
|
+
keyword: 'dummy',
|
|
33
|
+
keypress: 'd',
|
|
34
|
+
arguments: []
|
|
35
|
+
}).execute(:dummy).must_equal(:dummy)
|
|
98
36
|
end
|
|
99
37
|
end
|
|
100
38
|
|
|
101
39
|
describe '#executable' do
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
it 'returns a proc' do
|
|
105
|
-
subject.class.to_s.must_equal('Proc')
|
|
40
|
+
it 'needs a spec, please write one.' do
|
|
41
|
+
skip
|
|
106
42
|
end
|
|
107
43
|
end
|
|
108
44
|
end
|
|
@@ -4,231 +4,134 @@ require_relative '../../../../lib/vedeu/repository/interface_repository'
|
|
|
4
4
|
|
|
5
5
|
module Vedeu
|
|
6
6
|
describe Composition do
|
|
7
|
-
let(:described_class) { Composition }
|
|
8
|
-
let(:described_instance) { described_class.new(attributes) }
|
|
9
|
-
let(:attributes) { { interfaces: interfaces } }
|
|
10
|
-
let(:interfaces) {
|
|
11
|
-
{
|
|
12
|
-
name: 'dummy',
|
|
13
|
-
width: 40,
|
|
14
|
-
height: 25
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
describe '#initialize' do
|
|
19
|
-
let(:subject) { described_instance }
|
|
20
|
-
|
|
21
|
-
it 'returns a Composition instance' do
|
|
22
|
-
subject.must_be_instance_of(Composition)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it 'sets an instance variable' do
|
|
26
|
-
subject.instance_variable_get('@interfaces')
|
|
27
|
-
.must_be_instance_of(Array)
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
7
|
describe '#interfaces' do
|
|
32
|
-
let(:subject) { described_instance.interfaces }
|
|
33
|
-
|
|
34
|
-
it 'returns an Array' do
|
|
35
|
-
subject.must_be_instance_of(Array)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
8
|
it 'returns a collection of interfaces' do
|
|
39
|
-
|
|
9
|
+
Composition.new({
|
|
10
|
+
interfaces: {
|
|
11
|
+
name: 'dummy',
|
|
12
|
+
width: 40,
|
|
13
|
+
height: 25
|
|
14
|
+
}
|
|
15
|
+
}).interfaces.first.must_be_instance_of(Interface)
|
|
40
16
|
end
|
|
41
17
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
it 'returns an empty collection' do
|
|
46
|
-
subject.must_be_empty
|
|
47
|
-
end
|
|
18
|
+
it 'returns an empty collection when no interfaces are associated' do
|
|
19
|
+
Composition.new.interfaces.must_be_empty
|
|
48
20
|
end
|
|
49
21
|
end
|
|
50
22
|
|
|
51
23
|
describe '.enqueue' do
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
{
|
|
24
|
+
it 'returns a collection of interfaces' do
|
|
25
|
+
Composition.enqueue({
|
|
55
26
|
interfaces: [
|
|
56
|
-
{ name:
|
|
57
|
-
{ name:
|
|
27
|
+
{ name: 'enq1', lines: { streams: { text: 'Composition.enqueue 1' } } },
|
|
28
|
+
{ name: 'enq2', lines: { streams: { text: 'Composition.enqueue 2' } } }
|
|
58
29
|
]
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
before do
|
|
63
|
-
InterfaceRepository.create(name: 'enq1', width: 15, height: 2)
|
|
64
|
-
InterfaceRepository.create(name: 'enq2', width: 15, height: 2)
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
it 'returns an Composition' do
|
|
68
|
-
subject.must_be_instance_of(Composition)
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it 'returns a collection of interfaces' do
|
|
72
|
-
subject.interfaces.first.must_be_instance_of(Interface)
|
|
30
|
+
}).interfaces.first.must_be_instance_of(Interface)
|
|
73
31
|
end
|
|
74
32
|
|
|
75
33
|
it 'enqueues the interfaces for rendering' do
|
|
76
|
-
|
|
34
|
+
Composition.enqueue({
|
|
35
|
+
interfaces: [
|
|
36
|
+
{ name: 'enq1', lines: { streams: { text: 'Composition.enqueue 3' } } },
|
|
37
|
+
{ name: 'enq2', lines: { streams: { text: 'Composition.enqueue 4' } } }
|
|
38
|
+
]
|
|
39
|
+
}).interfaces.first.enqueued?.must_equal(true)
|
|
77
40
|
end
|
|
78
41
|
end
|
|
79
42
|
|
|
80
43
|
describe '#to_json' do
|
|
81
|
-
let(:subject) { described_instance.to_json }
|
|
82
|
-
|
|
83
|
-
it 'returns a String' do
|
|
84
|
-
subject.must_be_instance_of(String)
|
|
85
|
-
end
|
|
86
|
-
|
|
87
44
|
it 'returns the model as JSON' do
|
|
88
|
-
|
|
45
|
+
attributes = { interfaces: [{ name: 'Composition#to_json', width: 40, height: 25 }] }
|
|
46
|
+
|
|
47
|
+
Composition.new(attributes).to_json.must_equal("{\"interfaces\":[{\"colour\":null,\"style\":\"\",\"name\":\"Composition#to_json\",\"lines\":[],\"y\":1,\"x\":1,\"z\":1,\"width\":40,\"height\":25,\"current\":\"\",\"cursor\":true}]}")
|
|
89
48
|
end
|
|
90
49
|
end
|
|
91
50
|
|
|
92
51
|
describe '#to_s' do
|
|
93
|
-
|
|
52
|
+
it 'returns the stringified content for a single interface, single line, single stream' do
|
|
53
|
+
InterfaceRepository.create({ name: 'int1_lin1_str1', y: 3, x: 3, width: 10, height: 3 })
|
|
54
|
+
json = File.read('test/support/json/int1_lin1_str1.json')
|
|
55
|
+
attributes = Oj.load(json, symbol_keys: true)
|
|
94
56
|
|
|
95
|
-
|
|
96
|
-
subject.must_be_instance_of(String)
|
|
57
|
+
Composition.new(attributes).to_s.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text...")
|
|
97
58
|
end
|
|
98
59
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
before do
|
|
104
|
-
InterfaceRepository.create({ name: 'int1_lin1_str1', y: 3, x: 3, width: 10, height: 3 })
|
|
105
|
-
end
|
|
60
|
+
it 'returns the stringified content for a single interface, single line, multiple streams' do
|
|
61
|
+
InterfaceRepository.create({ name: 'int1_lin1_str3', y: 3, x: 3, width: 10, height: 3 })
|
|
62
|
+
json = File.read('test/support/json/int1_lin1_str3.json')
|
|
63
|
+
attributes = Oj.load(json, symbol_keys: true)
|
|
106
64
|
|
|
107
|
-
|
|
108
|
-
subject.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text...")
|
|
109
|
-
end
|
|
65
|
+
Composition.new(attributes).to_s.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text... more text...")
|
|
110
66
|
end
|
|
111
67
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
68
|
+
it 'returns the stringified content for a single interface, multiple lines, single stream' do
|
|
69
|
+
InterfaceRepository.create({ name: 'int1_lin2_str1', y: 3, x: 3, width: 10, height: 3 })
|
|
70
|
+
json = File.read('test/support/json/int1_lin2_str1.json')
|
|
71
|
+
attributes = Oj.load(json, symbol_keys: true)
|
|
115
72
|
|
|
116
|
-
|
|
117
|
-
InterfaceRepository.create({ name: 'int1_lin1_str3', y: 3, x: 3, width: 10, height: 3 })
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
it 'returns the stringified content' do
|
|
121
|
-
subject.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text... more text...")
|
|
122
|
-
end
|
|
73
|
+
Composition.new(attributes).to_s.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text...\e[4;3HSome text...")
|
|
123
74
|
end
|
|
124
75
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
before do
|
|
130
|
-
InterfaceRepository.create({ name: 'int1_lin2_str1', y: 3, x: 3, width: 10, height: 3 })
|
|
131
|
-
end
|
|
76
|
+
it 'returns the stringified content for a single interface, multiple lines, multiple streams' do
|
|
77
|
+
InterfaceRepository.create({ name: 'int1_lin2_str3', y: 3, x: 3, width: 10, height: 3 })
|
|
78
|
+
json = File.read('test/support/json/int1_lin2_str3.json')
|
|
79
|
+
attributes = Oj.load(json, symbol_keys: true)
|
|
132
80
|
|
|
133
|
-
|
|
134
|
-
subject.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text...\e[4;3HSome text...")
|
|
135
|
-
end
|
|
81
|
+
Composition.new(attributes).to_s.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text... more text...\e[4;3HSome text... more text...")
|
|
136
82
|
end
|
|
137
83
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
84
|
+
it 'returns the stringified content for a single interface, multiple lines, multiple streams, streams contain styles' do
|
|
85
|
+
json = File.read('test/support/json/int1_lin2_str3_styles.json')
|
|
86
|
+
attributes = Oj.load(json, symbol_keys: true)
|
|
87
|
+
InterfaceRepository.create({ name: 'int1_lin2_str3_styles', y: 3, x: 3, width: 10, height: 3 })
|
|
141
88
|
|
|
142
|
-
|
|
143
|
-
InterfaceRepository.create({ name: 'int1_lin2_str3', y: 3, x: 3, width: 10, height: 3 })
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
it 'returns the stringified content' do
|
|
147
|
-
subject.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text... more text...\e[4;3HSome text... more text...")
|
|
148
|
-
end
|
|
89
|
+
Composition.new(attributes).to_s.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3H\e[38;5;16m\e[48;5;21m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;5;226m\e[48;5;46m\e[24m\e[21m\e[27m \e[38;5;231m\e[48;5;201m\e[1mmore text...")
|
|
149
90
|
end
|
|
150
91
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
InterfaceRepository.create({ name: 'int1_lin2_str3_styles', y: 3, x: 3, width: 10, height: 3 })
|
|
157
|
-
end
|
|
92
|
+
it 'returns the stringified content for multiple interfaces, single line, single stream' do
|
|
93
|
+
InterfaceRepository.create({ name: 'int2_lin1_str1_1', y: 3, x: 3, width: 10, height: 3 })
|
|
94
|
+
InterfaceRepository.create({ name: 'int2_lin1_str1_2', y: 6, x: 6, width: 10, height: 3 })
|
|
95
|
+
json = File.read('test/support/json/int2_lin1_str1.json')
|
|
96
|
+
attributes = Oj.load(json, symbol_keys: true)
|
|
158
97
|
|
|
159
|
-
|
|
160
|
-
subject.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3H\e[38;5;16m\e[48;5;21m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;5;226m\e[48;5;46m\e[24m\e[21m\e[27m \e[38;5;231m\e[48;5;201m\e[1mmore text...")
|
|
161
|
-
end
|
|
98
|
+
Composition.new(attributes).to_s.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text...\e[6;6H \e[6;6H\e[7;6H \e[7;6H\e[8;6H \e[8;6H\e[6;6HSome text...")
|
|
162
99
|
end
|
|
163
100
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
101
|
+
it 'returns the stringified content for multiple interfaces, single line, multiple streams' do
|
|
102
|
+
InterfaceRepository.create({ name: 'int2_lin1_str3_1', y: 3, x: 3, width: 10, height: 3 })
|
|
103
|
+
InterfaceRepository.create({ name: 'int2_lin1_str3_2', y: 6, x: 6, width: 10, height: 3 })
|
|
104
|
+
json = File.read('test/support/json/int2_lin1_str3.json')
|
|
105
|
+
attributes = Oj.load(json, symbol_keys: true)
|
|
167
106
|
|
|
168
|
-
|
|
169
|
-
InterfaceRepository.create({ name: 'int2_lin1_str1_1', y: 3, x: 3, width: 10, height: 3 })
|
|
170
|
-
InterfaceRepository.create({ name: 'int2_lin1_str1_2', y: 6, x: 6, width: 10, height: 3 })
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
it 'returns the stringified content' do
|
|
174
|
-
subject.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text...\e[6;6H \e[6;6H\e[7;6H \e[7;6H\e[8;6H \e[8;6H\e[6;6HSome text...")
|
|
175
|
-
end
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
context 'multiple interfaces, single line, multiple streams' do
|
|
179
|
-
let(:json) { File.read('test/support/json/int2_lin1_str3.json') }
|
|
180
|
-
let(:attributes) { Oj.load(json, symbol_keys: true) }
|
|
181
|
-
|
|
182
|
-
before do
|
|
183
|
-
InterfaceRepository.create({ name: 'int2_lin1_str3_1', y: 3, x: 3, width: 10, height: 3 })
|
|
184
|
-
InterfaceRepository.create({ name: 'int2_lin1_str3_2', y: 6, x: 6, width: 10, height: 3 })
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
it 'returns the stringified content' do
|
|
188
|
-
subject.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text... more text...\e[6;6H \e[6;6H\e[7;6H \e[7;6H\e[8;6H \e[8;6H\e[6;6HSome text... more text...")
|
|
189
|
-
end
|
|
107
|
+
Composition.new(attributes).to_s.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text... more text...\e[6;6H \e[6;6H\e[7;6H \e[7;6H\e[8;6H \e[8;6H\e[6;6HSome text... more text...")
|
|
190
108
|
end
|
|
191
109
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
InterfaceRepository.create({ name: 'int2_lin2_str1_1', y: 3, x: 3, width: 10, height: 3 })
|
|
198
|
-
InterfaceRepository.create({ name: 'int2_lin2_str1_2', y: 6, x: 6, width: 10, height: 3 })
|
|
199
|
-
end
|
|
110
|
+
it 'returns the stringified content for multiple interfaces, multiple lines, single stream' do
|
|
111
|
+
InterfaceRepository.create({ name: 'int2_lin2_str1_1', y: 3, x: 3, width: 10, height: 3 })
|
|
112
|
+
InterfaceRepository.create({ name: 'int2_lin2_str1_2', y: 6, x: 6, width: 10, height: 3 })
|
|
113
|
+
json = File.read('test/support/json/int2_lin2_str1.json')
|
|
114
|
+
attributes = Oj.load(json, symbol_keys: true)
|
|
200
115
|
|
|
201
|
-
|
|
202
|
-
subject.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text...\e[4;3HSome text...\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text...\e[4;3HSome text...")
|
|
203
|
-
end
|
|
116
|
+
Composition.new(attributes).to_s.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text...\e[4;3HSome text...\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text...\e[4;3HSome text...")
|
|
204
117
|
end
|
|
205
118
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
119
|
+
it 'returns the stringified content for multiple interfaces, multiple lines, multiple streams' do
|
|
120
|
+
InterfaceRepository.create({ name: 'int2_lin2_str3_1', y: 3, x: 3, width: 10, height: 3 })
|
|
121
|
+
InterfaceRepository.create({ name: 'int2_lin2_str3_2', y: 6, x: 6, width: 10, height: 3 })
|
|
122
|
+
json = File.read('test/support/json/int2_lin2_str3.json')
|
|
123
|
+
attributes = Oj.load(json, symbol_keys: true)
|
|
209
124
|
|
|
210
|
-
|
|
211
|
-
InterfaceRepository.create({ name: 'int2_lin2_str3_1', y: 3, x: 3, width: 10, height: 3 })
|
|
212
|
-
InterfaceRepository.create({ name: 'int2_lin2_str3_2', y: 6, x: 6, width: 10, height: 3 })
|
|
213
|
-
end
|
|
214
|
-
|
|
215
|
-
it 'returns the stringified content' do
|
|
216
|
-
subject.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text... more text...\e[4;3HSome text... more text...\e[6;6H \e[6;6H\e[7;6H \e[7;6H\e[8;6H \e[8;6H\e[6;6HSome text... more text...\e[7;6HSome text... more text...")
|
|
217
|
-
end
|
|
125
|
+
Composition.new(attributes).to_s.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3HSome text... more text...\e[4;3HSome text... more text...\e[6;6H \e[6;6H\e[7;6H \e[7;6H\e[8;6H \e[8;6H\e[6;6HSome text... more text...\e[7;6HSome text... more text...")
|
|
218
126
|
end
|
|
219
127
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
InterfaceRepository.create({ name: 'int2_lin2_str3_styles_1', y: 3, x: 3, width: 10, height: 3 })
|
|
226
|
-
InterfaceRepository.create({ name: 'int2_lin2_str3_styles_2', y: 6, x: 6, width: 10, height: 3 })
|
|
227
|
-
end
|
|
128
|
+
it 'returns the stringified content for multiple interfaces, multiple lines, multiple streams, streams contain styles' do
|
|
129
|
+
InterfaceRepository.create({ name: 'int2_lin2_str3_styles_1', y: 3, x: 3, width: 10, height: 3 })
|
|
130
|
+
InterfaceRepository.create({ name: 'int2_lin2_str3_styles_2', y: 6, x: 6, width: 10, height: 3 })
|
|
131
|
+
json = File.read('test/support/json/int2_lin2_str3_styles.json')
|
|
132
|
+
attributes = Oj.load(json, symbol_keys: true)
|
|
228
133
|
|
|
229
|
-
|
|
230
|
-
subject.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3H\e[38;5;16m\e[48;5;21m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;5;226m\e[48;5;46m\e[24m\e[21m\e[27m \e[38;5;231m\e[48;5;201m\e[1mmore text...\e[4;3H\e[38;5;16m\e[48;5;21m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;5;226m\e[48;5;46m\e[24m\e[21m\e[27m \e[38;5;231m\e[48;5;201m\e[1mmore text...\e[6;6H \e[6;6H\e[7;6H \e[7;6H\e[8;6H \e[8;6H\e[6;6H\e[38;5;16m\e[48;5;21m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;5;226m\e[48;5;46m\e[24m\e[21m\e[27m \e[38;5;231m\e[48;5;201m\e[1mmore text...\e[7;6H\e[38;5;16m\e[48;5;21m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;5;226m\e[48;5;46m\e[24m\e[21m\e[27m \e[38;5;231m\e[48;5;201m\e[1mmore text...")
|
|
231
|
-
end
|
|
134
|
+
Composition.new(attributes).to_s.must_equal("\e[3;3H \e[3;3H\e[4;3H \e[4;3H\e[5;3H \e[5;3H\e[3;3H\e[38;5;16m\e[48;5;21m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;5;226m\e[48;5;46m\e[24m\e[21m\e[27m \e[38;5;231m\e[48;5;201m\e[1mmore text...\e[4;3H\e[38;5;16m\e[48;5;21m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;5;226m\e[48;5;46m\e[24m\e[21m\e[27m \e[38;5;231m\e[48;5;201m\e[1mmore text...\e[6;6H \e[6;6H\e[7;6H \e[7;6H\e[8;6H \e[8;6H\e[6;6H\e[38;5;16m\e[48;5;21m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;5;226m\e[48;5;46m\e[24m\e[21m\e[27m \e[38;5;231m\e[48;5;201m\e[1mmore text...\e[7;6H\e[38;5;16m\e[48;5;21m\e[24m\e[21m\e[27m\e[4mSome text...\e[38;5;226m\e[48;5;46m\e[24m\e[21m\e[27m \e[38;5;231m\e[48;5;201m\e[1mmore text...")
|
|
232
135
|
end
|
|
233
136
|
end
|
|
234
137
|
end
|
|
@@ -4,31 +4,14 @@ require_relative '../../../../lib/vedeu/models/colour'
|
|
|
4
4
|
|
|
5
5
|
module Vedeu
|
|
6
6
|
describe Foreground do
|
|
7
|
-
let(:described_class) { Foreground }
|
|
8
|
-
let(:described_instance) { Vedeu::Colour.new(attributes) }
|
|
9
|
-
let(:attributes) {
|
|
10
|
-
{
|
|
11
|
-
foreground: '#ff0000'
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
7
|
describe '#foreground' do
|
|
16
|
-
let(:subject) { described_instance.foreground }
|
|
17
|
-
|
|
18
|
-
it 'returns a String' do
|
|
19
|
-
subject.must_be_instance_of(String)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
8
|
it 'returns an escape sequence' do
|
|
23
|
-
|
|
9
|
+
Colour.new({ foreground: '#ff0000' }).foreground
|
|
10
|
+
.must_equal("\e[38;5;196m")
|
|
24
11
|
end
|
|
25
12
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
it 'returns an escape sequence' do
|
|
30
|
-
subject.must_equal('')
|
|
31
|
-
end
|
|
13
|
+
it 'returns an empty string when the foreground is missing' do
|
|
14
|
+
Colour.new.foreground.must_equal('')
|
|
32
15
|
end
|
|
33
16
|
end
|
|
34
17
|
end
|