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
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative '../../../test_helper'
|
2
|
+
require_relative '../../../../lib/vedeu/models/style_collection'
|
3
|
+
require_relative '../../../../lib/vedeu/models/stream'
|
4
|
+
|
5
|
+
module Vedeu
|
6
|
+
describe StyleCollection do
|
7
|
+
let(:described_class) { StyleCollection }
|
8
|
+
|
9
|
+
describe '#coerce' do
|
10
|
+
let(:subject) { Vedeu::Stream.new({ style: style }).style }
|
11
|
+
let(:style) {}
|
12
|
+
|
13
|
+
it 'returns a String' do
|
14
|
+
subject.must_be_instance_of(String)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'returns an empty string' do
|
18
|
+
subject.must_equal('')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require_relative '../../../test_helper'
|
2
|
+
require_relative '../../../../lib/vedeu/output/interface_renderer'
|
3
|
+
require_relative '../../../../lib/vedeu/models/interface'
|
4
|
+
|
5
|
+
module Vedeu
|
6
|
+
describe InterfaceRenderer do
|
7
|
+
let(:described_class) { InterfaceRenderer }
|
8
|
+
let(:described_instance) { described_class.new(interface) }
|
9
|
+
let(:interface) { }
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
@@ -1,51 +1,36 @@
|
|
1
1
|
require_relative '../../../test_helper'
|
2
|
+
require_relative '../../../../lib/vedeu/output/output'
|
2
3
|
|
3
4
|
module Vedeu
|
4
5
|
describe Output do
|
5
6
|
let(:described_class) { Output }
|
6
|
-
let(:subject) { described_class.new }
|
7
7
|
let(:output) {}
|
8
8
|
|
9
9
|
before do
|
10
|
-
InterfaceRepository.create({
|
10
|
+
InterfaceRepository.create({
|
11
|
+
name: 'dummy',
|
12
|
+
width: 15,
|
13
|
+
height: 2,
|
14
|
+
cursor: true
|
15
|
+
})
|
11
16
|
Terminal.stubs(:output).returns(output)
|
12
17
|
end
|
13
18
|
|
14
19
|
after { InterfaceRepository.reset }
|
15
20
|
|
16
|
-
|
17
|
-
subject.
|
21
|
+
describe '#initialize' do
|
22
|
+
let(:subject) { described_class.new }
|
23
|
+
|
24
|
+
it 'returns an Output instance' do
|
25
|
+
subject.must_be_instance_of(Output)
|
26
|
+
end
|
18
27
|
end
|
19
28
|
|
20
29
|
describe '.render' do
|
21
30
|
let(:subject) { described_class.render }
|
22
31
|
|
23
|
-
|
24
|
-
|
25
|
-
[
|
26
|
-
[
|
27
|
-
"\e[38;2;39m\e[48;2;49m\e[1;1H \e[1;1HTesting Outpu...\e[38;2;39m\e[48;2;49m\e[?25h",
|
28
|
-
"\e[38;2;39m\e[48;2;49m\e[2;1H \e[2;1H\e[38;2;39m\e[48;2;49m\e[?25h"
|
29
|
-
]
|
30
|
-
]
|
31
|
-
}
|
32
|
-
|
33
|
-
before { Compositor.arrange({ 'dummy' => [[{ text: 'Testing Output.render' }]] }) }
|
34
|
-
|
35
|
-
it { subject.must_equal(output) }
|
36
|
-
end
|
37
|
-
|
38
|
-
context 'when the interfaces have no content' do
|
39
|
-
let(:output) {
|
40
|
-
[
|
41
|
-
[
|
42
|
-
"\e[38;2;39m\e[48;2;49m\e[1;1H \e[1;1H\e[38;2;39m\e[48;2;49m\e[?25h",
|
43
|
-
"\e[38;2;39m\e[48;2;49m\e[2;1H \e[2;1H\e[38;2;39m\e[48;2;49m\e[?25h"
|
44
|
-
]
|
45
|
-
]
|
46
|
-
}
|
47
|
-
|
48
|
-
it { subject.must_equal(output) }
|
32
|
+
it 'returns an Array' do
|
33
|
+
subject.must_be_instance_of(Array)
|
49
34
|
end
|
50
35
|
end
|
51
36
|
end
|
@@ -1,27 +1,37 @@
|
|
1
1
|
require_relative '../../../test_helper'
|
2
|
+
require_relative '../../../../lib/vedeu/process/process'
|
3
|
+
require_relative '../../../../lib/vedeu/repository/interface_repository'
|
2
4
|
|
3
5
|
module Vedeu
|
4
6
|
describe Process do
|
5
7
|
let(:described_class) { Process }
|
6
8
|
let(:input) { nil }
|
7
9
|
let(:result) {}
|
8
|
-
let(:subject) { described_class.new }
|
9
10
|
|
10
|
-
|
11
|
-
subject.
|
11
|
+
describe '#initialize' do
|
12
|
+
let(:subject) { described_class.new }
|
13
|
+
|
14
|
+
it 'returns a Process instance' do
|
15
|
+
subject.must_be_instance_of(Process)
|
16
|
+
end
|
12
17
|
end
|
13
18
|
|
14
19
|
describe '.evaluate' do
|
15
20
|
let(:subject) { described_class.evaluate }
|
16
21
|
let(:command) { Command.new }
|
22
|
+
let(:json) { {} }
|
17
23
|
|
18
24
|
before do
|
19
|
-
InterfaceRepository.create({
|
25
|
+
InterfaceRepository.create({
|
26
|
+
name: 'dummy',
|
27
|
+
width: 15,
|
28
|
+
height: 2
|
29
|
+
})
|
20
30
|
Queue.stubs(:dequeue).returns(input)
|
21
|
-
CommandRepository.stubs(:
|
22
|
-
CommandRepository.stubs(:by_keyword).returns(command)
|
31
|
+
CommandRepository.stubs(:by_input).returns(command)
|
23
32
|
command.stubs(:execute).returns(result)
|
24
|
-
|
33
|
+
Parser.stubs(:parse).returns(json)
|
34
|
+
Composition.stubs(:enqueue).returns([])
|
25
35
|
end
|
26
36
|
|
27
37
|
after do
|
@@ -30,61 +40,29 @@ module Vedeu
|
|
30
40
|
end
|
31
41
|
|
32
42
|
context 'when there is no input' do
|
33
|
-
it '
|
34
|
-
subject.
|
43
|
+
it 'raises an exception' do
|
44
|
+
proc { subject }.must_raise(StopIteration)
|
35
45
|
end
|
36
46
|
end
|
37
47
|
|
38
|
-
context 'when
|
48
|
+
context 'when there is input' do
|
39
49
|
let(:input) { "q" }
|
40
50
|
|
41
|
-
context '
|
42
|
-
it 'returns a NilClass' do
|
43
|
-
subject.must_be_instance_of(NilClass)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
context 'or the result is :stop' do
|
48
|
-
let(:result) { :stop }
|
49
|
-
|
50
|
-
it 'raises an exception' do
|
51
|
-
proc { subject }.must_raise(StopIteration)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context 'or the result is anything else' do
|
51
|
+
context 'and there is a result' do
|
56
52
|
let(:result) { { 'dummy' => [['output...']] } }
|
57
53
|
|
58
54
|
it 'returns an Array' do
|
59
55
|
subject.must_be_instance_of(Array)
|
60
56
|
end
|
61
57
|
end
|
62
|
-
end
|
63
|
-
|
64
|
-
context 'when the input is a keyword' do
|
65
|
-
let(:input) { "quit" }
|
66
|
-
|
67
|
-
context 'but there is no result' do
|
68
|
-
it 'returns a NilClass' do
|
69
|
-
subject.must_be_instance_of(NilClass)
|
70
|
-
end
|
71
|
-
end
|
72
58
|
|
73
|
-
context 'or the result is :stop' do
|
59
|
+
context 'or there is no result or the result is :stop' do
|
74
60
|
let(:result) { :stop }
|
75
61
|
|
76
62
|
it 'raises an exception' do
|
77
63
|
proc { subject }.must_raise(StopIteration)
|
78
64
|
end
|
79
65
|
end
|
80
|
-
|
81
|
-
context 'or the result is anything else' do
|
82
|
-
let(:result) { { 'dummy' => [['output...']] } }
|
83
|
-
|
84
|
-
it 'returns an Array' do
|
85
|
-
subject.must_be_instance_of(Array)
|
86
|
-
end
|
87
|
-
end
|
88
66
|
end
|
89
67
|
end
|
90
68
|
end
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require_relative '../../../test_helper'
|
2
|
+
require_relative '../../../support/dummy_command'
|
3
|
+
require_relative '../../../../lib/vedeu/repository/command_repository'
|
2
4
|
|
3
5
|
module Vedeu
|
4
6
|
describe CommandRepository do
|
@@ -22,16 +24,15 @@ module Vedeu
|
|
22
24
|
|
23
25
|
after { CommandRepository.reset }
|
24
26
|
|
25
|
-
describe '.
|
26
|
-
let(:subject) { described_class.
|
27
|
+
describe '.by_input' do
|
28
|
+
let(:subject) { described_class.by_input(input) }
|
29
|
+
let(:input) { 'b' }
|
27
30
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
it 'returns the Command instance' do
|
32
|
-
subject.must_be_instance_of(Command)
|
33
|
-
end
|
31
|
+
it 'returns the Command instance' do
|
32
|
+
subject.must_be_instance_of(Command)
|
33
|
+
end
|
34
34
|
|
35
|
+
context 'when the command was found by keypress' do
|
35
36
|
it 'returns the correct command' do
|
36
37
|
subject.name.must_equal('banana')
|
37
38
|
end
|
@@ -44,18 +45,10 @@ module Vedeu
|
|
44
45
|
subject.keypress.must_equal('b')
|
45
46
|
end
|
46
47
|
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe '.by_keyword' do
|
50
|
-
let(:subject) { described_class.by_keyword(input) }
|
51
48
|
|
52
49
|
context 'when the command was found by keyword' do
|
53
50
|
let(:input) { 'apple' }
|
54
51
|
|
55
|
-
it 'returns the Command instance' do
|
56
|
-
subject.must_be_instance_of(Command)
|
57
|
-
end
|
58
|
-
|
59
52
|
it 'returns the correct command' do
|
60
53
|
subject.keypress.must_equal('a')
|
61
54
|
end
|
@@ -70,9 +63,22 @@ module Vedeu
|
|
70
63
|
end
|
71
64
|
end
|
72
65
|
|
66
|
+
describe '.create' do
|
67
|
+
let(:subject) { described_class.create(attributes) }
|
68
|
+
let(:attributes) { {} }
|
69
|
+
|
70
|
+
it 'returns a Command' do
|
71
|
+
subject.must_be_instance_of(Command)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
73
75
|
describe '.entity' do
|
74
76
|
let(:subject) { described_class.entity }
|
75
77
|
|
78
|
+
it 'returns a Class instance' do
|
79
|
+
subject.must_be_instance_of(Class)
|
80
|
+
end
|
81
|
+
|
76
82
|
it 'returns Command' do
|
77
83
|
subject.must_equal(Command)
|
78
84
|
end
|
@@ -1,11 +1,33 @@
|
|
1
1
|
require_relative '../../../test_helper'
|
2
|
+
require_relative '../../../../lib/vedeu/repository/interface_repository'
|
2
3
|
|
3
4
|
module Vedeu
|
4
5
|
describe InterfaceRepository do
|
5
6
|
let(:described_class) { InterfaceRepository }
|
6
7
|
|
7
|
-
before
|
8
|
-
|
8
|
+
before do
|
9
|
+
InterfaceRepository.create({
|
10
|
+
name: 'dummy',
|
11
|
+
width: 15,
|
12
|
+
height: 2
|
13
|
+
})
|
14
|
+
end
|
15
|
+
after { InterfaceRepository.reset }
|
16
|
+
|
17
|
+
describe '.create' do
|
18
|
+
let(:subject) { described_class.create(attributes) }
|
19
|
+
let(:attributes) {
|
20
|
+
{
|
21
|
+
name: 'dummy',
|
22
|
+
width: 15,
|
23
|
+
height: 2
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
it 'returns an Interface' do
|
28
|
+
subject.must_be_instance_of(Interface)
|
29
|
+
end
|
30
|
+
end
|
9
31
|
|
10
32
|
describe '.find' do
|
11
33
|
let(:subject) { described_class.find(value) }
|
@@ -26,21 +48,35 @@ module Vedeu
|
|
26
48
|
end
|
27
49
|
end
|
28
50
|
|
29
|
-
describe '.
|
30
|
-
let(:subject)
|
51
|
+
describe '.update' do
|
52
|
+
let(:subject) { described_class.update(value, attributes) }
|
53
|
+
let(:value) { 'dummy' }
|
54
|
+
let(:attributes) { { name: 'dumber' } }
|
31
55
|
|
32
|
-
|
56
|
+
it 'returns an Interface' do
|
57
|
+
subject.must_be_instance_of(Interface)
|
58
|
+
end
|
33
59
|
|
34
|
-
|
35
|
-
|
60
|
+
context 'when the interface exists' do
|
61
|
+
it 'updates and returns the existing interface' do
|
62
|
+
subject.name.must_equal('dumber')
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'when the interface does not exist' do
|
67
|
+
before { InterfaceRepository.reset }
|
68
|
+
|
69
|
+
it 'returns the created interface' do
|
70
|
+
subject.name.must_equal('dumber')
|
71
|
+
end
|
36
72
|
end
|
37
73
|
end
|
38
74
|
|
39
|
-
describe '.
|
40
|
-
let(:subject) { described_class.
|
75
|
+
describe '.refresh' do
|
76
|
+
let(:subject) { described_class.refresh }
|
41
77
|
|
42
|
-
it 'returns an
|
43
|
-
subject.
|
78
|
+
it 'returns an Array' do
|
79
|
+
subject.must_be_instance_of(Array)
|
44
80
|
end
|
45
81
|
end
|
46
82
|
|
@@ -49,9 +85,9 @@ module Vedeu
|
|
49
85
|
|
50
86
|
before do
|
51
87
|
InterfaceRepository.reset
|
52
|
-
@case_a = InterfaceRepository.create({ name: 'a', width: 15, height: 2,
|
53
|
-
@case_b = InterfaceRepository.create({ name: 'b', width: 15, height: 2,
|
54
|
-
@case_c = InterfaceRepository.create({ name: 'c', width: 15, height: 2,
|
88
|
+
@case_a = InterfaceRepository.create({ name: 'a', width: 15, height: 2, z: 2 })
|
89
|
+
@case_b = InterfaceRepository.create({ name: 'b', width: 15, height: 2, z: 1 })
|
90
|
+
@case_c = InterfaceRepository.create({ name: 'c', width: 15, height: 2, z: 3 })
|
55
91
|
end
|
56
92
|
after { InterfaceRepository.reset }
|
57
93
|
|
@@ -63,5 +99,17 @@ module Vedeu
|
|
63
99
|
subject.must_equal([@case_b, @case_a, @case_c])
|
64
100
|
end
|
65
101
|
end
|
102
|
+
|
103
|
+
describe '.entity' do
|
104
|
+
let(:subject) { described_class.entity }
|
105
|
+
|
106
|
+
it 'returns a Class instance' do
|
107
|
+
subject.must_be_instance_of(Class)
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'returns Interface' do
|
111
|
+
subject.must_equal(Interface)
|
112
|
+
end
|
113
|
+
end
|
66
114
|
end
|
67
115
|
end
|
@@ -1,18 +1,25 @@
|
|
1
1
|
require_relative '../../../test_helper'
|
2
|
+
require_relative '../../../support/dummy_command'
|
3
|
+
require_relative '../../../../lib/vedeu/repository/storage'
|
4
|
+
|
2
5
|
|
3
6
|
module Vedeu
|
4
7
|
describe Storage do
|
5
8
|
let(:described_class) { Storage }
|
6
9
|
let(:subject) { described_class.new }
|
7
10
|
let(:record) { DummyCommand.new }
|
8
|
-
let(:entity)
|
11
|
+
let(:entity) {}
|
9
12
|
|
10
|
-
|
11
|
-
subject.
|
12
|
-
end
|
13
|
+
describe '#initialize' do
|
14
|
+
let(:subject) { described_class.new }
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
+
it 'returns a Storage instance' do
|
17
|
+
subject.must_be_instance_of(Storage)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'sets an instance variable' do
|
21
|
+
subject.instance_variable_get('@map').must_equal({})
|
22
|
+
end
|
16
23
|
end
|
17
24
|
|
18
25
|
describe '#create' do
|
@@ -0,0 +1,348 @@
|
|
1
|
+
require_relative '../../../test_helper'
|
2
|
+
require_relative '../../../../lib/vedeu/support/esc'
|
3
|
+
|
4
|
+
module Vedeu
|
5
|
+
describe Esc do
|
6
|
+
let(:described_class) { Esc }
|
7
|
+
|
8
|
+
describe '.background_colour' do
|
9
|
+
let(:subject) { described_class.background_colour }
|
10
|
+
|
11
|
+
it 'returns a String' do
|
12
|
+
subject.must_be_instance_of(String)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'returns an escape sequence' do
|
16
|
+
subject.must_equal("\e[48;5;16m")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '.blink' do
|
21
|
+
let(:subject) { described_class.blink }
|
22
|
+
|
23
|
+
it 'returns a String' do
|
24
|
+
subject.must_be_instance_of(String)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns an escape sequence' do
|
28
|
+
subject.must_equal("\e[5m")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '.blink_off' do
|
33
|
+
let(:subject) { described_class.blink_off }
|
34
|
+
|
35
|
+
it 'returns a String' do
|
36
|
+
subject.must_be_instance_of(String)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'returns an escape sequence' do
|
40
|
+
subject.must_equal("\e[25m")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '.bold' do
|
45
|
+
let(:subject) { described_class.bold }
|
46
|
+
|
47
|
+
it 'returns a String' do
|
48
|
+
subject.must_be_instance_of(String)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'returns an escape sequence' do
|
52
|
+
subject.must_equal("\e[1m")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '.bold_off' do
|
57
|
+
let(:subject) { described_class.bold_off }
|
58
|
+
|
59
|
+
it 'returns a String' do
|
60
|
+
subject.must_be_instance_of(String)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'returns an escape sequence' do
|
64
|
+
subject.must_equal("\e[21m")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe '.clear' do
|
69
|
+
let(:subject) { described_class.clear }
|
70
|
+
|
71
|
+
it 'returns a String' do
|
72
|
+
subject.must_be_instance_of(String)
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'returns an escape sequence' do
|
76
|
+
subject.must_equal("\e[2J")
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe '.clear_line' do
|
81
|
+
let(:subject) { described_class.clear_line }
|
82
|
+
|
83
|
+
it 'returns a String' do
|
84
|
+
subject.must_be_instance_of(String)
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'returns an escape sequence' do
|
88
|
+
subject.must_equal("\e[2K")
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe '.esc' do
|
93
|
+
let(:subject) { described_class.esc }
|
94
|
+
|
95
|
+
it 'returns a String' do
|
96
|
+
subject.must_be_instance_of(String)
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'returns an escape sequence' do
|
100
|
+
subject.must_equal("\e[")
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe '.foreground_colour' do
|
105
|
+
let(:subject) { described_class.foreground_colour }
|
106
|
+
|
107
|
+
it 'returns a String' do
|
108
|
+
subject.must_be_instance_of(String)
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'returns an escape sequence' do
|
112
|
+
subject.must_equal("\e[38;5;231m")
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe '.negative' do
|
117
|
+
let(:subject) { described_class.negative }
|
118
|
+
|
119
|
+
it 'returns a String' do
|
120
|
+
subject.must_be_instance_of(String)
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'returns an escape sequence' do
|
124
|
+
subject.must_equal("\e[7m")
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe '.positive' do
|
129
|
+
let(:subject) { described_class.positive }
|
130
|
+
|
131
|
+
it 'returns a String' do
|
132
|
+
subject.must_be_instance_of(String)
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'returns an escape sequence' do
|
136
|
+
subject.must_equal("\e[27m")
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe '.normal' do
|
141
|
+
let(:subject) { described_class.normal }
|
142
|
+
|
143
|
+
it 'returns a String' do
|
144
|
+
subject.must_be_instance_of(String)
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'returns an escape sequence' do
|
148
|
+
subject.must_equal("\e[24m\e[21m\e[27m")
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
describe '.dim' do
|
153
|
+
let(:subject) { described_class.dim }
|
154
|
+
|
155
|
+
it 'returns a String' do
|
156
|
+
subject.must_be_instance_of(String)
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'returns an escape sequence' do
|
160
|
+
subject.must_equal("\e[2m")
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
describe '.reset' do
|
165
|
+
let(:subject) { described_class.reset }
|
166
|
+
|
167
|
+
it 'returns a String' do
|
168
|
+
subject.must_be_instance_of(String)
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'returns an escape sequence' do
|
172
|
+
subject.must_equal("\e[0m")
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
describe '.set_position' do
|
177
|
+
let(:subject) { described_class.set_position(y, x) }
|
178
|
+
let(:y) {}
|
179
|
+
let(:x) {}
|
180
|
+
|
181
|
+
context 'when no coordinates are provided' do
|
182
|
+
it 'returns a position escape sequence' do
|
183
|
+
subject.must_equal("\e[1;1H")
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
context 'when coordinates are provided' do
|
188
|
+
let(:y) { 12 }
|
189
|
+
let(:x) { 19 }
|
190
|
+
|
191
|
+
it 'returns a position escape sequence' do
|
192
|
+
subject.must_equal("\e[12;19H")
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
describe '.stylize' do
|
198
|
+
let(:subject) { described_class.stylize(style) }
|
199
|
+
let(:style) {}
|
200
|
+
|
201
|
+
it 'returns a String' do
|
202
|
+
subject.must_be_instance_of(String)
|
203
|
+
end
|
204
|
+
|
205
|
+
context 'when the style is not provided' do
|
206
|
+
it 'returns an empty string' do
|
207
|
+
subject.must_equal('')
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
context 'when the style is blink' do
|
212
|
+
let(:style) { 'blink' }
|
213
|
+
|
214
|
+
it 'returns an escape sequence' do
|
215
|
+
subject.must_equal("\e[5m")
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
context 'when the style is blink off' do
|
220
|
+
let(:style) { 'blink_off' }
|
221
|
+
|
222
|
+
it 'returns an escape sequence' do
|
223
|
+
subject.must_equal("\e[25m")
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
context 'when the style is bold' do
|
228
|
+
let(:style) { 'bold' }
|
229
|
+
|
230
|
+
it 'returns an escape sequence' do
|
231
|
+
subject.must_equal("\e[1m")
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
context 'when the style is bold off' do
|
236
|
+
let(:style) { 'bold_off' }
|
237
|
+
|
238
|
+
it 'returns an escape sequence' do
|
239
|
+
subject.must_equal("\e[21m")
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
context 'when the style is clear' do
|
244
|
+
let(:style) { 'clear' }
|
245
|
+
|
246
|
+
it 'returns an escape sequence' do
|
247
|
+
subject.must_equal("\e[2J")
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
context 'when the style is hide_cursor' do
|
252
|
+
let(:style) { 'hide_cursor' }
|
253
|
+
|
254
|
+
it 'returns an escape sequence' do
|
255
|
+
subject.must_equal("\e[?25l")
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
context 'when the style is negative' do
|
260
|
+
let(:style) { 'negative' }
|
261
|
+
|
262
|
+
it 'returns an escape sequence' do
|
263
|
+
subject.must_equal("\e[7m")
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
context 'when the style is positive' do
|
268
|
+
let(:style) { 'positive' }
|
269
|
+
|
270
|
+
it 'returns an escape sequence' do
|
271
|
+
subject.must_equal("\e[27m")
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
context 'when the style is reset' do
|
276
|
+
let(:style) { 'reset' }
|
277
|
+
|
278
|
+
it 'returns an escape sequence' do
|
279
|
+
subject.must_equal("\e[0m")
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
context 'when the style is normal' do
|
284
|
+
let(:style) { 'normal' }
|
285
|
+
|
286
|
+
it 'returns an escape sequence' do
|
287
|
+
subject.must_equal("\e[24m\e[21m\e[27m")
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
context 'when the style is dim' do
|
292
|
+
let(:style) { 'dim' }
|
293
|
+
|
294
|
+
it 'returns an escape sequence' do
|
295
|
+
subject.must_equal("\e[2m")
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
context 'when the style is show_cursor' do
|
300
|
+
let(:style) { 'show_cursor' }
|
301
|
+
|
302
|
+
it 'returns an escape sequence' do
|
303
|
+
subject.must_equal("\e[?25h")
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
context 'when the style is underline' do
|
308
|
+
let(:style) { 'underline' }
|
309
|
+
|
310
|
+
it 'returns an escape sequence' do
|
311
|
+
subject.must_equal("\e[4m")
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
context 'when the style is underline off' do
|
316
|
+
let(:style) { 'underline_off' }
|
317
|
+
|
318
|
+
it 'returns an escape sequence' do
|
319
|
+
subject.must_equal("\e[24m")
|
320
|
+
end
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
describe '.underline' do
|
325
|
+
let(:subject) { described_class.underline }
|
326
|
+
|
327
|
+
it 'returns a String' do
|
328
|
+
subject.must_be_instance_of(String)
|
329
|
+
end
|
330
|
+
|
331
|
+
it 'returns an escape sequence' do
|
332
|
+
subject.must_equal("\e[4m")
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
describe '.underline_off' do
|
337
|
+
let(:subject) { described_class.underline_off }
|
338
|
+
|
339
|
+
it 'returns a String' do
|
340
|
+
subject.must_be_instance_of(String)
|
341
|
+
end
|
342
|
+
|
343
|
+
it 'returns an escape sequence' do
|
344
|
+
subject.must_equal("\e[24m")
|
345
|
+
end
|
346
|
+
end
|
347
|
+
end
|
348
|
+
end
|