vedeu 0.4.16 → 0.4.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vedeu/api.rb +7 -21
- data/lib/vedeu/bindings.rb +2 -6
- data/lib/vedeu/buffers/buffer.rb +29 -34
- data/lib/vedeu/cursor/cursor.rb +5 -2
- data/lib/vedeu/distributed/all.rb +5 -5
- data/lib/vedeu/distributed/server.rb +1 -1
- data/lib/vedeu/dsl/components/border.rb +1 -2
- data/lib/vedeu/dsl/components/geometry.rb +0 -47
- data/lib/vedeu/dsl/interface.rb +4 -11
- data/lib/vedeu/dsl/line.rb +1 -2
- data/lib/vedeu/dsl/shared/all.rb +1 -2
- data/lib/vedeu/dsl/shared/{colour.rb → presentation.rb} +27 -4
- data/lib/vedeu/dsl/shared/use.rb +50 -29
- data/lib/vedeu/dsl/stream.rb +1 -2
- data/lib/vedeu/geometry/geometry.rb +22 -11
- data/lib/vedeu/geometry/index_position.rb +0 -19
- data/lib/vedeu/geometry/position_validator.rb +8 -8
- data/lib/vedeu/models/interface.rb +34 -76
- data/lib/vedeu/models/null_interface.rb +5 -0
- data/lib/vedeu/models/stream.rb +1 -1
- data/lib/vedeu/output/border.rb +25 -41
- data/lib/vedeu/output/clear.rb +1 -7
- data/lib/vedeu/output/esc.rb +10 -10
- data/lib/vedeu/output/presentation.rb +2 -0
- data/lib/vedeu/output/renderers/escape_sequence_renderer.rb +3 -0
- data/lib/vedeu/repositories/model.rb +6 -0
- data/lib/vedeu/repositories/repositories/groups.rb +12 -0
- data/lib/vedeu/repositories/repository.rb +11 -8
- data/lib/vedeu/storage/all.rb +4 -4
- data/lib/vedeu/support/visibility.rb +8 -0
- data/test/lib/vedeu/buffers/buffer_test.rb +0 -2
- data/test/lib/vedeu/cursor/cursor_test.rb +14 -0
- data/test/lib/vedeu/dsl/components/border_test.rb +2 -2
- data/test/lib/vedeu/dsl/components/geometry_test.rb +63 -82
- data/test/lib/vedeu/dsl/components/keymap_test.rb +3 -3
- data/test/lib/vedeu/dsl/components/menu_test.rb +8 -8
- data/test/lib/vedeu/dsl/interface_test.rb +14 -22
- data/test/lib/vedeu/dsl/line_test.rb +4 -4
- data/test/lib/vedeu/dsl/shared/{colour_test.rb → presentation_test.rb} +19 -11
- data/test/lib/vedeu/dsl/shared/text_test.rb +15 -15
- data/test/lib/vedeu/dsl/shared/use_test.rb +24 -7
- data/test/lib/vedeu/geometry/geometry_test.rb +22 -19
- data/test/lib/vedeu/geometry/grid_test.rb +3 -3
- data/test/lib/vedeu/geometry/index_position_test.rb +0 -45
- data/test/lib/vedeu/geometry/position_test.rb +5 -5
- data/test/lib/vedeu/models/cell_test.rb +3 -3
- data/test/lib/vedeu/models/char_test.rb +5 -5
- data/test/lib/vedeu/models/interface_test.rb +7 -53
- data/test/lib/vedeu/models/null_test.rb +2 -2
- data/test/lib/vedeu/models/stream_test.rb +5 -5
- data/test/lib/vedeu/output/border_test.rb +1 -0
- data/test/lib/vedeu/output/colour_test.rb +16 -16
- data/test/lib/vedeu/output/esc_test.rb +15 -1
- data/test/lib/vedeu/output/html_char_test.rb +4 -4
- data/test/lib/vedeu/output/style_test.rb +15 -13
- data/test/lib/vedeu/output/text_test.rb +3 -3
- data/test/lib/vedeu/repositories/collection_test.rb +2 -2
- data/test/lib/vedeu/repositories/model_test.rb +19 -0
- data/test/lib/vedeu/repositories/repositories/groups_test.rb +22 -0
- data/test/lib/vedeu/repositories/repository_test.rb +50 -16
- data/test/lib/vedeu/support/common_test.rb +5 -5
- data/test/lib/vedeu/support/terminal_test.rb +3 -3
- data/test/lib/vedeu/support/visibility_test.rb +8 -0
- data/test/support/helpers/model_test_class.rb +18 -0
- data/test/test_helper.rb +1 -1
- data/vedeu.gemspec +2 -2
- metadata +7 -20
- data/lib/vedeu/dsl/shared/style.rb +0 -39
- data/test/lib/vedeu/dsl/shared/style_test.rb +0 -25
- data/test/support/helpers/all.rb +0 -5
- data/test/support/helpers/dsl_model_test_class.rb +0 -25
- data/test/support/helpers/helpers.rb +0 -17
- data/test/support/helpers/repositories.rb +0 -26
- data/test/support/helpers/repository_test_module.rb +0 -21
@@ -55,13 +55,13 @@ module Vedeu
|
|
55
55
|
end
|
56
56
|
|
57
57
|
describe '#name' do
|
58
|
-
let(:
|
58
|
+
let(:_value) { 'gold' }
|
59
59
|
|
60
|
-
subject { instance.name(
|
60
|
+
subject { instance.name(_value) }
|
61
61
|
|
62
62
|
it 'defines the name of the keymap' do
|
63
63
|
subject
|
64
|
-
model.name.must_equal(
|
64
|
+
model.name.must_equal(_value)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -24,9 +24,9 @@ module Vedeu
|
|
24
24
|
end
|
25
25
|
|
26
26
|
describe '#item' do
|
27
|
-
let(:
|
27
|
+
let(:_value) { :platinum }
|
28
28
|
|
29
|
-
subject { instance.item(
|
29
|
+
subject { instance.item(_value) }
|
30
30
|
|
31
31
|
context 'when items are provided' do
|
32
32
|
it { subject.must_equal([:sodium,
|
@@ -38,25 +38,25 @@ module Vedeu
|
|
38
38
|
end
|
39
39
|
|
40
40
|
describe '#items' do
|
41
|
-
let(:
|
41
|
+
let(:_value) { [] }
|
42
42
|
|
43
|
-
subject { instance.items(
|
43
|
+
subject { instance.items(_value) }
|
44
44
|
|
45
45
|
context 'when no items are provided' do
|
46
46
|
it { subject.must_equal([]) }
|
47
47
|
end
|
48
48
|
|
49
49
|
context 'when items are provided' do
|
50
|
-
let(:
|
50
|
+
let(:_value) { [:gold, :silver, :tin] }
|
51
51
|
|
52
|
-
it { subject.must_equal(
|
52
|
+
it { subject.must_equal(_value)}
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
describe '#name' do
|
57
|
-
let(:
|
57
|
+
let(:_value) { 'metals' }
|
58
58
|
|
59
|
-
subject { instance.name(
|
59
|
+
subject { instance.name(_value) }
|
60
60
|
|
61
61
|
it 'returns the name of the menu' do
|
62
62
|
subject
|
@@ -69,11 +69,11 @@ module Vedeu
|
|
69
69
|
end
|
70
70
|
|
71
71
|
describe '#cursor' do
|
72
|
-
let(:
|
72
|
+
let(:_value) {}
|
73
73
|
|
74
74
|
before { Vedeu.cursors.reset }
|
75
75
|
|
76
|
-
subject { instance.cursor(
|
76
|
+
subject { instance.cursor(_value) }
|
77
77
|
|
78
78
|
it {
|
79
79
|
subject
|
@@ -81,7 +81,7 @@ module Vedeu
|
|
81
81
|
}
|
82
82
|
|
83
83
|
context 'when the value is false' do
|
84
|
-
let(:
|
84
|
+
let(:_value) { false }
|
85
85
|
|
86
86
|
it {
|
87
87
|
subject
|
@@ -90,7 +90,7 @@ module Vedeu
|
|
90
90
|
end
|
91
91
|
|
92
92
|
context 'when the value is nil' do
|
93
|
-
let(:
|
93
|
+
let(:_value) {}
|
94
94
|
|
95
95
|
it {
|
96
96
|
subject
|
@@ -99,7 +99,7 @@ module Vedeu
|
|
99
99
|
end
|
100
100
|
|
101
101
|
context 'when the value is :show' do
|
102
|
-
let(:
|
102
|
+
let(:_value) { :show }
|
103
103
|
|
104
104
|
it {
|
105
105
|
subject
|
@@ -108,7 +108,7 @@ module Vedeu
|
|
108
108
|
end
|
109
109
|
|
110
110
|
context 'when the value is true' do
|
111
|
-
let(:
|
111
|
+
let(:_value) { true }
|
112
112
|
|
113
113
|
it {
|
114
114
|
subject
|
@@ -117,7 +117,7 @@ module Vedeu
|
|
117
117
|
end
|
118
118
|
|
119
119
|
context 'when the value is :yes' do
|
120
|
-
let(:
|
120
|
+
let(:_value) { :yes }
|
121
121
|
|
122
122
|
it {
|
123
123
|
subject
|
@@ -136,13 +136,9 @@ module Vedeu
|
|
136
136
|
end
|
137
137
|
|
138
138
|
describe '#delay' do
|
139
|
-
|
140
|
-
Vedeu.interface 'cobalt' do
|
141
|
-
delay 0.25
|
142
|
-
end
|
139
|
+
subject { instance.delay(0.25) }
|
143
140
|
|
144
|
-
|
145
|
-
end
|
141
|
+
it { subject; model.delay.must_equal(0.25) }
|
146
142
|
end
|
147
143
|
|
148
144
|
describe '#focus!' do
|
@@ -205,16 +201,16 @@ module Vedeu
|
|
205
201
|
end
|
206
202
|
|
207
203
|
describe '#group' do
|
208
|
-
let(:
|
204
|
+
let(:_value) { 'elements' }
|
209
205
|
|
210
206
|
before { Vedeu.groups.reset }
|
211
207
|
|
212
|
-
subject { instance.group(
|
208
|
+
subject { instance.group(_value) }
|
213
209
|
|
214
210
|
it { subject.must_be_instance_of(Vedeu::Group) }
|
215
211
|
|
216
212
|
context 'when the value is empty or nil' do
|
217
|
-
let(:
|
213
|
+
let(:_value) { '' }
|
218
214
|
|
219
215
|
it { subject.must_equal(false) }
|
220
216
|
end
|
@@ -267,13 +263,9 @@ module Vedeu
|
|
267
263
|
end
|
268
264
|
|
269
265
|
describe '#name' do
|
270
|
-
|
271
|
-
Vedeu.interface do
|
272
|
-
name 'nickel'
|
273
|
-
end
|
266
|
+
subject { instance.name('nickel') }
|
274
267
|
|
275
|
-
|
276
|
-
end
|
268
|
+
it { subject; model.name.must_equal('nickel') }
|
277
269
|
end
|
278
270
|
|
279
271
|
describe '#show!' do
|
@@ -34,7 +34,7 @@ module Vedeu
|
|
34
34
|
end
|
35
35
|
|
36
36
|
describe '#line' do
|
37
|
-
let(:
|
37
|
+
let(:_value) { '' }
|
38
38
|
|
39
39
|
subject {
|
40
40
|
instance.line do
|
@@ -50,13 +50,13 @@ module Vedeu
|
|
50
50
|
|
51
51
|
context 'when the block is not given' do
|
52
52
|
context 'when the value is given' do
|
53
|
-
subject { instance.line(
|
53
|
+
subject { instance.line(_value) }
|
54
54
|
end
|
55
55
|
|
56
56
|
context 'when the value is not given' do
|
57
|
-
let(:
|
57
|
+
let(:_value) {}
|
58
58
|
|
59
|
-
subject { instance.line(
|
59
|
+
subject { instance.line(_value) }
|
60
60
|
|
61
61
|
it { proc { subject }.must_raise(InvalidSyntax) }
|
62
62
|
end
|
@@ -4,23 +4,23 @@ module Vedeu
|
|
4
4
|
|
5
5
|
module DSL
|
6
6
|
|
7
|
-
describe
|
7
|
+
describe Presentation do
|
8
8
|
|
9
|
-
let(:described) { Vedeu::DSL::
|
10
|
-
let(:
|
9
|
+
let(:described) { Vedeu::DSL::Presentation }
|
10
|
+
let(:instance) { Vedeu::DSL::Interface.new(model) }
|
11
11
|
let(:model) { Vedeu::Interface.new }
|
12
12
|
let(:background) { '#00ff00' }
|
13
13
|
let(:foreground) { '#ff00ff' }
|
14
14
|
|
15
15
|
describe 'alias methods' do
|
16
|
-
it {
|
17
|
-
it {
|
18
|
-
it {
|
19
|
-
it {
|
16
|
+
it { instance.must_respond_to(:bg) }
|
17
|
+
it { instance.must_respond_to(:bgcolor) }
|
18
|
+
it { instance.must_respond_to(:fg) }
|
19
|
+
it { instance.must_respond_to(:fgcolor) }
|
20
20
|
end
|
21
21
|
|
22
22
|
describe '#background' do
|
23
|
-
subject {
|
23
|
+
subject { instance.background(background) }
|
24
24
|
|
25
25
|
it { subject.must_be_instance_of(Vedeu::Colour) }
|
26
26
|
|
@@ -32,7 +32,7 @@ module Vedeu
|
|
32
32
|
end
|
33
33
|
|
34
34
|
describe '#foreground' do
|
35
|
-
subject {
|
35
|
+
subject { instance.foreground(foreground) }
|
36
36
|
|
37
37
|
it { subject.must_be_instance_of(Vedeu::Colour) }
|
38
38
|
|
@@ -46,7 +46,7 @@ module Vedeu
|
|
46
46
|
describe '#colour' do
|
47
47
|
let(:attributes) { { background: background, foreground: foreground } }
|
48
48
|
|
49
|
-
subject {
|
49
|
+
subject { instance.colour(attributes) }
|
50
50
|
|
51
51
|
it { subject.must_be_instance_of(Vedeu::Colour) }
|
52
52
|
|
@@ -71,7 +71,15 @@ module Vedeu
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
-
|
74
|
+
describe '#style' do
|
75
|
+
let(:args) { :bold }
|
76
|
+
|
77
|
+
subject { instance.style(args) }
|
78
|
+
|
79
|
+
it { subject.must_be_instance_of(Vedeu::Style) }
|
80
|
+
end
|
81
|
+
|
82
|
+
end # Presentation
|
75
83
|
|
76
84
|
end # DSL
|
77
85
|
|
@@ -7,7 +7,7 @@ module Vedeu
|
|
7
7
|
describe Text do
|
8
8
|
|
9
9
|
describe '#text' do
|
10
|
-
let(:
|
10
|
+
let(:_value) {}
|
11
11
|
let(:options) { {} }
|
12
12
|
let(:modified_options) {
|
13
13
|
{
|
@@ -19,7 +19,7 @@ module Vedeu
|
|
19
19
|
let(:model) { Vedeu::Line.new }
|
20
20
|
let(:instance) { Vedeu::DSL::Line.new(model) }
|
21
21
|
|
22
|
-
subject { instance.text(
|
22
|
+
subject { instance.text(_value, options) }
|
23
23
|
|
24
24
|
context 'when the model is a Vedeu::Interface' do
|
25
25
|
let(:model) { Vedeu::Interface.new }
|
@@ -28,7 +28,7 @@ module Vedeu
|
|
28
28
|
it { subject.must_be_instance_of(Vedeu::Lines) }
|
29
29
|
|
30
30
|
it 'adds the text to the model' do
|
31
|
-
Vedeu::Text.expects(:add).with(
|
31
|
+
Vedeu::Text.expects(:add).with(_value, modified_options)
|
32
32
|
subject
|
33
33
|
end
|
34
34
|
end
|
@@ -40,7 +40,7 @@ module Vedeu
|
|
40
40
|
it { subject.must_be_instance_of(Vedeu::Streams) }
|
41
41
|
|
42
42
|
it 'adds the text to the model' do
|
43
|
-
Vedeu::Text.expects(:add).with(
|
43
|
+
Vedeu::Text.expects(:add).with(_value, modified_options)
|
44
44
|
subject
|
45
45
|
end
|
46
46
|
end
|
@@ -53,7 +53,7 @@ module Vedeu
|
|
53
53
|
it { subject.must_be_instance_of(Vedeu::Streams) }
|
54
54
|
|
55
55
|
it 'adds the text to the model' do
|
56
|
-
Vedeu::Text.expects(:add).with(
|
56
|
+
Vedeu::Text.expects(:add).with(_value, modified_options)
|
57
57
|
subject
|
58
58
|
end
|
59
59
|
end
|
@@ -63,8 +63,8 @@ module Vedeu
|
|
63
63
|
let(:anchor) { :align }
|
64
64
|
|
65
65
|
it 'adds the text to the model' do
|
66
|
-
Vedeu::Text.expects(:add).with(
|
67
|
-
instance.align(
|
66
|
+
Vedeu::Text.expects(:add).with(_value, modified_options)
|
67
|
+
instance.align(_value, options)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -72,8 +72,8 @@ module Vedeu
|
|
72
72
|
let(:anchor) { :center }
|
73
73
|
|
74
74
|
it 'adds the text to the model' do
|
75
|
-
Vedeu::Text.expects(:add).with(
|
76
|
-
instance.center(
|
75
|
+
Vedeu::Text.expects(:add).with(_value, modified_options)
|
76
|
+
instance.center(_value, options)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
@@ -81,8 +81,8 @@ module Vedeu
|
|
81
81
|
let(:anchor) { :centre }
|
82
82
|
|
83
83
|
it 'adds the text to the model' do
|
84
|
-
Vedeu::Text.expects(:add).with(
|
85
|
-
instance.centre(
|
84
|
+
Vedeu::Text.expects(:add).with(_value, modified_options)
|
85
|
+
instance.centre(_value, options)
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
@@ -90,8 +90,8 @@ module Vedeu
|
|
90
90
|
let(:anchor) { :left }
|
91
91
|
|
92
92
|
it 'adds the text to the model' do
|
93
|
-
Vedeu::Text.expects(:add).with(
|
94
|
-
instance.left(
|
93
|
+
Vedeu::Text.expects(:add).with(_value, modified_options)
|
94
|
+
instance.left(_value, options)
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
@@ -99,8 +99,8 @@ module Vedeu
|
|
99
99
|
let(:anchor) { :right }
|
100
100
|
|
101
101
|
it 'adds the text to the model' do
|
102
|
-
Vedeu::Text.expects(:add).with(
|
103
|
-
instance.right(
|
102
|
+
Vedeu::Text.expects(:add).with(_value, modified_options)
|
103
|
+
instance.right(_value, options)
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
@@ -6,17 +6,34 @@ module Vedeu
|
|
6
6
|
|
7
7
|
describe Use do
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
# before do
|
10
|
+
# Vedeu.interfaces.reset
|
11
|
+
# Vedeu.interface('hydrogen') do
|
12
|
+
# delay 0.75
|
13
|
+
# end
|
14
|
+
# Vedeu.interface('helium') do
|
15
|
+
# duplicate('hydrogen')
|
16
|
+
# end
|
17
|
+
# end
|
18
|
+
|
19
|
+
describe '#duplicate' do
|
20
|
+
context 'when the model exists' do
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when the model does not exist' do
|
12
24
|
end
|
25
|
+
end
|
13
26
|
|
14
|
-
|
15
|
-
|
16
|
-
|
27
|
+
describe '.use' do
|
28
|
+
context 'when the model exists' do
|
29
|
+
context 'and the attribute exists' do
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'but the attribute does not exist' do
|
17
33
|
end
|
34
|
+
end
|
18
35
|
|
19
|
-
|
36
|
+
context 'when the model does not exist' do
|
20
37
|
end
|
21
38
|
end
|
22
39
|
|
@@ -8,14 +8,15 @@ module Vedeu
|
|
8
8
|
let(:instance) { described.new(attributes) }
|
9
9
|
let(:attributes) {
|
10
10
|
{
|
11
|
-
centred:
|
12
|
-
height:
|
13
|
-
name:
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
11
|
+
centred: centred,
|
12
|
+
height: height,
|
13
|
+
name: _name,
|
14
|
+
repository: Vedeu.geometries,
|
15
|
+
width: width,
|
16
|
+
x: x,
|
17
|
+
xn: xn,
|
18
|
+
y: y,
|
19
|
+
yn: yn,
|
19
20
|
}
|
20
21
|
}
|
21
22
|
let(:centred) {}
|
@@ -30,18 +31,20 @@ module Vedeu
|
|
30
31
|
before { Terminal.stubs(:size).returns([12, 40]) }
|
31
32
|
|
32
33
|
describe '#initialize' do
|
33
|
-
|
34
|
-
|
35
|
-
it {
|
36
|
-
it {
|
37
|
-
it {
|
38
|
-
it {
|
39
|
-
it {
|
40
|
-
it {
|
41
|
-
it {
|
42
|
-
it {
|
34
|
+
subject { instance }
|
35
|
+
|
36
|
+
it { subject.must_be_instance_of(Geometry) }
|
37
|
+
it { subject.instance_variable_get('@attributes').must_equal(attributes) }
|
38
|
+
it { subject.instance_variable_get('@centred').must_equal(centred) }
|
39
|
+
it { subject.instance_variable_get('@height').must_equal(height) }
|
40
|
+
it { subject.instance_variable_get('@name').must_equal(_name) }
|
41
|
+
it { subject.instance_variable_get('@width').must_equal(width) }
|
42
|
+
it { subject.instance_variable_get('@x').must_equal(x) }
|
43
|
+
it { subject.instance_variable_get('@xn').must_equal(xn) }
|
44
|
+
it { subject.instance_variable_get('@y').must_equal(y) }
|
45
|
+
it { subject.instance_variable_get('@yn').must_equal(yn) }
|
43
46
|
it do
|
44
|
-
|
47
|
+
subject.instance_variable_get('@repository').must_equal(Vedeu.geometries)
|
45
48
|
end
|
46
49
|
end
|
47
50
|
|