vedeu 0.4.22 → 0.4.23
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 +5 -5
- data/examples/geometry_app.rb +2 -2
- data/lib/vedeu/bindings.rb +2 -15
- data/lib/vedeu/buffers/buffer.rb +2 -6
- data/lib/vedeu/configuration/cli.rb +4 -4
- data/lib/vedeu/dsl/components/border.rb +24 -8
- data/lib/vedeu/dsl/components/geometry.rb +10 -0
- data/lib/vedeu/events/event.rb +1 -2
- data/lib/vedeu/geometry/area.rb +4 -1
- data/lib/vedeu/geometry/geometry.rb +51 -18
- data/lib/vedeu/geometry/grid.rb +4 -28
- data/lib/vedeu/launcher.rb +6 -2
- data/lib/vedeu/models/line.rb +1 -1
- data/lib/vedeu/output/clear.rb +8 -8
- data/lib/vedeu/output/compressor.rb +1 -0
- data/lib/vedeu/output/esc.rb +29 -101
- data/lib/vedeu/output/html_char.rb +9 -9
- data/lib/vedeu/output/refresh.rb +17 -5
- data/lib/vedeu/output/renderers/all.rb +1 -9
- data/lib/vedeu/output/translator.rb +1 -1
- data/lib/vedeu/output/viewport.rb +1 -1
- data/lib/vedeu/repositories/repositories/colours.rb +6 -3
- data/lib/vedeu/support/all.rb +1 -0
- data/lib/vedeu/support/template.rb +2 -1
- data/lib/vedeu/support/terminal.rb +2 -0
- data/lib/vedeu/support/timer.rb +44 -0
- data/test/lib/vedeu/buffers/buffer_test.rb +1 -7
- data/test/lib/vedeu/configuration/cli_test.rb +28 -0
- data/test/lib/vedeu/dsl/components/geometry_test.rb +12 -0
- data/test/lib/vedeu/geometry/geometry_test.rb +8 -0
- data/test/lib/vedeu/geometry/grid_test.rb +0 -20
- data/test/lib/vedeu/geometry/position_test.rb +6 -0
- data/test/lib/vedeu/null/border_test.rb +6 -0
- data/test/lib/vedeu/output/clear_test.rb +12 -6
- data/test/lib/vedeu/output/compressor_test.rb +29 -0
- data/test/lib/vedeu/output/esc_test.rb +26 -26
- data/test/lib/vedeu/output/presentation_test.rb +22 -0
- data/test/lib/vedeu/output/translator_test.rb +18 -16
- data/test/lib/vedeu/output/viewport_test.rb +163 -97
- data/test/lib/vedeu/output/virtual_terminal_test.rb +6 -0
- data/test/lib/vedeu/repositories/repositories/colours_test.rb +29 -4
- data/test/lib/vedeu/repositories/repository_test.rb +6 -0
- data/vedeu.gemspec +4 -4
- metadata +3 -44
@@ -68,13 +68,7 @@ module Vedeu
|
|
68
68
|
describe '#clear' do
|
69
69
|
subject { instance.clear }
|
70
70
|
|
71
|
-
|
72
|
-
it { subject.must_be_instance_of(NilClass) }
|
73
|
-
end
|
74
|
-
|
75
|
-
context 'when the clear buffer is not empty' do
|
76
|
-
# it { subject.must_be_instance_of(Array) }
|
77
|
-
end
|
71
|
+
it { subject.must_be_instance_of(Array) }
|
78
72
|
end
|
79
73
|
|
80
74
|
describe '#hide' do
|
@@ -55,6 +55,34 @@ module Vedeu
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
+
# describe '#drb_height' do
|
59
|
+
# it '--drb-height' do
|
60
|
+
# Configuration.configure(['--drb-height'])
|
61
|
+
# Configuration.drb_height.must_equal(true)
|
62
|
+
# end
|
63
|
+
# end
|
64
|
+
|
65
|
+
# describe '#drb_host' do
|
66
|
+
# it '--drb-host' do
|
67
|
+
# Configuration.configure(['--drb-host'])
|
68
|
+
# Configuration.drb_host.must_equal(true)
|
69
|
+
# end
|
70
|
+
# end
|
71
|
+
|
72
|
+
# describe '#drb_port' do
|
73
|
+
# it '--drb-port' do
|
74
|
+
# Configuration.configure(['--drb-port'])
|
75
|
+
# Configuration.drb_port.must_equal(true)
|
76
|
+
# end
|
77
|
+
# end
|
78
|
+
|
79
|
+
# describe '#drb_width' do
|
80
|
+
# it '--drb-width' do
|
81
|
+
# Configuration.configure(['--drb-width'])
|
82
|
+
# Configuration.drb_width.must_equal(true)
|
83
|
+
# end
|
84
|
+
# end
|
85
|
+
|
58
86
|
describe '#interactive?' do
|
59
87
|
it '--interactive' do
|
60
88
|
Configuration.configure(['--interactive'])
|
@@ -53,6 +53,12 @@ module Vedeu
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
describe '#columns' do
|
57
|
+
subject { instance.columns(3) }
|
58
|
+
|
59
|
+
it { subject.must_equal(18) }
|
60
|
+
end
|
61
|
+
|
56
62
|
describe '#height' do
|
57
63
|
subject { instance.height(6) }
|
58
64
|
|
@@ -75,6 +81,12 @@ module Vedeu
|
|
75
81
|
end
|
76
82
|
end
|
77
83
|
|
84
|
+
describe '#rows' do
|
85
|
+
subject { instance.rows(3) }
|
86
|
+
|
87
|
+
it { subject.must_equal(6) }
|
88
|
+
end
|
89
|
+
|
78
90
|
describe '#width' do
|
79
91
|
subject { instance.width(25) }
|
80
92
|
|
@@ -51,6 +51,14 @@ module Vedeu
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
+
describe '#inspect' do
|
55
|
+
subject { instance.inspect }
|
56
|
+
|
57
|
+
it { subject.must_be_instance_of(String) }
|
58
|
+
|
59
|
+
it { subject.must_equal('<Vedeu::Geometry x:1 xn:40 y:1 yn:12 maximise:false>') }
|
60
|
+
end
|
61
|
+
|
54
62
|
describe '#maximise' do
|
55
63
|
let(:attributes) {
|
56
64
|
{
|
@@ -1,25 +1,5 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
describe Fixnum do
|
4
|
-
|
5
|
-
describe '#columns' do
|
6
|
-
it 'returns the width if the value is in range' do
|
7
|
-
IO.console.stub :winsize, [25, 60] do
|
8
|
-
1.columns.must_equal(5)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe '#rows' do
|
14
|
-
it 'returns the height if the value is in range' do
|
15
|
-
IO.console.stub :winsize, [25, 60] do
|
16
|
-
1.rows.must_equal(2)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
end # Fixnum
|
22
|
-
|
23
3
|
module Vedeu
|
24
4
|
|
25
5
|
describe Grid do
|
@@ -36,12 +36,7 @@ module Vedeu
|
|
36
36
|
subject { described.clear(interface, options) }
|
37
37
|
|
38
38
|
context 'when the interface is visible' do
|
39
|
-
|
40
|
-
let(:drb) { true }
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'when DRb is not enabled' do
|
44
|
-
end
|
39
|
+
# it { subject.must_be_instance_of(Array) }
|
45
40
|
end
|
46
41
|
|
47
42
|
context 'when the interface is not visible' do
|
@@ -60,6 +55,7 @@ module Vedeu
|
|
60
55
|
it { subject.flatten.size.must_equal(9) }
|
61
56
|
|
62
57
|
context 'when the interface is visible' do
|
58
|
+
# it { subject.must_be_instance_of(Array) }
|
63
59
|
end
|
64
60
|
|
65
61
|
context 'when the interface is not visible' do
|
@@ -71,6 +67,16 @@ module Vedeu
|
|
71
67
|
|
72
68
|
describe '#write' do
|
73
69
|
subject { instance.write }
|
70
|
+
|
71
|
+
context 'when the interface is visible' do
|
72
|
+
# it { subject.must_be_instance_of(Array) }
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'when the interface is not visible' do
|
76
|
+
let(:visible) { false }
|
77
|
+
|
78
|
+
it { subject.must_be_instance_of(NilClass) }
|
79
|
+
end
|
74
80
|
end
|
75
81
|
|
76
82
|
end # Clear
|
@@ -20,8 +20,37 @@ module Vedeu
|
|
20
20
|
|
21
21
|
it { subject.must_be_instance_of(String) }
|
22
22
|
|
23
|
+
context 'when the output is not a collection' do
|
24
|
+
let(:output) { 'abcd' }
|
25
|
+
|
26
|
+
it { subject.must_equal('abcd') }
|
27
|
+
end
|
28
|
+
|
23
29
|
context 'when the output is all Vedeu::Char elements' do
|
30
|
+
let(:output) {
|
31
|
+
[
|
32
|
+
Vedeu::Char.new(value: 'Y', colour: { foreground: '#ff0000' }),
|
33
|
+
Vedeu::Char.new(value: 'e', colour: { foreground: '#ff0000' }),
|
34
|
+
Vedeu::Char.new(value: 's', colour: { foreground: '#ff0000' }),
|
35
|
+
]
|
36
|
+
}
|
37
|
+
it 'converts the non-Vedeu::Char elements into String elements' do
|
38
|
+
subject.must_equal("\e[38;2;255;0;0mYes")
|
39
|
+
end
|
40
|
+
end
|
24
41
|
|
42
|
+
context 'when the output is all Vedeu::Char elements' do
|
43
|
+
let(:output) {
|
44
|
+
[
|
45
|
+
Vedeu::Char.new(value: 'a', colour: { foreground: '#ff0000' }),
|
46
|
+
Vedeu::Char.new(value: 'b', colour: { foreground: '#ff0000' }),
|
47
|
+
Vedeu::Char.new(value: 'c', colour: { foreground: '#0000ff' }),
|
48
|
+
Vedeu::Char.new(value: 'd', colour: { foreground: '#0000ff' }),
|
49
|
+
]
|
50
|
+
}
|
51
|
+
it 'compresses multiple colours and styles where possible' do
|
52
|
+
subject.must_equal("\e[38;2;255;0;0mab\e[38;2;0;0;255mcd")
|
53
|
+
end
|
25
54
|
end
|
26
55
|
|
27
56
|
context 'when the output is not all Vedeu::Char elements' do
|
@@ -12,23 +12,23 @@ module Vedeu
|
|
12
12
|
|
13
13
|
describe 'colours defined via define_method' do
|
14
14
|
it 'returns an escape sequence for the foreground colour' do
|
15
|
-
|
15
|
+
described.magenta.must_equal("\e[35m")
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'returns an escape sequence for the foreground colour and resets ' \
|
19
19
|
'after calling the block' do
|
20
|
-
|
20
|
+
described.cyan do
|
21
21
|
'ununpentium'
|
22
22
|
end.must_equal("\e[36mununpentium\e[39m")
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'returns an escape sequence for the background colour' do
|
26
|
-
|
26
|
+
described.on_yellow.must_equal("\e[43m")
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'returns an escape sequence for the background colour and resets ' \
|
30
30
|
'after calling the block' do
|
31
|
-
|
31
|
+
described.on_red do
|
32
32
|
'livermorium'
|
33
33
|
end.must_equal("\e[41mlivermorium\e[49m")
|
34
34
|
end
|
@@ -37,7 +37,7 @@ module Vedeu
|
|
37
37
|
describe '.escape' do
|
38
38
|
let(:stream) { "\e[0m\e[38;2;39m\e[48;2;49m\e[2J\e[?25l" }
|
39
39
|
|
40
|
-
subject {
|
40
|
+
subject { described.escape(stream) }
|
41
41
|
|
42
42
|
it { subject.must_be_instance_of(String) }
|
43
43
|
|
@@ -68,87 +68,87 @@ module Vedeu
|
|
68
68
|
|
69
69
|
describe '.string' do
|
70
70
|
it 'returns an empty string when the style is not provided' do
|
71
|
-
|
71
|
+
described.string.must_equal('')
|
72
72
|
end
|
73
73
|
|
74
74
|
it 'returns an escape sequence when the style is bg_reset' do
|
75
|
-
|
75
|
+
described.string('bg_reset').must_equal("\e[49m")
|
76
76
|
end
|
77
77
|
|
78
78
|
it 'returns an escape sequence when the style is blink' do
|
79
|
-
|
79
|
+
described.string('blink').must_equal("\e[5m")
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'returns an escape sequence when the style is blink off' do
|
83
|
-
|
83
|
+
described.string('blink_off').must_equal("\e[25m")
|
84
84
|
end
|
85
85
|
|
86
86
|
it 'returns an escape sequence when the style is bold' do
|
87
|
-
|
87
|
+
described.string('bold').must_equal("\e[1m")
|
88
88
|
end
|
89
89
|
|
90
90
|
it 'returns an escape sequence when the style is bold off' do
|
91
|
-
|
91
|
+
described.string('bold_off').must_equal("\e[22m")
|
92
92
|
end
|
93
93
|
|
94
94
|
it 'returns an escape sequence when the style is clear' do
|
95
|
-
|
95
|
+
described.string('clear').must_equal("\e[39m\e[49m\e[2J")
|
96
96
|
end
|
97
97
|
|
98
98
|
it 'returns an escape sequence when the style is clear_line' do
|
99
|
-
|
99
|
+
described.string('clear_line').must_equal("\e[39m\e[49m\e[2K")
|
100
100
|
end
|
101
101
|
|
102
102
|
it 'returns an escape sequence when the style is colour_reset' do
|
103
|
-
|
103
|
+
described.string('colour_reset').must_equal("\e[39m\e[49m")
|
104
104
|
end
|
105
105
|
|
106
106
|
it 'returns an escape sequence when the style is fg_reset' do
|
107
|
-
|
107
|
+
described.string('fg_reset').must_equal("\e[39m")
|
108
108
|
end
|
109
109
|
|
110
110
|
it 'returns an escape sequence when the style is hide_cursor' do
|
111
|
-
|
111
|
+
described.string('hide_cursor').must_equal("\e[?25l")
|
112
112
|
end
|
113
113
|
|
114
114
|
it 'returns an escape sequence when the style is screen_init' do
|
115
|
-
|
115
|
+
described.string('screen_init').must_equal("\e[0m\e[39m\e[49m\e[2J\e[?25l")
|
116
116
|
end
|
117
117
|
|
118
118
|
it 'returns an escape sequence when the style is screen_exit' do
|
119
|
-
|
119
|
+
described.string('screen_exit').must_equal("\e[?25h\e[39m\e[49m\e[0m")
|
120
120
|
end
|
121
121
|
|
122
122
|
it 'returns an escape sequence when the style is negative' do
|
123
|
-
|
123
|
+
described.string('negative').must_equal("\e[7m")
|
124
124
|
end
|
125
125
|
|
126
126
|
it 'returns an escape sequence when the style is positive' do
|
127
|
-
|
127
|
+
described.string('positive').must_equal("\e[27m")
|
128
128
|
end
|
129
129
|
|
130
130
|
it 'returns an escape sequence when the style is reset' do
|
131
|
-
|
131
|
+
described.string('reset').must_equal("\e[0m")
|
132
132
|
end
|
133
133
|
|
134
134
|
it 'returns an escape sequence when the style is normal' do
|
135
|
-
|
135
|
+
described.string('normal').must_equal("\e[24m\e[22m\e[27m")
|
136
136
|
end
|
137
137
|
|
138
138
|
it 'returns an escape sequence when the style is dim' do
|
139
|
-
|
139
|
+
described.string('dim').must_equal("\e[2m")
|
140
140
|
end
|
141
141
|
|
142
142
|
it 'returns an escape sequence when the style is show_cursor' do
|
143
|
-
|
143
|
+
described.string('show_cursor').must_equal("\e[?25h")
|
144
144
|
end
|
145
145
|
|
146
146
|
it 'returns an escape sequence when the style is underline' do
|
147
|
-
|
147
|
+
described.string('underline').must_equal("\e[4m")
|
148
148
|
end
|
149
149
|
|
150
150
|
it 'returns an escape sequence when the style is underline off' do
|
151
|
-
|
151
|
+
described.string('underline_off').must_equal("\e[24m")
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
@@ -59,6 +59,17 @@ module Vedeu
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
+
describe '#background=' do
|
63
|
+
subject { receiver.background = '#987654' }
|
64
|
+
|
65
|
+
it { subject.must_equal('#987654') }
|
66
|
+
|
67
|
+
it do
|
68
|
+
subject
|
69
|
+
receiver.attributes[:background].must_equal('#987654')
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
62
73
|
describe '#foreground' do
|
63
74
|
subject { receiver.foreground }
|
64
75
|
|
@@ -74,6 +85,17 @@ module Vedeu
|
|
74
85
|
end
|
75
86
|
end
|
76
87
|
|
88
|
+
describe '#foreground=' do
|
89
|
+
subject { receiver.foreground = '#123456' }
|
90
|
+
|
91
|
+
it { subject.must_equal('#123456') }
|
92
|
+
|
93
|
+
it do
|
94
|
+
subject
|
95
|
+
receiver.attributes[:foreground].must_equal('#123456')
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
77
99
|
describe '#parent_background' do
|
78
100
|
subject { receiver.parent_background }
|
79
101
|
|
@@ -24,27 +24,29 @@ module Vedeu
|
|
24
24
|
describe '.coerce' do
|
25
25
|
let(:_value) {}
|
26
26
|
|
27
|
-
subject { described.coerce(
|
27
|
+
subject { described.coerce(_value) }
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
context 'when the value is nil' do
|
30
|
+
it { subject.must_be_instance_of(String) }
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when the value is a Vedeu::Background' do
|
34
|
+
let(:_value) { Vedeu::Background.new }
|
35
|
+
|
36
|
+
it { subject.must_equal(_value) }
|
37
|
+
end
|
32
38
|
|
33
|
-
|
34
|
-
|
35
|
-
# end
|
39
|
+
context 'when the value is a Vedeu::Foreground' do
|
40
|
+
let(:_value) { Vedeu::Foreground.new }
|
36
41
|
|
37
|
-
|
38
|
-
|
39
|
-
# end
|
42
|
+
it { subject.must_equal(_value) }
|
43
|
+
end
|
40
44
|
|
41
|
-
|
42
|
-
|
43
|
-
# end
|
45
|
+
context 'when the value is not a polymorphic Colour' do
|
46
|
+
let(:_value) { '#aadd00' }
|
44
47
|
|
45
|
-
|
46
|
-
|
47
|
-
# end
|
48
|
+
it { subject.must_be_instance_of(Vedeu::Translator) }
|
49
|
+
end
|
48
50
|
end
|
49
51
|
|
50
52
|
describe '#eql?' do
|