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
@@ -40,6 +40,12 @@ module Vedeu
|
|
40
40
|
alias_method :member, :child
|
41
41
|
alias_method :collection, :child
|
42
42
|
|
43
|
+
# @note
|
44
|
+
# Not current used.
|
45
|
+
#
|
46
|
+
# @param klass [void]
|
47
|
+
# @param as [void]
|
48
|
+
# @return [void]
|
43
49
|
def repository(klass, as:)
|
44
50
|
self.repository = as
|
45
51
|
klass.register(as, self)
|
@@ -19,6 +19,18 @@ module Vedeu
|
|
19
19
|
|
20
20
|
end
|
21
21
|
|
22
|
+
# @param name [String] The name of the stored group.
|
23
|
+
# @return [Vedeu::Group]
|
24
|
+
def by_name(name)
|
25
|
+
if registered?(name)
|
26
|
+
find(name)
|
27
|
+
|
28
|
+
else
|
29
|
+
Vedeu::Group.new(name: name).store
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
22
34
|
end # Groups
|
23
35
|
|
24
36
|
end # Vedeu
|
@@ -24,6 +24,9 @@ module Vedeu
|
|
24
24
|
# @return [void]
|
25
25
|
attr_reader :storage
|
26
26
|
|
27
|
+
# @param model [Class]
|
28
|
+
# @param storage [Class|Hash]
|
29
|
+
# @return [Vedeu::Repository]
|
27
30
|
def self.register_repository(model = nil, storage = {})
|
28
31
|
new(model, storage).tap do |klass|
|
29
32
|
Vedeu::Repositories.register(klass.repository)
|
@@ -40,6 +43,9 @@ module Vedeu
|
|
40
43
|
@storage = storage
|
41
44
|
end
|
42
45
|
|
46
|
+
# Returns the repository class.
|
47
|
+
#
|
48
|
+
# @return [Class]
|
43
49
|
def repository
|
44
50
|
self.class # .name
|
45
51
|
end
|
@@ -86,6 +92,11 @@ module Vedeu
|
|
86
92
|
end
|
87
93
|
alias_method :by_name, :find_or_create
|
88
94
|
|
95
|
+
# @return [String]
|
96
|
+
def inspect
|
97
|
+
"<#{self.class.name}: #{registered.inspect}>"
|
98
|
+
end
|
99
|
+
|
89
100
|
# Returns a collection of the names of all the registered entities.
|
90
101
|
#
|
91
102
|
# @return [Array]
|
@@ -145,14 +156,6 @@ module Vedeu
|
|
145
156
|
end
|
146
157
|
alias_method :register, :store
|
147
158
|
|
148
|
-
# Access a model by name.
|
149
|
-
#
|
150
|
-
# @param name [String]
|
151
|
-
# @return [|NilClass]
|
152
|
-
def use(name)
|
153
|
-
find(name) if registered?(name)
|
154
|
-
end
|
155
|
-
|
156
159
|
private
|
157
160
|
|
158
161
|
# @return [Hash]
|
data/lib/vedeu/storage/all.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
require_relative 'store'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
require_relative 'associative_store'
|
4
|
+
require_relative 'conveyor_store'
|
5
|
+
require_relative 'fifo_store'
|
6
6
|
|
@@ -4,6 +4,14 @@ module Vedeu
|
|
4
4
|
#
|
5
5
|
class Visibility
|
6
6
|
|
7
|
+
# @param name [String]
|
8
|
+
# @return [Vedeu::Visibility]
|
9
|
+
def self.for_cursor(name = nil)
|
10
|
+
named = name ? Vedeu.cursors.by_name(name) : Vedeu.cursor
|
11
|
+
|
12
|
+
new(named)
|
13
|
+
end
|
14
|
+
|
7
15
|
# @param model [void]
|
8
16
|
# @return [void]
|
9
17
|
def self.show(model)
|
@@ -12,14 +12,12 @@ module Vedeu
|
|
12
12
|
back: back,
|
13
13
|
front: front,
|
14
14
|
previous: previous,
|
15
|
-
repository: repository,
|
16
15
|
}
|
17
16
|
}
|
18
17
|
let(:_name) { 'krypton' }
|
19
18
|
let(:back) {}
|
20
19
|
let(:front) {}
|
21
20
|
let(:previous) {}
|
22
|
-
let(:repository) {}
|
23
21
|
|
24
22
|
before { Vedeu.stubs(:trigger) }
|
25
23
|
|
@@ -39,6 +39,13 @@ module Vedeu
|
|
39
39
|
it { subject.instance_variable_get('@y').must_equal(8) }
|
40
40
|
end
|
41
41
|
|
42
|
+
describe '#hide_cursor' do
|
43
|
+
subject { instance.hide_cursor }
|
44
|
+
|
45
|
+
it { subject.must_be_instance_of(String) }
|
46
|
+
it { subject.must_equal("\e[?25l") }
|
47
|
+
end
|
48
|
+
|
42
49
|
describe '#inspect' do
|
43
50
|
subject { instance.inspect }
|
44
51
|
|
@@ -48,6 +55,13 @@ module Vedeu
|
|
48
55
|
) }
|
49
56
|
end
|
50
57
|
|
58
|
+
describe '#show_cursor' do
|
59
|
+
subject { instance.show_cursor }
|
60
|
+
|
61
|
+
it { subject.must_be_instance_of(String) }
|
62
|
+
it { subject.must_equal("\e[?25h") }
|
63
|
+
end
|
64
|
+
|
51
65
|
describe '#to_s' do
|
52
66
|
let(:visible) { true }
|
53
67
|
|
@@ -173,9 +173,9 @@ module Vedeu
|
|
173
173
|
end
|
174
174
|
|
175
175
|
describe '#title' do
|
176
|
-
let(:
|
176
|
+
let(:_value) { 'Some title'}
|
177
177
|
|
178
|
-
subject { instance.title(
|
178
|
+
subject { instance.title(_value) }
|
179
179
|
|
180
180
|
it { subject.must_be_instance_of(String) }
|
181
181
|
it { subject.must_equal('Some title') }
|
@@ -10,6 +10,8 @@ module Vedeu
|
|
10
10
|
let(:instance) { described.new(model) }
|
11
11
|
let(:model) { Vedeu::Geometry.new }
|
12
12
|
|
13
|
+
before { Terminal.stubs(:size).returns([25, 80]) }
|
14
|
+
|
13
15
|
describe 'alias methods' do
|
14
16
|
it { instance.must_respond_to(:centred!) }
|
15
17
|
end
|
@@ -20,113 +22,86 @@ module Vedeu
|
|
20
22
|
end
|
21
23
|
|
22
24
|
describe '#centred' do
|
23
|
-
subject {
|
25
|
+
subject { instance.centred(true) }
|
24
26
|
|
25
27
|
it 'sets the attribute to the value' do
|
26
|
-
subject.
|
28
|
+
subject.must_equal(true)
|
27
29
|
end
|
28
30
|
|
29
31
|
context 'DSL #centred' do
|
30
32
|
subject {
|
31
|
-
Vedeu.
|
32
|
-
|
33
|
-
centred false
|
34
|
-
end
|
33
|
+
Vedeu.geometry 'geometry' do
|
34
|
+
centred false
|
35
35
|
end
|
36
36
|
}
|
37
37
|
|
38
|
-
it { subject.must_be_instance_of(Vedeu::
|
38
|
+
it { subject.must_be_instance_of(Vedeu::Geometry) }
|
39
39
|
|
40
40
|
it 'allows the use of centred within geometry' do
|
41
|
-
subject.
|
41
|
+
subject.centred.must_equal(false)
|
42
42
|
end
|
43
43
|
|
44
44
|
context 'when no value is given' do
|
45
45
|
subject {
|
46
|
-
Vedeu.
|
47
|
-
|
48
|
-
centred
|
49
|
-
end
|
46
|
+
Vedeu.geometry 'geometry' do
|
47
|
+
centred
|
50
48
|
end
|
51
49
|
}
|
52
50
|
|
53
|
-
it { subject.
|
51
|
+
it { subject.centred.must_equal(true) }
|
54
52
|
end
|
55
53
|
end
|
56
54
|
end
|
57
55
|
|
58
56
|
describe '#height' do
|
59
|
-
subject {
|
57
|
+
subject { instance.height(6) }
|
60
58
|
|
61
59
|
it 'sets the attribute to the value' do
|
62
|
-
subject.
|
60
|
+
subject.must_equal(6)
|
63
61
|
end
|
64
62
|
|
65
63
|
context 'DSL #height' do
|
66
64
|
subject {
|
67
|
-
Vedeu.
|
68
|
-
|
69
|
-
height 17
|
70
|
-
end
|
65
|
+
Vedeu.geometry 'geometry' do
|
66
|
+
height 17
|
71
67
|
end
|
72
68
|
}
|
73
69
|
|
74
|
-
it { subject.must_be_instance_of(Vedeu::
|
70
|
+
it { subject.must_be_instance_of(Vedeu::Geometry) }
|
75
71
|
|
76
72
|
it 'allows the use of height within geometry' do
|
77
|
-
subject.
|
73
|
+
subject.height.must_equal(17)
|
78
74
|
end
|
79
75
|
end
|
80
76
|
end
|
81
77
|
|
82
|
-
# describe '#use' do
|
83
|
-
# subject {
|
84
|
-
# Vedeu::Geometry.build({ name: 'hydrogen' }) { use 'helium' }
|
85
|
-
# }
|
86
|
-
|
87
|
-
# context 'when the named geometry does not exist' do
|
88
|
-
# end
|
89
|
-
|
90
|
-
# context 'when the named geometry exists' do
|
91
|
-
# before do
|
92
|
-
# Vedeu::Geometry.build({ name: 'helium', x: 5 }).store
|
93
|
-
# end
|
94
|
-
|
95
|
-
# it { subject.must_be_instance_of(Vedeu::Geometry) }
|
96
|
-
# it { subject.name.must_equal('hydrogen') }
|
97
|
-
# it { subject.x.must_equal(5) }
|
98
|
-
# end
|
99
|
-
# end
|
100
|
-
|
101
78
|
describe '#width' do
|
102
|
-
subject {
|
79
|
+
subject { instance.width(25) }
|
103
80
|
|
104
81
|
it 'sets the attribute to the value' do
|
105
|
-
subject.
|
82
|
+
subject.must_equal(25)
|
106
83
|
end
|
107
84
|
|
108
85
|
context 'DSL #width' do
|
109
86
|
subject {
|
110
|
-
Vedeu.
|
111
|
-
|
112
|
-
width 29
|
113
|
-
end
|
87
|
+
Vedeu.geometry 'geometry' do
|
88
|
+
width 29
|
114
89
|
end
|
115
90
|
}
|
116
91
|
|
117
|
-
it { subject.must_be_instance_of(Vedeu::
|
92
|
+
it { subject.must_be_instance_of(Vedeu::Geometry) }
|
118
93
|
|
119
94
|
it 'allows the use of width within geometry' do
|
120
|
-
subject.
|
95
|
+
subject.width.must_equal(29)
|
121
96
|
end
|
122
97
|
end
|
123
98
|
end
|
124
99
|
|
125
100
|
describe '#x' do
|
126
|
-
subject {
|
101
|
+
subject { instance.x(2) }
|
127
102
|
|
128
103
|
it 'sets the attribute to the value' do
|
129
|
-
subject.
|
104
|
+
subject.must_equal(2)
|
130
105
|
end
|
131
106
|
|
132
107
|
context 'when a block is given' do
|
@@ -143,41 +118,46 @@ module Vedeu
|
|
143
118
|
|
144
119
|
context 'DSL #x' do
|
145
120
|
subject {
|
146
|
-
Vedeu.
|
147
|
-
|
148
|
-
x 7
|
149
|
-
end
|
121
|
+
Vedeu.geometry 'geometry' do
|
122
|
+
x 7
|
150
123
|
end
|
151
124
|
}
|
152
125
|
|
153
|
-
it { subject.must_be_instance_of(Vedeu::
|
126
|
+
it { subject.must_be_instance_of(Vedeu::Geometry) }
|
154
127
|
|
155
128
|
it 'allows the use of x within geometry' do
|
156
|
-
subject.
|
129
|
+
subject.x.must_equal(7)
|
157
130
|
end
|
158
131
|
|
159
132
|
context 'when no value is given' do
|
160
133
|
subject {
|
161
|
-
Vedeu.
|
162
|
-
|
163
|
-
x
|
164
|
-
end
|
134
|
+
Vedeu.geometry 'geometry' do
|
135
|
+
x
|
165
136
|
end
|
166
137
|
}
|
167
138
|
|
168
|
-
it { subject.
|
139
|
+
it { subject.x.must_equal(1) }
|
169
140
|
end
|
170
141
|
|
171
142
|
context 'when a block is given' do
|
143
|
+
subject {
|
144
|
+
Vedeu::Geometry.build({}) do
|
145
|
+
x do
|
146
|
+
8 + 8
|
147
|
+
end
|
148
|
+
end
|
149
|
+
}
|
150
|
+
|
151
|
+
it { subject.x.must_equal(16) }
|
172
152
|
end
|
173
153
|
end
|
174
154
|
end
|
175
155
|
|
176
156
|
describe '#y' do
|
177
|
-
subject {
|
157
|
+
subject { instance.y(5) }
|
178
158
|
|
179
159
|
it 'sets the attribute to the value' do
|
180
|
-
subject.
|
160
|
+
subject.must_equal(5)
|
181
161
|
end
|
182
162
|
|
183
163
|
context 'when a block is given' do
|
@@ -194,42 +174,45 @@ module Vedeu
|
|
194
174
|
|
195
175
|
context 'DSL #y' do
|
196
176
|
subject {
|
197
|
-
Vedeu.
|
198
|
-
|
199
|
-
y 4
|
200
|
-
end
|
177
|
+
Vedeu.geometry 'geometry' do
|
178
|
+
y 4
|
201
179
|
end
|
202
180
|
}
|
203
181
|
|
204
|
-
it { subject.must_be_instance_of(Vedeu::
|
182
|
+
it { subject.must_be_instance_of(Vedeu::Geometry) }
|
205
183
|
|
206
184
|
it 'allows the use of y within geometry' do
|
207
|
-
subject.
|
185
|
+
subject.y.must_equal(4)
|
208
186
|
end
|
209
187
|
|
210
188
|
context 'when no value is given' do
|
211
189
|
subject {
|
212
|
-
Vedeu.
|
213
|
-
|
214
|
-
y
|
215
|
-
end
|
190
|
+
Vedeu.geometry 'geometry' do
|
191
|
+
y
|
216
192
|
end
|
217
193
|
}
|
218
194
|
|
219
|
-
it { subject.
|
195
|
+
it { subject.y.must_equal(1) }
|
220
196
|
end
|
221
197
|
|
222
198
|
context 'when a block is given' do
|
199
|
+
subject {
|
200
|
+
Vedeu::Geometry.build({}) do
|
201
|
+
y do
|
202
|
+
8 + 8
|
203
|
+
end
|
204
|
+
end
|
205
|
+
}
|
206
|
+
|
207
|
+
it { subject.y.must_equal(16) }
|
223
208
|
end
|
224
209
|
end
|
225
210
|
end
|
226
211
|
|
227
212
|
describe '#xn' do
|
228
|
-
|
229
|
-
|
230
|
-
subject { Vedeu::Geometry.build({}) { xn 15 } }
|
213
|
+
subject { instance.xn(15) }
|
231
214
|
|
232
|
-
it { subject.
|
215
|
+
it { subject.must_equal(15) }
|
233
216
|
|
234
217
|
context 'when a block is given' do
|
235
218
|
subject {
|
@@ -245,11 +228,9 @@ module Vedeu
|
|
245
228
|
end
|
246
229
|
|
247
230
|
describe '#yn' do
|
248
|
-
|
249
|
-
|
250
|
-
subject { Vedeu::Geometry.build({}) { yn 8 } }
|
231
|
+
subject { instance.yn(8) }
|
251
232
|
|
252
|
-
it { subject.
|
233
|
+
it { subject.must_equal(8) }
|
253
234
|
|
254
235
|
context 'when a block is given' do
|
255
236
|
subject {
|