vedeu 0.2.11 → 0.2.12
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/examples/borders_app.rb +171 -0
- data/lib/vedeu.rb +1 -1
- data/lib/vedeu/api/interface.rb +12 -0
- data/lib/vedeu/api/menu.rb +1 -1
- data/lib/vedeu/colours/colour.rb +1 -1
- data/lib/vedeu/models/border.rb +238 -0
- data/lib/vedeu/models/char.rb +1 -1
- data/lib/vedeu/models/composition.rb +1 -1
- data/lib/vedeu/models/geometry.rb +1 -1
- data/lib/vedeu/models/line.rb +1 -1
- data/lib/vedeu/models/stream.rb +1 -1
- data/lib/vedeu/output/output.rb +1 -1
- data/lib/vedeu/output/viewport.rb +34 -3
- data/lib/vedeu/repositories/models/cursor.rb +34 -7
- data/lib/vedeu/repositories/models/event.rb +1 -1
- data/lib/vedeu/repositories/models/group.rb +1 -1
- data/lib/vedeu/repositories/models/interface.rb +14 -6
- data/lib/vedeu/repositories/models/keymap.rb +1 -1
- data/lib/vedeu/repositories/models/offset.rb +1 -1
- data/lib/vedeu/support/trace.rb +1 -1
- data/test/integration/views/basic_view_test.rb +19 -0
- data/test/lib/vedeu/api/api_test.rb +6 -5
- data/test/lib/vedeu/api/helpers_test.rb +2 -6
- data/test/lib/vedeu/api/interface_test.rb +53 -45
- data/test/lib/vedeu/api/menu_test.rb +6 -0
- data/test/lib/vedeu/api/stream_test.rb +1 -3
- data/test/lib/vedeu/application_test.rb +6 -12
- data/test/lib/vedeu/colours/colour_test.rb +16 -5
- data/test/lib/vedeu/colours/translator_test.rb +7 -2
- data/test/lib/vedeu/configuration/cli_test.rb +9 -0
- data/test/lib/vedeu/input/input_test.rb +5 -5
- data/test/lib/vedeu/launcher_test.rb +9 -3
- data/test/lib/vedeu/models/border_test.rb +197 -0
- data/test/lib/vedeu/models/char_test.rb +18 -15
- data/test/lib/vedeu/models/composition_test.rb +6 -7
- data/test/lib/vedeu/models/geometry_test.rb +43 -49
- data/test/lib/vedeu/models/key_test.rb +7 -5
- data/test/lib/vedeu/models/line_test.rb +12 -16
- data/test/lib/vedeu/models/stream_test.rb +20 -10
- data/test/lib/vedeu/models/style_test.rb +9 -10
- data/test/lib/vedeu/output/compositor_test.rb +7 -22
- data/test/lib/vedeu/output/output_test.rb +34 -33
- data/test/lib/vedeu/output/viewport_test.rb +6 -6
- data/test/lib/vedeu/repositories/models/buffer_test.rb +13 -18
- data/test/lib/vedeu/repositories/models/cursor_test.rb +21 -21
- data/test/lib/vedeu/repositories/models/event_test.rb +10 -4
- data/test/lib/vedeu/{models → repositories/models}/group_test.rb +8 -9
- data/test/lib/vedeu/repositories/models/interface_test.rb +37 -17
- data/test/lib/vedeu/repositories/models/keymap_test.rb +6 -6
- data/test/lib/vedeu/repositories/models/menu_test.rb +6 -3
- data/test/lib/vedeu/repositories/models/offset_test.rb +6 -3
- data/test/lib/vedeu/support/bounding_area_test.rb +28 -36
- data/test/lib/vedeu/support/grid_test.rb +8 -0
- data/test/lib/vedeu/support/keymap_validator_test.rb +5 -8
- data/test/lib/vedeu/support/position_test.rb +3 -3
- data/test/lib/vedeu/support/registrar_test.rb +13 -7
- data/test/lib/vedeu/support/sentence_test.rb +9 -2
- data/test/lib/vedeu/support/trace_test.rb +5 -3
- data/test/test_helper.rb +12 -0
- data/vedeu.gemspec +1 -1
- metadata +8 -7
- data/lib/vedeu/output/view.rb +0 -64
- data/test/lib/vedeu/output/view_test.rb +0 -21
@@ -4,33 +4,36 @@ module Vedeu
|
|
4
4
|
|
5
5
|
describe Char do
|
6
6
|
|
7
|
-
let(:
|
7
|
+
let(:described) { Char.new(attributes) }
|
8
|
+
let(:char) { Char.new(attributes) }
|
9
|
+
let(:parent) {
|
10
|
+
{
|
11
|
+
colour: {
|
12
|
+
foreground: '#00ff00',
|
13
|
+
background: '#ff00ff'
|
14
|
+
},
|
15
|
+
style: []
|
16
|
+
}
|
17
|
+
}
|
8
18
|
let(:attributes) {
|
9
19
|
{
|
10
20
|
colour: { foreground: '#ffff00', background: '#0000ff' },
|
11
|
-
parent:
|
12
|
-
colour: {
|
13
|
-
foreground: '#00ff00',
|
14
|
-
background: '#ff00ff'
|
15
|
-
},
|
16
|
-
style: []
|
17
|
-
},
|
21
|
+
parent: parent,
|
18
22
|
style: [],
|
19
23
|
value: value,
|
20
24
|
}
|
21
25
|
}
|
22
|
-
let(:value)
|
26
|
+
let(:value) { 'a' }
|
23
27
|
|
24
28
|
describe '#initialize' do
|
25
|
-
it
|
26
|
-
|
27
|
-
|
29
|
+
it { return_type_for(described, Char) }
|
30
|
+
it { assigns(described, '@attributes', attributes) }
|
31
|
+
it { assigns(described, '@parent', parent) }
|
32
|
+
it { assigns(described, '@value', value) }
|
28
33
|
end
|
29
34
|
|
30
35
|
describe '#to_s' do
|
31
|
-
it
|
32
|
-
char.to_s.must_be_instance_of(String)
|
33
|
-
end
|
36
|
+
it { return_type_for(described.to_s, String) }
|
34
37
|
|
35
38
|
it 'returns the escape sequences and content' do
|
36
39
|
# - char colours and style as set in Stream#chars.
|
@@ -5,15 +5,14 @@ require 'json'
|
|
5
5
|
module Vedeu
|
6
6
|
|
7
7
|
describe Composition do
|
8
|
+
let(:described) { Composition.new(attributes) }
|
9
|
+
let(:attributes) { {} }
|
8
10
|
|
9
11
|
before { Buffers.reset }
|
10
12
|
|
11
13
|
describe '#initialize' do
|
12
|
-
it
|
13
|
-
|
14
|
-
|
15
|
-
Composition.new(attributes).must_be_instance_of(Composition)
|
16
|
-
end
|
14
|
+
it { return_type_for(described, Composition) }
|
15
|
+
it { assigns(described, '@attributes', { interfaces: [] }) }
|
17
16
|
end
|
18
17
|
|
19
18
|
describe '#interfaces' do
|
@@ -31,13 +30,13 @@ module Vedeu
|
|
31
30
|
end
|
32
31
|
|
33
32
|
it 'returns an empty collection when no interfaces are associated' do
|
34
|
-
|
33
|
+
described.interfaces.must_be_empty
|
35
34
|
end
|
36
35
|
end
|
37
36
|
|
38
37
|
describe '#method_missing' do
|
39
38
|
it 'returns nil' do
|
40
|
-
|
39
|
+
described.some_missing_method(:test).must_equal(nil)
|
41
40
|
end
|
42
41
|
end
|
43
42
|
|
@@ -4,83 +4,82 @@ module Vedeu
|
|
4
4
|
|
5
5
|
describe Geometry do
|
6
6
|
|
7
|
+
let(:described) { Geometry.new(attributes) }
|
8
|
+
let(:attributes) { {} }
|
9
|
+
|
10
|
+
before do
|
11
|
+
IO.console.stubs(:winsize).returns([25, 80])
|
12
|
+
end
|
13
|
+
|
7
14
|
describe '#initialize' do
|
8
|
-
it
|
9
|
-
|
10
|
-
|
11
|
-
|
15
|
+
it { return_type_for(described, Geometry) }
|
16
|
+
it { assigns(described, '@attributes', {
|
17
|
+
centred: false,
|
18
|
+
height: 25,
|
19
|
+
width: 80,
|
20
|
+
x: 1,
|
21
|
+
xn: nil,
|
22
|
+
y: 1,
|
23
|
+
yn: nil,
|
24
|
+
})
|
25
|
+
}
|
26
|
+
it { assigns(described, '@centred', false) }
|
27
|
+
it { assigns(described, '@height', 25) }
|
28
|
+
it { assigns(described, '@width', 80) }
|
12
29
|
end
|
13
30
|
|
14
31
|
describe '#y' do
|
15
32
|
it 'returns the value of y when it is a proc' do
|
16
|
-
|
17
|
-
|
18
|
-
geometry.y.must_equal(17)
|
19
|
-
end
|
33
|
+
geometry = Geometry.new({ y: proc { 17 } })
|
34
|
+
geometry.y.must_equal(17)
|
20
35
|
end
|
21
36
|
|
22
37
|
it 'returns the value of y when just an attribute' do
|
23
|
-
|
24
|
-
|
25
|
-
geometry.y.must_equal(19)
|
26
|
-
end
|
38
|
+
geometry = Geometry.new({ y: 19 })
|
39
|
+
geometry.y.must_equal(19)
|
27
40
|
end
|
28
41
|
end
|
29
42
|
|
30
43
|
describe '#yn' do
|
31
44
|
it 'returns the value of yn when it is a proc' do
|
32
|
-
|
33
|
-
|
34
|
-
geometry.yn.must_equal(17)
|
35
|
-
end
|
45
|
+
geometry = Geometry.new({ yn: proc { 17 } })
|
46
|
+
geometry.yn.must_equal(17)
|
36
47
|
end
|
37
48
|
|
38
49
|
it 'returns the value of yn when just an attribute' do
|
39
|
-
|
40
|
-
|
41
|
-
geometry.yn.must_equal(19)
|
42
|
-
end
|
50
|
+
geometry = Geometry.new({ yn: 19 })
|
51
|
+
geometry.yn.must_equal(19)
|
43
52
|
end
|
44
53
|
end
|
45
54
|
|
46
55
|
describe '#x' do
|
47
56
|
it 'returns the value of x when it is a proc' do
|
48
|
-
|
49
|
-
|
50
|
-
geometry.x.must_equal(58)
|
51
|
-
end
|
57
|
+
geometry = Geometry.new({ x: proc { 58 } })
|
58
|
+
geometry.x.must_equal(58)
|
52
59
|
end
|
53
60
|
|
54
61
|
it 'returns the value of x when just an attribute' do
|
55
|
-
|
56
|
-
|
57
|
-
geometry.x.must_equal(64)
|
58
|
-
end
|
62
|
+
geometry = Geometry.new({ x: 64 })
|
63
|
+
geometry.x.must_equal(64)
|
59
64
|
end
|
60
65
|
end
|
61
66
|
|
62
67
|
describe '#xn' do
|
63
68
|
it 'returns the value of xn when it is a proc' do
|
64
|
-
|
65
|
-
|
66
|
-
geometry.xn.must_equal(58)
|
67
|
-
end
|
69
|
+
geometry = Geometry.new({ xn: proc { 58 } })
|
70
|
+
geometry.xn.must_equal(58)
|
68
71
|
end
|
69
72
|
|
70
73
|
it 'returns the value of xn when just an attribute' do
|
71
|
-
|
72
|
-
|
73
|
-
geometry.xn.must_equal(64)
|
74
|
-
end
|
74
|
+
geometry = Geometry.new({ xn: 64 })
|
75
|
+
geometry.xn.must_equal(64)
|
75
76
|
end
|
76
77
|
end
|
77
78
|
|
78
79
|
describe '#width' do
|
79
80
|
it 'returns the viewport width when the interface fits the terminal' do
|
80
|
-
|
81
|
-
|
82
|
-
geometry.width.must_equal(60)
|
83
|
-
end
|
81
|
+
geometry = Geometry.new({ width: 60, height: 1, x: 5, y: 1 })
|
82
|
+
geometry.width.must_equal(60)
|
84
83
|
end
|
85
84
|
|
86
85
|
it 'returns the viewport width when the interface does not fit the ' \
|
@@ -101,10 +100,8 @@ module Vedeu
|
|
101
100
|
|
102
101
|
describe '#height' do
|
103
102
|
it 'returns the viewport height when the interface fits the terminal' do
|
104
|
-
|
105
|
-
|
106
|
-
geometry.height.must_equal(20)
|
107
|
-
end
|
103
|
+
geometry = Geometry.new({ width: 5, height: 20, x: 1, y: 5 })
|
104
|
+
geometry.height.must_equal(20)
|
108
105
|
end
|
109
106
|
|
110
107
|
it 'returns the viewport height when the interface does not fit the ' \
|
@@ -130,11 +127,8 @@ module Vedeu
|
|
130
127
|
end
|
131
128
|
|
132
129
|
it 'returns the origin for the interface' do
|
133
|
-
|
134
|
-
|
135
|
-
geometry = Geometry.new({ width: 5, height: 5, centred: true })
|
136
|
-
geometry.origin.must_equal("\e[10;38H")
|
137
|
-
end
|
130
|
+
geometry = Geometry.new({ width: 5, height: 5, centred: true })
|
131
|
+
geometry.origin.must_equal("\e[10;38H")
|
138
132
|
end
|
139
133
|
|
140
134
|
it 'returns the line position relative to the origin' do
|
@@ -4,13 +4,15 @@ module Vedeu
|
|
4
4
|
|
5
5
|
describe Key do
|
6
6
|
|
7
|
-
let(:
|
8
|
-
let(:
|
7
|
+
let(:described) { Key.new(input, output) }
|
8
|
+
let(:input) { '' }
|
9
|
+
let(:output) { Proc.new { :output } }
|
9
10
|
|
10
11
|
describe '#initialize' do
|
11
|
-
it
|
12
|
-
|
13
|
-
|
12
|
+
it { return_type_for(described, Key) }
|
13
|
+
it { assigns(described, '@input', input) }
|
14
|
+
|
15
|
+
it { skip; assigns(described, '@output', output) }
|
14
16
|
end
|
15
17
|
|
16
18
|
describe '#input' do
|
@@ -3,6 +3,8 @@ require 'test_helper'
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
5
|
describe Line do
|
6
|
+
|
7
|
+
let(:described) { Line.new(attributes) }
|
6
8
|
let(:line) { Line.new(attributes) }
|
7
9
|
let(:attributes) {
|
8
10
|
{
|
@@ -27,31 +29,29 @@ module Vedeu
|
|
27
29
|
}
|
28
30
|
|
29
31
|
describe '#initialize' do
|
30
|
-
it
|
31
|
-
|
32
|
-
|
32
|
+
it { return_type_for(described, Line) }
|
33
|
+
it { assigns(described, '@attributes', attributes) }
|
34
|
+
it { assigns(described, '@parent', nil) }
|
33
35
|
end
|
34
36
|
|
35
37
|
describe '#attributes' do
|
36
38
|
it 'returns the attributes' do
|
37
|
-
|
39
|
+
described.attributes.must_equal(attributes)
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
41
43
|
describe '#chars' do
|
42
|
-
it
|
43
|
-
line.chars.must_be_instance_of(Array)
|
44
|
-
end
|
44
|
+
it { return_type_for(described.chars, Array) }
|
45
45
|
|
46
46
|
context 'when there is no content' do
|
47
|
-
before {
|
47
|
+
before { described.stubs(:size).returns(0) }
|
48
48
|
|
49
|
-
it {
|
49
|
+
it { described.chars.must_equal([]) }
|
50
50
|
end
|
51
51
|
|
52
52
|
context 'when there is content' do
|
53
53
|
it 'returns an Array' do
|
54
|
-
|
54
|
+
described.chars.must_equal(
|
55
55
|
[
|
56
56
|
"\e[38;2;255;0;0mS", "\e[38;2;255;0;0mo", "\e[38;2;255;0;0mm",
|
57
57
|
"\e[38;2;255;0;0me", "\e[38;2;255;0;0mt", "\e[38;2;255;0;0mh",
|
@@ -90,9 +90,7 @@ module Vedeu
|
|
90
90
|
end
|
91
91
|
|
92
92
|
describe '#size' do
|
93
|
-
it
|
94
|
-
line.size.must_be_instance_of(Fixnum)
|
95
|
-
end
|
93
|
+
it { return_type_for(described.size, Fixnum) }
|
96
94
|
|
97
95
|
it 'returns the size of the line' do
|
98
96
|
line.size.must_equal(53)
|
@@ -100,9 +98,7 @@ module Vedeu
|
|
100
98
|
end
|
101
99
|
|
102
100
|
describe '#streams' do
|
103
|
-
it
|
104
|
-
line.streams.must_be_instance_of(Array)
|
105
|
-
end
|
101
|
+
it { return_type_for(described.streams, Array) }
|
106
102
|
end
|
107
103
|
|
108
104
|
describe '#to_s' do
|
@@ -3,6 +3,18 @@ require 'test_helper'
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
5
|
describe Stream do
|
6
|
+
|
7
|
+
let(:described) { Stream.new(attributes) }
|
8
|
+
let(:attributes) {
|
9
|
+
{
|
10
|
+
colour: colour,
|
11
|
+
parent: parent,
|
12
|
+
text: text,
|
13
|
+
style: style,
|
14
|
+
width: width,
|
15
|
+
align: align
|
16
|
+
}
|
17
|
+
}
|
6
18
|
let(:stream) {
|
7
19
|
Stream.new({
|
8
20
|
colour: colour,
|
@@ -26,10 +38,12 @@ module Vedeu
|
|
26
38
|
let(:width) { 9 }
|
27
39
|
|
28
40
|
describe '#initialize' do
|
29
|
-
it
|
30
|
-
|
31
|
-
|
32
|
-
|
41
|
+
it { described.must_be_instance_of(Stream) }
|
42
|
+
it { assigns(described, '@attributes', attributes) }
|
43
|
+
it { assigns(described, '@align', align) }
|
44
|
+
it { assigns(described, '@text', text) }
|
45
|
+
it { assigns(described, '@width', width) }
|
46
|
+
it { assigns(described, '@parent', parent) }
|
33
47
|
end
|
34
48
|
|
35
49
|
describe '#chars' do
|
@@ -43,9 +57,7 @@ module Vedeu
|
|
43
57
|
}
|
44
58
|
}
|
45
59
|
|
46
|
-
it
|
47
|
-
stream.chars.must_be_instance_of(Array)
|
48
|
-
end
|
60
|
+
it { return_type_for(described.chars, Array) }
|
49
61
|
|
50
62
|
context 'when there is content' do
|
51
63
|
it 'returns a collection of strings containing escape sequences and ' \
|
@@ -109,9 +121,7 @@ module Vedeu
|
|
109
121
|
end
|
110
122
|
|
111
123
|
describe '#size' do
|
112
|
-
it
|
113
|
-
stream.size.must_be_instance_of(Fixnum)
|
114
|
-
end
|
124
|
+
it { return_type_for(described.size, Fixnum) }
|
115
125
|
|
116
126
|
it 'returns the size of the stream' do
|
117
127
|
stream.size.must_equal(9)
|
@@ -3,25 +3,24 @@ require 'test_helper'
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
5
|
describe Style do
|
6
|
-
describe '#initialize' do
|
7
|
-
it 'returns an instance of itself' do
|
8
|
-
values = ''
|
9
6
|
|
10
|
-
|
11
|
-
|
7
|
+
let(:described) { Style.new(values) }
|
8
|
+
let(:values) { ['bold'] }
|
9
|
+
|
10
|
+
describe '#initialize' do
|
11
|
+
it { described.must_be_instance_of(Style) }
|
12
|
+
it { assigns(described, '@values', values) }
|
12
13
|
end
|
13
14
|
|
14
15
|
describe '#attributes' do
|
15
16
|
it 'returns an attributes hash for this instance' do
|
16
|
-
|
17
|
-
{
|
18
|
-
style: ['bold']
|
19
|
-
}
|
20
|
-
)
|
17
|
+
described.attributes.must_equal({ style: ['bold'] })
|
21
18
|
end
|
22
19
|
end
|
23
20
|
|
24
21
|
describe '#to_s' do
|
22
|
+
it { return_type_for(described.to_s, String) }
|
23
|
+
|
25
24
|
describe 'for a single style' do
|
26
25
|
let(:values) { 'normal' }
|
27
26
|
|
@@ -3,6 +3,8 @@ require 'test_helper'
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
5
|
describe Compositor do
|
6
|
+
|
7
|
+
let(:described) { Compositor.new(interface, buffer) }
|
6
8
|
let(:interface) {
|
7
9
|
{
|
8
10
|
name: 'indium'
|
@@ -18,31 +20,14 @@ module Vedeu
|
|
18
20
|
end
|
19
21
|
|
20
22
|
describe '#initialize' do
|
21
|
-
|
22
|
-
|
23
|
-
it
|
24
|
-
subject.must_be_instance_of(Compositor)
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'assigns the interface' do
|
28
|
-
subject.instance_variable_get("@interface").must_equal(interface)
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'assigns the buffer' do
|
32
|
-
subject.instance_variable_get("@buffer").must_equal(buffer)
|
33
|
-
end
|
23
|
+
it { return_type_for(described, Compositor) }
|
24
|
+
it { assigns(described, '@interface', interface) }
|
25
|
+
it { assigns(described, '@buffer', buffer) }
|
34
26
|
end
|
35
27
|
|
36
28
|
describe '#compose' do
|
37
|
-
|
38
|
-
|
39
|
-
it 'returns an Array' do
|
40
|
-
subject.must_be_instance_of(Array)
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'returns the updated interface attributes' do
|
44
|
-
subject.must_equal([{}])
|
45
|
-
end
|
29
|
+
it { return_type_for(described.compose, Array) }
|
30
|
+
it { return_value_for(described.compose, [{}]) }
|
46
31
|
end
|
47
32
|
|
48
33
|
end # Compositor
|