vedeu 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/docs/events.md +4 -0
- data/examples/borders_app.rb +43 -39
- data/examples/focus_app.rb +4 -0
- data/examples/hello_world.rb +10 -3
- data/lib/vedeu/all.rb +1 -2
- data/lib/vedeu/api.rb +4 -1
- data/lib/vedeu/application/application_controller.rb +24 -0
- data/lib/vedeu/application/application_view.rb +9 -9
- data/lib/vedeu/bindings.rb +2 -0
- data/lib/vedeu/bindings/movement.rb +9 -9
- data/lib/vedeu/bindings/system.rb +3 -3
- data/lib/vedeu/buffers/buffer.rb +4 -9
- data/lib/vedeu/buffers/display_buffer.rb +2 -48
- data/lib/vedeu/cli/generator/application.rb +6 -0
- data/lib/vedeu/cli/generator/templates/application/.ruby-version +1 -0
- data/lib/vedeu/cli/generator/templates/application/app/controllers/name.erb +2 -11
- data/lib/vedeu/configuration/api.rb +6 -0
- data/lib/vedeu/configuration/configuration.rb +6 -0
- data/lib/vedeu/cursor/cursor.rb +49 -15
- data/lib/vedeu/cursor/move.rb +2 -2
- data/lib/vedeu/cursor/refresh_cursor.rb +2 -7
- data/lib/vedeu/distributed/server.rb +7 -21
- data/lib/vedeu/dsl/view.rb +31 -6
- data/lib/vedeu/internal_api.rb +7 -0
- data/lib/vedeu/log/log.rb +5 -2
- data/lib/vedeu/models/escape.rb +24 -6
- data/lib/vedeu/models/interface.rb +2 -14
- data/lib/vedeu/null/buffer.rb +7 -21
- data/lib/vedeu/null/generic.rb +5 -16
- data/lib/vedeu/null/interface.rb +6 -18
- data/lib/vedeu/runtime/bootstrap.rb +1 -1
- data/lib/vedeu/runtime/flags.rb +57 -0
- data/lib/vedeu/runtime/router.rb +2 -2
- data/lib/vedeu/version.rb +2 -1
- data/test/lib/vedeu/api_test.rb +1 -0
- data/test/lib/vedeu/application/application_controller_test.rb +26 -2
- data/test/lib/vedeu/application/application_view_test.rb +9 -4
- data/test/lib/vedeu/bindings_test.rb +9 -0
- data/test/lib/vedeu/borders/border_test.rb +25 -42
- data/test/lib/vedeu/buffers/display_buffer_test.rb +0 -10
- data/test/lib/vedeu/configuration/api_test.rb +7 -1
- data/test/lib/vedeu/configuration/cli_test.rb +0 -1
- data/test/lib/vedeu/configuration/configuration_test.rb +16 -0
- data/test/lib/vedeu/cursor/cursor_test.rb +122 -4
- data/test/lib/vedeu/dsl/view_test.rb +2 -2
- data/test/lib/vedeu/internal_api_test.rb +2 -0
- data/test/lib/vedeu/models/escape_test.rb +16 -6
- data/test/lib/vedeu/models/focus_test.rb +2 -1
- data/test/lib/vedeu/models/interface_test.rb +9 -5
- data/test/lib/vedeu/null/buffer_test.rb +7 -25
- data/test/lib/vedeu/null/generic_test.rb +6 -20
- data/test/lib/vedeu/null/interface_test.rb +8 -14
- data/test/lib/vedeu/output/compressor_test.rb +4 -4
- data/test/lib/vedeu/output/renderers_test.rb +1 -1
- data/test/lib/vedeu/runtime/flags_test.rb +47 -0
- data/test/lib/vedeu/runtime/router_test.rb +4 -4
- data/test/test_helper.rb +2 -0
- metadata +6 -10
- data/examples/geometry_app.rb +0 -147
- data/examples/panel_app.rb +0 -71
- data/lib/vedeu/geometry/index_position.rb +0 -85
- data/lib/vedeu/geometry/position_validator.rb +0 -69
- data/test/lib/vedeu/geometry/index_position_test.rb +0 -130
- data/test/lib/vedeu/geometry/position_validator_test.rb +0 -149
data/lib/vedeu/runtime/router.rb
CHANGED
@@ -131,8 +131,8 @@ module Vedeu
|
|
131
131
|
# @param args [Symbol]
|
132
132
|
# @return [void]
|
133
133
|
def route(controller, action, **args)
|
134
|
-
klass = Object.const_get(klass_for(controller)).new
|
135
|
-
klass.send(action
|
134
|
+
klass = Object.const_get(klass_for(controller)).new(**args)
|
135
|
+
klass.send(action)
|
136
136
|
end
|
137
137
|
|
138
138
|
# Fetch the class for the controller by name.
|
data/lib/vedeu/version.rb
CHANGED
data/test/lib/vedeu/api_test.rb
CHANGED
@@ -19,6 +19,7 @@ module Vedeu
|
|
19
19
|
it { Vedeu.must_respond_to(:renders) }
|
20
20
|
it { Vedeu.must_respond_to(:render) }
|
21
21
|
it { Vedeu.must_respond_to(:views) }
|
22
|
+
it { Vedeu.must_respond_to(:view) }
|
22
23
|
it { Vedeu.must_respond_to(:bind) }
|
23
24
|
it { Vedeu.must_respond_to(:bind_alias) }
|
24
25
|
it { Vedeu.must_respond_to(:bound?) }
|
@@ -5,9 +5,33 @@ module Vedeu
|
|
5
5
|
describe ApplicationController do
|
6
6
|
|
7
7
|
let(:described) { Vedeu::ApplicationController }
|
8
|
-
let(:instance) { described.new }
|
8
|
+
let(:instance) { described.new(params) }
|
9
|
+
let(:params) { {} }
|
9
10
|
|
10
|
-
#
|
11
|
+
describe '#initialize' do
|
12
|
+
subject { instance }
|
13
|
+
|
14
|
+
it { subject.must_be_instance_of(described) }
|
15
|
+
it { subject.instance_variable_get('@params').must_equal(params) }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#redirect_to' do
|
19
|
+
let(:controller) {}
|
20
|
+
let(:action) {}
|
21
|
+
let(:params) { {} }
|
22
|
+
|
23
|
+
before { Vedeu.stubs(:trigger) }
|
24
|
+
|
25
|
+
subject { instance.redirect_to(controller, action, params) }
|
26
|
+
|
27
|
+
it {
|
28
|
+
Vedeu.expects(:trigger).with(:_goto_, controller, action, params)
|
29
|
+
subject
|
30
|
+
}
|
31
|
+
|
32
|
+
it { instance.must_respond_to(:redirect) }
|
33
|
+
it { instance.must_respond_to(:goto) }
|
34
|
+
end
|
11
35
|
|
12
36
|
end # ApplicationController
|
13
37
|
|
@@ -5,16 +5,21 @@ module Vedeu
|
|
5
5
|
describe ApplicationView do
|
6
6
|
|
7
7
|
let(:described) { Vedeu::ApplicationView }
|
8
|
-
let(:instance) { described.new(
|
9
|
-
let(:
|
8
|
+
let(:instance) { described.new(params) }
|
9
|
+
let(:params) { {} }
|
10
10
|
|
11
11
|
describe '#initialize' do
|
12
12
|
it { instance.must_be_instance_of(described) }
|
13
|
-
it { instance.instance_variable_get('@
|
13
|
+
it { instance.instance_variable_get('@params').must_equal(params) }
|
14
14
|
end
|
15
15
|
|
16
|
+
# describe 'accessors' do
|
17
|
+
# it { instance.must_respond_to(:params) }
|
18
|
+
# it { instance.must_respond_to(:params=) }
|
19
|
+
# end
|
20
|
+
|
16
21
|
describe '.render' do
|
17
|
-
subject { described.render(
|
22
|
+
subject { described.render(params) }
|
18
23
|
|
19
24
|
it { proc { subject }.must_raise(Vedeu::NotImplemented) }
|
20
25
|
end
|
@@ -7,6 +7,15 @@ module Vedeu
|
|
7
7
|
let(:described) { Vedeu::Bindings }
|
8
8
|
|
9
9
|
describe '.setup!' do
|
10
|
+
before {
|
11
|
+
Vedeu::Bindings::Application.stubs(:setup!)
|
12
|
+
Vedeu::Bindings::Visibility.stubs(:setup!)
|
13
|
+
Vedeu::Bindings::Movement.stubs(:setup!)
|
14
|
+
Vedeu::Bindings::Menus.stubs(:setup!)
|
15
|
+
Vedeu::Bindings::DRB.stubs(:setup!)
|
16
|
+
Vedeu::Bindings::System.stubs(:setup!)
|
17
|
+
}
|
18
|
+
|
10
19
|
subject { described.setup! }
|
11
20
|
|
12
21
|
it {
|
@@ -8,9 +8,30 @@ module Vedeu
|
|
8
8
|
let(:instance) { described.new(attributes) }
|
9
9
|
let(:attributes) {
|
10
10
|
{
|
11
|
-
|
11
|
+
bottom_left: 'm',
|
12
|
+
bottom_right: 'j',
|
13
|
+
client: nil,
|
14
|
+
colour: nil,
|
15
|
+
enabled: false,
|
16
|
+
horizontal: 'q',
|
17
|
+
name: 'borders',
|
18
|
+
repository: Vedeu.borders,
|
19
|
+
show_bottom: true,
|
20
|
+
show_left: true,
|
21
|
+
show_right: true,
|
22
|
+
show_top: true,
|
23
|
+
style: nil,
|
24
|
+
title: '',
|
25
|
+
top_left: 'l',
|
26
|
+
top_right: 'k',
|
27
|
+
vertical: 'x',
|
12
28
|
}
|
13
29
|
}
|
30
|
+
let(:geometry) {}
|
31
|
+
|
32
|
+
before {
|
33
|
+
Vedeu.geometries.stubs(:by_name).returns(geometry)
|
34
|
+
}
|
14
35
|
|
15
36
|
describe '.build' do
|
16
37
|
subject {
|
@@ -23,36 +44,10 @@ module Vedeu
|
|
23
44
|
end
|
24
45
|
|
25
46
|
describe '#initialize' do
|
26
|
-
let(:default_attributes) {
|
27
|
-
{
|
28
|
-
bottom_left: 'm',
|
29
|
-
bottom_right: 'j',
|
30
|
-
client: nil,
|
31
|
-
colour: nil,
|
32
|
-
enabled: false,
|
33
|
-
horizontal: 'q',
|
34
|
-
name: 'borders',
|
35
|
-
repository: Vedeu.borders,
|
36
|
-
show_bottom: true,
|
37
|
-
show_left: true,
|
38
|
-
show_right: true,
|
39
|
-
show_top: true,
|
40
|
-
style: nil,
|
41
|
-
title: '',
|
42
|
-
top_left: 'l',
|
43
|
-
top_right: 'k',
|
44
|
-
vertical: 'x',
|
45
|
-
}
|
46
|
-
}
|
47
47
|
it { instance.must_be_instance_of(described) }
|
48
48
|
it do
|
49
49
|
instance.instance_variable_get('@attributes').
|
50
|
-
must_equal(
|
51
|
-
end
|
52
|
-
it { instance.instance_variable_get('@name').must_equal('borders') }
|
53
|
-
it do
|
54
|
-
instance.instance_variable_get('@repository').
|
55
|
-
must_be_instance_of(Vedeu::Borders)
|
50
|
+
must_equal(attributes)
|
56
51
|
end
|
57
52
|
end
|
58
53
|
|
@@ -117,10 +112,6 @@ module Vedeu
|
|
117
112
|
Vedeu::Geometry.new(name: 'Border#bxbxnbybyn', x: 2, xn: 6, y: 2, yn: 6)
|
118
113
|
}
|
119
114
|
|
120
|
-
before {
|
121
|
-
Vedeu.geometries.stubs(:by_name).returns(geometry)
|
122
|
-
}
|
123
|
-
|
124
115
|
describe '#bx' do
|
125
116
|
subject { instance.bx }
|
126
117
|
|
@@ -214,9 +205,6 @@ module Vedeu
|
|
214
205
|
let(:geometry) {
|
215
206
|
Vedeu::Geometry.new(name: 'borders', width: 8)
|
216
207
|
}
|
217
|
-
before {
|
218
|
-
Vedeu.geometries.stubs(:by_name).returns(geometry)
|
219
|
-
}
|
220
208
|
|
221
209
|
subject { instance.width }
|
222
210
|
|
@@ -269,9 +257,6 @@ module Vedeu
|
|
269
257
|
let(:geometry) {
|
270
258
|
Vedeu::Geometry.new(name: 'borders', height: 5)
|
271
259
|
}
|
272
|
-
before {
|
273
|
-
Vedeu.geometries.stubs(:by_name).returns(geometry)
|
274
|
-
}
|
275
260
|
|
276
261
|
subject { instance.height }
|
277
262
|
|
@@ -435,12 +420,10 @@ module Vedeu
|
|
435
420
|
let(:geometry) {
|
436
421
|
Vedeu::Geometry.new(name: 'Border#render', x: 1, xn: 4, y: 1, yn: 4)
|
437
422
|
}
|
438
|
-
let(:interface) {
|
439
|
-
|
440
|
-
}
|
423
|
+
let(:interface) { Vedeu::Interface.new(visible: visibility) }
|
424
|
+
|
441
425
|
before {
|
442
426
|
Vedeu.interfaces.stubs(:by_name).returns(interface)
|
443
|
-
Vedeu.geometries.stubs(:by_name).returns(geometry)
|
444
427
|
}
|
445
428
|
|
446
429
|
subject { instance.render }
|
@@ -54,16 +54,6 @@ module Vedeu
|
|
54
54
|
|
55
55
|
it { proc { subject }.must_raise(InvalidSyntax) }
|
56
56
|
end
|
57
|
-
|
58
|
-
context 'when the buffer is not already registered' do
|
59
|
-
# @todo Add more tests.
|
60
|
-
# it { skip }
|
61
|
-
end
|
62
|
-
|
63
|
-
context 'when the buffer is already registered' do
|
64
|
-
# @todo Add more tests.
|
65
|
-
# it { skip }
|
66
|
-
end
|
67
57
|
end
|
68
58
|
|
69
59
|
end # DisplayBuffer
|
@@ -16,7 +16,6 @@ module Vedeu
|
|
16
16
|
let(:described) { Vedeu::Config::API }
|
17
17
|
let(:instance) { described.new }
|
18
18
|
|
19
|
-
before { Configuration.reset! }
|
20
19
|
after { test_configuration }
|
21
20
|
|
22
21
|
describe '#base_path' do
|
@@ -228,6 +227,13 @@ module Vedeu
|
|
228
227
|
end
|
229
228
|
end
|
230
229
|
|
230
|
+
describe '#log_only' do
|
231
|
+
it 'sets the options to the desired value' do
|
232
|
+
configuration = Vedeu.configure { log_only :debug, :store }
|
233
|
+
configuration.log_only.must_equal([:debug, :store])
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
231
237
|
describe '#renderer' do
|
232
238
|
it { instance.must_respond_to(:renderers) }
|
233
239
|
end
|
@@ -81,6 +81,22 @@ module Vedeu
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
+
describe '.log_only' do
|
85
|
+
context 'when log_only is not configured' do
|
86
|
+
it { described.log_only.must_equal([]) }
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'when log_only is configured' do
|
90
|
+
before {
|
91
|
+
Vedeu.configure do
|
92
|
+
log_only :timer, :event
|
93
|
+
end
|
94
|
+
}
|
95
|
+
|
96
|
+
it { described.log_only.must_equal([:timer, :event]) }
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
84
100
|
describe '.once?' do
|
85
101
|
it { described.must_respond_to(:once) }
|
86
102
|
|
@@ -24,6 +24,22 @@ module Vedeu
|
|
24
24
|
let(:visible) { true }
|
25
25
|
let(:x) { 19 }
|
26
26
|
let(:y) { 8 }
|
27
|
+
let(:border) { Vedeu::Border.new(name: _name, enabled: enabled) }
|
28
|
+
let(:geometry) {
|
29
|
+
Vedeu::Geometry.new(
|
30
|
+
name: _name,
|
31
|
+
x: 5,
|
32
|
+
xn: 35,
|
33
|
+
y: 5,
|
34
|
+
yn: 10
|
35
|
+
)
|
36
|
+
}
|
37
|
+
let(:enabled) { true }
|
38
|
+
|
39
|
+
before {
|
40
|
+
Vedeu.borders.stubs(:by_name).returns(border)
|
41
|
+
Vedeu.geometries.stubs(:by_name).returns(geometry)
|
42
|
+
}
|
27
43
|
|
28
44
|
describe '#initialize' do
|
29
45
|
subject { instance }
|
@@ -46,15 +62,13 @@ module Vedeu
|
|
46
62
|
it { instance.must_respond_to(:oy) }
|
47
63
|
it { instance.must_respond_to(:oy=) }
|
48
64
|
it { instance.must_respond_to(:state) }
|
49
|
-
it { instance.must_respond_to(:x) }
|
50
65
|
it { instance.must_respond_to(:x=) }
|
51
|
-
it { instance.must_respond_to(:y) }
|
52
66
|
it { instance.must_respond_to(:y=) }
|
53
67
|
end
|
54
68
|
|
55
69
|
describe '#hide' do
|
56
70
|
let(:visible) { true }
|
57
|
-
let(:hide_cursor) { Vedeu::Escape.new(Vedeu::Esc.hide_cursor) }
|
71
|
+
let(:hide_cursor) { Vedeu::Escape.new(value: Vedeu::Esc.hide_cursor) }
|
58
72
|
|
59
73
|
before {
|
60
74
|
Vedeu::Output.stubs(:render).
|
@@ -83,7 +97,7 @@ module Vedeu
|
|
83
97
|
|
84
98
|
describe '#show' do
|
85
99
|
let(:visible) { false }
|
86
|
-
let(:show_cursor) { Vedeu::Escape.new(Vedeu::Esc.show_cursor) }
|
100
|
+
let(:show_cursor) { Vedeu::Escape.new(value: Vedeu::Esc.show_cursor) }
|
87
101
|
|
88
102
|
before {
|
89
103
|
Vedeu::Output.stubs(:render).
|
@@ -132,6 +146,110 @@ module Vedeu
|
|
132
146
|
end
|
133
147
|
end
|
134
148
|
|
149
|
+
describe '#x' do
|
150
|
+
subject { instance.x }
|
151
|
+
|
152
|
+
context 'when x is less than tx' do
|
153
|
+
let(:x) { -2 }
|
154
|
+
|
155
|
+
it { subject.must_equal(6) }
|
156
|
+
end
|
157
|
+
|
158
|
+
context 'when x is less than left' do
|
159
|
+
let(:x) { 2 }
|
160
|
+
|
161
|
+
it { subject.must_equal(6) }
|
162
|
+
end
|
163
|
+
|
164
|
+
context 'when x is less than bx' do
|
165
|
+
let(:x) { 5 }
|
166
|
+
|
167
|
+
it { subject.must_equal(6) }
|
168
|
+
|
169
|
+
context 'when border is not enabled' do
|
170
|
+
let(:enabled) { false }
|
171
|
+
|
172
|
+
it { subject.must_equal(5) }
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
context 'when x is more than txn' do
|
177
|
+
let(:x) { 47 }
|
178
|
+
|
179
|
+
it { subject.must_equal(34) }
|
180
|
+
end
|
181
|
+
|
182
|
+
context 'when x is more than right' do
|
183
|
+
let(:x) { 37 }
|
184
|
+
|
185
|
+
it { subject.must_equal(34) }
|
186
|
+
end
|
187
|
+
|
188
|
+
context 'when x is more than bxn' do
|
189
|
+
let(:x) { 35 }
|
190
|
+
|
191
|
+
it { subject.must_equal(34) }
|
192
|
+
|
193
|
+
context 'when border is not enabled' do
|
194
|
+
let(:enabled) { false }
|
195
|
+
|
196
|
+
it { subject.must_equal(35) }
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
describe '#y' do
|
202
|
+
subject { instance.y }
|
203
|
+
|
204
|
+
context 'when y is less than ty' do
|
205
|
+
let(:y) { -2 }
|
206
|
+
|
207
|
+
it { subject.must_equal(6) }
|
208
|
+
end
|
209
|
+
|
210
|
+
context 'when y is less than top' do
|
211
|
+
let(:y) { 2 }
|
212
|
+
|
213
|
+
it { subject.must_equal(6) }
|
214
|
+
end
|
215
|
+
|
216
|
+
context 'when y is less than by' do
|
217
|
+
let(:y) { 5 }
|
218
|
+
|
219
|
+
it { subject.must_equal(6) }
|
220
|
+
|
221
|
+
context 'when border is not enabled' do
|
222
|
+
let(:enabled) { false }
|
223
|
+
|
224
|
+
it { subject.must_equal(5) }
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
context 'when y is more than tyn' do
|
229
|
+
let(:y) { 17 }
|
230
|
+
|
231
|
+
it { subject.must_equal(9) }
|
232
|
+
end
|
233
|
+
|
234
|
+
context 'when y is more than bottom' do
|
235
|
+
let(:y) { 12 }
|
236
|
+
|
237
|
+
it { subject.must_equal(9) }
|
238
|
+
end
|
239
|
+
|
240
|
+
context 'when y is more than byn' do
|
241
|
+
let(:y) { 10 }
|
242
|
+
|
243
|
+
it { subject.must_equal(9) }
|
244
|
+
|
245
|
+
context 'when border is not enabled' do
|
246
|
+
let(:enabled) { false }
|
247
|
+
|
248
|
+
it { subject.must_equal(10) }
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
135
253
|
end # Cursor
|
136
254
|
|
137
255
|
end # Vedeu
|