vedeu 0.6.9 → 0.6.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/lib/vedeu/all.rb +3 -3
- data/lib/vedeu/api/external.rb +194 -0
- data/lib/vedeu/api/internal.rb +173 -0
- data/lib/vedeu/application/controller.rb +3 -2
- data/lib/vedeu/bindings/application.rb +1 -1
- data/lib/vedeu/bindings/drb.rb +2 -3
- data/lib/vedeu/bindings/movement.rb +1 -1
- data/lib/vedeu/buffers/all.rb +0 -2
- data/lib/vedeu/colours/translator.rb +2 -1
- data/lib/vedeu/common.rb +4 -2
- data/lib/vedeu/configuration/api.rb +1 -1
- data/lib/vedeu/configuration/cli.rb +1 -1
- data/lib/vedeu/cursors/repository.rb +1 -1
- data/lib/vedeu/editor/insert.rb +12 -13
- data/lib/vedeu/geometry/position.rb +1 -1
- data/lib/vedeu/models/cell.rb +35 -21
- data/lib/vedeu/models/escape.rb +18 -1
- data/lib/vedeu/models/page.rb +20 -10
- data/lib/vedeu/models/row.rb +18 -8
- data/lib/vedeu/models/views/char.rb +9 -7
- data/lib/vedeu/models/views/view.rb +1 -1
- data/lib/vedeu/output/compressor.rb +22 -14
- data/lib/vedeu/output/output.rb +1 -10
- data/lib/vedeu/output/renderers/escape_sequence.rb +8 -4
- data/lib/vedeu/output/renderers/file.rb +7 -23
- data/lib/vedeu/output/renderers/html.rb +47 -26
- data/lib/vedeu/output/renderers/json.rb +11 -16
- data/lib/vedeu/output/renderers/null.rb +1 -1
- data/lib/vedeu/output/renderers/renderer_options.rb +2 -1
- data/lib/vedeu/output/renderers/terminal.rb +7 -15
- data/lib/vedeu/output/renderers/text.rb +1 -1
- data/lib/vedeu/output/viewport.rb +154 -143
- data/lib/vedeu/repositories/collection.rb +2 -2
- data/lib/vedeu/repositories/model.rb +25 -26
- data/lib/vedeu/repositories/registerable.rb +9 -8
- data/lib/vedeu/repositories/repository.rb +21 -16
- data/lib/vedeu/repositories/store.rb +6 -4
- data/lib/vedeu/runtime/bootstrap.rb +7 -5
- data/lib/vedeu/runtime/main_loop.rb +2 -0
- data/lib/vedeu/runtime/router.rb +155 -149
- data/lib/vedeu/templating/decoder.rb +8 -5
- data/lib/vedeu/templating/encoder.rb +6 -4
- data/lib/vedeu/templating/template.rb +2 -2
- data/lib/vedeu/templating/view_template.rb +8 -7
- data/lib/vedeu/terminal/buffer.rb +132 -0
- data/lib/vedeu/terminal/terminal.rb +0 -5
- data/lib/vedeu/version.rb +1 -1
- data/lib/vedeu.rb +2 -2
- data/out_ +50 -0
- data/test/lib/vedeu/api/external_test.rb +62 -0
- data/test/lib/vedeu/{internal_api_test.rb → api/internal_test.rb} +6 -2
- data/test/lib/vedeu/application/controller_test.rb +3 -3
- data/test/lib/vedeu/bindings/application_test.rb +2 -2
- data/test/lib/vedeu/models/cell_test.rb +48 -17
- data/test/lib/vedeu/models/escape_test.rb +29 -7
- data/test/lib/vedeu/models/page_test.rb +70 -50
- data/test/lib/vedeu/models/row_test.rb +40 -20
- data/test/lib/vedeu/output/compressor_test.rb +12 -12
- data/test/lib/vedeu/output/output_test.rb +17 -23
- data/test/lib/vedeu/output/renderers/escape_sequence_test.rb +15 -11
- data/test/lib/vedeu/output/renderers/html_test.rb +66 -68
- data/test/lib/vedeu/output/renderers/json_test.rb +36 -83
- data/test/lib/vedeu/output/renderers/terminal_test.rb +22 -2
- data/test/lib/vedeu/output/viewport_test.rb +201 -197
- data/test/lib/vedeu/runtime/router_test.rb +144 -140
- data/test/lib/vedeu/terminal/buffer_test.rb +307 -0
- data/test/support/examples/material_colours_app.rb +2 -2
- data/test/support/templates/html_renderer.vedeu +24 -0
- metadata +14 -17
- data/lib/vedeu/api.rb +0 -190
- data/lib/vedeu/buffers/virtual_buffer.rb +0 -136
- data/lib/vedeu/buffers/virtual_buffers.rb +0 -77
- data/lib/vedeu/internal_api.rb +0 -173
- data/lib/vedeu/terminal/content.rb +0 -88
- data/test/lib/vedeu/api_test.rb +0 -58
- data/test/lib/vedeu/buffers/virtual_buffer_test.rb +0 -148
- data/test/lib/vedeu/buffers/virtual_buffers_test.rb +0 -73
- data/test/lib/vedeu/terminal/content_test.rb +0 -108
@@ -13,192 +13,196 @@ module Vedeu
|
|
13
13
|
|
14
14
|
end # SomeController
|
15
15
|
|
16
|
-
|
16
|
+
module Runtime
|
17
17
|
|
18
|
-
|
18
|
+
describe Router do
|
19
19
|
|
20
|
-
|
20
|
+
let(:described) { Vedeu::Runtime::Router }
|
21
21
|
|
22
|
-
|
23
|
-
let(:controller) {}
|
24
|
-
let(:klass) { "SomeController" }
|
22
|
+
before { described.reset! }
|
25
23
|
|
26
|
-
|
24
|
+
describe '.add_controller' do
|
25
|
+
let(:controller) {}
|
26
|
+
let(:klass) { "SomeController" }
|
27
27
|
|
28
|
-
|
29
|
-
it { proc { subject }.must_raise(Vedeu::Error::MissingRequired) }
|
30
|
-
end
|
28
|
+
subject { described.add_controller(controller, klass) }
|
31
29
|
|
32
|
-
|
33
|
-
|
30
|
+
context 'when a name is not given' do
|
31
|
+
it { proc { subject }.must_raise(Vedeu::Error::MissingRequired) }
|
32
|
+
end
|
34
33
|
|
35
|
-
context 'when
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
context 'when a name is given' do
|
35
|
+
let(:controller) { :some_controller }
|
36
|
+
|
37
|
+
context 'when the controller is registered' do
|
38
|
+
before do
|
39
|
+
described.add_controller(controller, '')
|
40
|
+
described.add_action(controller, :show_basket)
|
41
|
+
end
|
42
|
+
after { described.reset! }
|
43
|
+
|
44
|
+
it {
|
45
|
+
subject.must_equal({
|
46
|
+
some_controller: {
|
47
|
+
klass: 'SomeController',
|
48
|
+
actions: [:show_basket]
|
49
|
+
}
|
50
|
+
})
|
51
|
+
}
|
39
52
|
end
|
40
|
-
after { described.reset! }
|
41
|
-
|
42
|
-
it {
|
43
|
-
subject.must_equal({
|
44
|
-
some_controller: {
|
45
|
-
klass: 'SomeController',
|
46
|
-
actions: [:show_basket]
|
47
|
-
}
|
48
|
-
})
|
49
|
-
}
|
50
|
-
end
|
51
53
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
54
|
+
context 'when the controller is not registered' do
|
55
|
+
it {
|
56
|
+
subject.must_equal({
|
57
|
+
some_controller: {
|
58
|
+
klass: 'SomeController',
|
59
|
+
actions: []
|
60
|
+
}
|
61
|
+
})
|
62
|
+
}
|
63
|
+
end
|
61
64
|
end
|
62
65
|
end
|
63
|
-
end
|
64
|
-
|
65
|
-
describe '.add_action' do
|
66
|
-
let(:controller) {}
|
67
|
-
let(:action) {}
|
68
66
|
|
69
|
-
|
67
|
+
describe '.add_action' do
|
68
|
+
let(:controller) {}
|
69
|
+
let(:action) {}
|
70
70
|
|
71
|
-
|
72
|
-
let(:action) { :some_action }
|
71
|
+
subject { described.add_action(controller, action) }
|
73
72
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
context 'when the name is not given' do
|
78
|
-
let(:controller) { :some_controller }
|
73
|
+
context 'when the controller is not given' do
|
74
|
+
let(:action) { :some_action }
|
79
75
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
context 'when the controller and name is given' do
|
84
|
-
let(:controller) { :some_controller }
|
85
|
-
let(:action) { :some_action }
|
76
|
+
it { proc { subject }.must_raise(Vedeu::Error::MissingRequired) }
|
77
|
+
end
|
86
78
|
|
87
|
-
context 'when the
|
88
|
-
|
89
|
-
after { described.reset! }
|
79
|
+
context 'when the name is not given' do
|
80
|
+
let(:controller) { :some_controller }
|
90
81
|
|
91
|
-
it {
|
92
|
-
subject.must_equal({
|
93
|
-
some_controller: {
|
94
|
-
klass: 'SomeController',
|
95
|
-
actions: [:some_action]
|
96
|
-
}
|
97
|
-
})
|
98
|
-
}
|
82
|
+
it { proc { subject }.must_raise(Vedeu::Error::MissingRequired) }
|
99
83
|
end
|
100
84
|
|
101
|
-
context 'when the controller is
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
85
|
+
context 'when the controller and name is given' do
|
86
|
+
let(:controller) { :some_controller }
|
87
|
+
let(:action) { :some_action }
|
88
|
+
|
89
|
+
context 'when the controller is registered' do
|
90
|
+
before { described.add_controller(controller, 'SomeController') }
|
91
|
+
after { described.reset! }
|
92
|
+
|
93
|
+
it {
|
94
|
+
subject.must_equal({
|
95
|
+
some_controller: {
|
96
|
+
klass: 'SomeController',
|
97
|
+
actions: [:some_action]
|
98
|
+
}
|
99
|
+
})
|
100
|
+
}
|
101
|
+
end
|
102
|
+
|
103
|
+
context 'when the controller is not registered' do
|
104
|
+
before { described.reset! }
|
105
|
+
|
106
|
+
it {
|
107
|
+
subject.must_equal({
|
108
|
+
some_controller: {
|
109
|
+
klass: '',
|
110
|
+
actions: [:some_action]
|
111
|
+
}
|
112
|
+
})
|
113
|
+
}
|
114
|
+
end
|
112
115
|
end
|
113
116
|
end
|
114
|
-
end
|
115
117
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
118
|
+
describe '.goto' do
|
119
|
+
let(:controller) { :some_controller }
|
120
|
+
let(:action) { :some_action }
|
121
|
+
let(:args) {
|
122
|
+
{
|
123
|
+
customer_id: 7,
|
124
|
+
product_id: 88,
|
125
|
+
}
|
123
126
|
}
|
124
|
-
}
|
125
127
|
|
126
|
-
|
128
|
+
subject { described.goto(controller, action, **args) }
|
127
129
|
|
128
|
-
|
130
|
+
it { described.must_respond_to(:action) }
|
129
131
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
132
|
+
context 'when the controller is registered' do
|
133
|
+
context 'when the controller klass is defined' do
|
134
|
+
before do
|
135
|
+
described.add_controller(controller, 'Vedeu::SomeController')
|
136
|
+
described.add_action(controller, action)
|
137
|
+
end
|
138
|
+
after { described.reset! }
|
139
|
+
|
140
|
+
it {
|
141
|
+
subject.must_equal({
|
142
|
+
customer: {
|
143
|
+
name: 'Gavin Laking',
|
144
|
+
customer_id: 7
|
145
|
+
},
|
146
|
+
basket: {
|
147
|
+
product_ids: [88]
|
148
|
+
}
|
149
|
+
})
|
150
|
+
}
|
135
151
|
end
|
136
|
-
after { described.reset! }
|
137
|
-
|
138
|
-
it {
|
139
|
-
subject.must_equal({
|
140
|
-
customer: {
|
141
|
-
name: 'Gavin Laking',
|
142
|
-
customer_id: 7
|
143
|
-
},
|
144
|
-
basket: {
|
145
|
-
product_ids: [88]
|
146
|
-
}
|
147
|
-
})
|
148
|
-
}
|
149
|
-
end
|
150
152
|
|
151
|
-
|
152
|
-
|
153
|
+
context 'when the action is not defined for this controller' do
|
154
|
+
let(:action) { :undefined_action }
|
155
|
+
|
156
|
+
before do
|
157
|
+
described.add_controller(controller, 'Vedeu::SomeController')
|
158
|
+
end
|
153
159
|
|
154
|
-
|
155
|
-
described.add_controller(controller, 'Vedeu::SomeController')
|
160
|
+
it { proc { subject }.must_raise(Vedeu::Error::ActionNotFound) }
|
156
161
|
end
|
157
162
|
|
158
|
-
|
159
|
-
|
163
|
+
context 'when the controller klass is not defined' do
|
164
|
+
before do
|
165
|
+
described.add_controller(controller, '')
|
166
|
+
described.add_action(controller, action)
|
167
|
+
end
|
168
|
+
after { described.reset! }
|
160
169
|
|
161
|
-
|
162
|
-
before do
|
163
|
-
described.add_controller(controller, '')
|
164
|
-
described.add_action(controller, action)
|
170
|
+
it { proc { subject }.must_raise(Vedeu::Error::MissingRequired) }
|
165
171
|
end
|
166
|
-
|
172
|
+
end
|
167
173
|
|
168
|
-
|
174
|
+
context 'when the controller is not registered' do
|
175
|
+
it { proc { subject }.must_raise(Vedeu::Error::ControllerNotFound) }
|
169
176
|
end
|
170
177
|
end
|
171
178
|
|
172
|
-
|
173
|
-
|
174
|
-
end
|
175
|
-
end
|
179
|
+
describe '.registered' do
|
180
|
+
let(:controller) { :some_controller }
|
176
181
|
|
177
|
-
|
178
|
-
let(:controller) { :some_controller }
|
182
|
+
subject { described.registered?(controller) }
|
179
183
|
|
180
|
-
|
184
|
+
context 'when the controller is registered' do
|
185
|
+
before { described.add_controller(controller, "SomeController") }
|
186
|
+
after { described.reset! }
|
181
187
|
|
182
|
-
|
183
|
-
|
184
|
-
after { described.reset! }
|
188
|
+
it { subject.must_equal(true) }
|
189
|
+
end
|
185
190
|
|
186
|
-
|
191
|
+
context 'when the controller is not registered' do
|
192
|
+
it { subject.must_equal(false) }
|
193
|
+
end
|
187
194
|
end
|
188
195
|
|
189
|
-
|
190
|
-
|
191
|
-
end
|
192
|
-
end
|
196
|
+
describe '.reset!' do
|
197
|
+
subject { described.reset! }
|
193
198
|
|
194
|
-
|
195
|
-
subject { described.reset! }
|
199
|
+
it { subject.must_equal({}) }
|
196
200
|
|
197
|
-
|
201
|
+
it { described.must_respond_to(:reset) }
|
202
|
+
end
|
198
203
|
|
199
|
-
|
200
|
-
end
|
204
|
+
end # Router
|
201
205
|
|
202
|
-
end #
|
206
|
+
end # Runtime
|
203
207
|
|
204
208
|
end # Vedeu
|
@@ -0,0 +1,307 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Terminal
|
6
|
+
|
7
|
+
describe Buffer do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Terminal::Buffer }
|
10
|
+
let(:height) { 2 }
|
11
|
+
let(:width) { 3 }
|
12
|
+
|
13
|
+
before do
|
14
|
+
Vedeu.stubs(:height).returns(height)
|
15
|
+
Vedeu.stubs(:width).returns(width)
|
16
|
+
Vedeu::Terminal::Buffer.reset
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#buffer' do
|
20
|
+
let(:expected) {
|
21
|
+
Array.new(height) do |y|
|
22
|
+
Array.new(width) do |x|
|
23
|
+
Vedeu::Models::Cell.new(position: [y + 1, x + 1])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
}
|
27
|
+
|
28
|
+
subject { described.buffer }
|
29
|
+
|
30
|
+
it { subject.must_be_instance_of(Array) }
|
31
|
+
it { described.instance_variable_get('@output').must_equal(expected) }
|
32
|
+
it { subject.must_equal(expected) }
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#empty_buffer' do
|
36
|
+
let(:expected) {
|
37
|
+
Array.new(height) do |y|
|
38
|
+
Array.new(width) do |x|
|
39
|
+
Vedeu::Models::Cell.new(position: [y + 1, x + 1])
|
40
|
+
end
|
41
|
+
end
|
42
|
+
}
|
43
|
+
|
44
|
+
subject { described.empty_buffer }
|
45
|
+
|
46
|
+
it { subject.must_be_instance_of(Array) }
|
47
|
+
it { subject.must_equal(expected) }
|
48
|
+
end
|
49
|
+
|
50
|
+
# describe '#output' do
|
51
|
+
# subject { described.output }
|
52
|
+
|
53
|
+
# context 'when nothing has been written to the buffer' do
|
54
|
+
# it {
|
55
|
+
# described.instance_variable_get('@output').must_equal(empty_buffer)
|
56
|
+
# }
|
57
|
+
# end
|
58
|
+
|
59
|
+
# context 'when something has been written to the buffer' do
|
60
|
+
# let(:expected) {
|
61
|
+
# exp = empty_buffer
|
62
|
+
# exp[1][2] = Vedeu::Views::Char.new(value: 'a', position: [1, 2])
|
63
|
+
# exp
|
64
|
+
# }
|
65
|
+
|
66
|
+
# before do
|
67
|
+
# described.write(Vedeu::Views::Char.new(value: 'a',
|
68
|
+
# position: [1, 2]))
|
69
|
+
# end
|
70
|
+
|
71
|
+
# it { described.instance_variable_get('@output').must_equal(expected) }
|
72
|
+
# end
|
73
|
+
# end
|
74
|
+
|
75
|
+
describe '#render' do
|
76
|
+
let(:ready) { false }
|
77
|
+
|
78
|
+
before { Vedeu.stubs(:ready?).returns(ready) }
|
79
|
+
|
80
|
+
subject { described.render }
|
81
|
+
|
82
|
+
context 'when Vedeu is not ready' do
|
83
|
+
it { subject.must_equal(nil) }
|
84
|
+
end
|
85
|
+
|
86
|
+
context 'when Vedeu is ready' do
|
87
|
+
let(:ready) { true }
|
88
|
+
|
89
|
+
context 'when the buffer is empty' do
|
90
|
+
# it {
|
91
|
+
# Vedeu.renderers.expects(:render).with(Vedeu::Models::Page)
|
92
|
+
# subject
|
93
|
+
# }
|
94
|
+
end
|
95
|
+
|
96
|
+
context 'when the buffer is not empty' do
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe '#reset' do
|
102
|
+
let(:output) {
|
103
|
+
Array.new(height) do |y|
|
104
|
+
Array.new(width) do |x|
|
105
|
+
Vedeu::Models::Cell.new(position: [y + 1, x + 1])
|
106
|
+
end
|
107
|
+
end
|
108
|
+
}
|
109
|
+
|
110
|
+
subject { described.reset }
|
111
|
+
|
112
|
+
it { described.instance_variable_get('@output').must_equal(output) }
|
113
|
+
it { subject.must_be_instance_of(Array) }
|
114
|
+
it { subject.must_equal(output) }
|
115
|
+
|
116
|
+
it { described.must_respond_to(:clear) }
|
117
|
+
end
|
118
|
+
|
119
|
+
describe '#write' do
|
120
|
+
let(:_value) {}
|
121
|
+
|
122
|
+
subject { described.write(_value) }
|
123
|
+
|
124
|
+
# context 'when the value is nil' do
|
125
|
+
# let(:expected) {
|
126
|
+
# [
|
127
|
+
# [
|
128
|
+
# Vedeu::Models::Cell.new(position: [1, 1]),
|
129
|
+
# Vedeu::Models::Cell.new(position: [1, 2]),
|
130
|
+
# Vedeu::Models::Cell.new(position: [1, 3])
|
131
|
+
# ], [
|
132
|
+
# Vedeu::Models::Cell.new(position: [2, 1]),
|
133
|
+
# Vedeu::Models::Cell.new(position: [2, 2]),
|
134
|
+
# Vedeu::Models::Cell.new(position: [2, 3])
|
135
|
+
# ]
|
136
|
+
# ]
|
137
|
+
# }
|
138
|
+
|
139
|
+
# it { subject.must_equal(described) }
|
140
|
+
# it { described.output.must_equal(expected) }
|
141
|
+
# end
|
142
|
+
|
143
|
+
# context 'when the value is not nil' do
|
144
|
+
# let(:_value) { Vedeu::Views::Char.new(y: 2, x: 1, value: 'a') }
|
145
|
+
# let(:expected) {
|
146
|
+
|
147
|
+
# }
|
148
|
+
|
149
|
+
# it { subject.must_equal(described) }
|
150
|
+
# it { described.output.must_equal(expected) }
|
151
|
+
# end
|
152
|
+
end
|
153
|
+
|
154
|
+
end # Buffer
|
155
|
+
|
156
|
+
end # Terminal
|
157
|
+
|
158
|
+
end # Vedeu
|
159
|
+
|
160
|
+
# require 'test_helper'
|
161
|
+
|
162
|
+
# module Vedeu
|
163
|
+
|
164
|
+
# module Buffers
|
165
|
+
|
166
|
+
# describe VirtualBuffer do
|
167
|
+
|
168
|
+
# let(:described) { Vedeu::Buffers::VirtualBuffer }
|
169
|
+
# let(:instance) { described.new(height, width, renderer) }
|
170
|
+
# let(:height) { 3 }
|
171
|
+
# let(:width) { 3 }
|
172
|
+
# let(:renderer) { Vedeu::Renderers::HTML.new }
|
173
|
+
|
174
|
+
# describe '#initialize' do
|
175
|
+
# it { instance.must_be_instance_of(described) }
|
176
|
+
# it { instance.instance_variable_get('@height').must_equal(3) }
|
177
|
+
# it { instance.instance_variable_get('@width').must_equal(3) }
|
178
|
+
# it { instance.instance_variable_get('@renderer').must_equal(renderer) }
|
179
|
+
# end
|
180
|
+
|
181
|
+
# describe 'accessors' do
|
182
|
+
# it { instance.must_respond_to(:renderer) }
|
183
|
+
# it { instance.must_respond_to(:renderer=) }
|
184
|
+
# it { instance.must_respond_to(:height) }
|
185
|
+
# it { instance.must_respond_to(:width) }
|
186
|
+
# end
|
187
|
+
|
188
|
+
# describe '.output' do
|
189
|
+
# let(:data) {}
|
190
|
+
|
191
|
+
# before do
|
192
|
+
# Vedeu.stubs(:width).returns(3)
|
193
|
+
# Vedeu.stubs(:height).returns(3)
|
194
|
+
# end
|
195
|
+
|
196
|
+
# subject { described.output(data) }
|
197
|
+
|
198
|
+
# it { subject.must_be_instance_of(Array) }
|
199
|
+
# end
|
200
|
+
|
201
|
+
# describe '#cells' do
|
202
|
+
# before do
|
203
|
+
# Vedeu.stubs(:width).returns(3)
|
204
|
+
# Vedeu.stubs(:height).returns(3)
|
205
|
+
# end
|
206
|
+
|
207
|
+
# subject { instance.cells }
|
208
|
+
|
209
|
+
# it { subject.must_be_instance_of(Array) }
|
210
|
+
# it { subject.size.must_equal(3) }
|
211
|
+
# it { subject.flatten.size.must_equal(9) }
|
212
|
+
# end
|
213
|
+
|
214
|
+
# describe '#read' do
|
215
|
+
# subject { instance.read(y, x) }
|
216
|
+
|
217
|
+
# context 'when x is out of bounds' do
|
218
|
+
# let(:y) { 1 }
|
219
|
+
# let(:x) { 5 }
|
220
|
+
|
221
|
+
# it { subject.must_equal([]) }
|
222
|
+
# end
|
223
|
+
|
224
|
+
# context 'when y is out of bounds' do
|
225
|
+
# let(:y) { 5 }
|
226
|
+
# let(:x) { 1 }
|
227
|
+
|
228
|
+
# it { subject.must_equal([]) }
|
229
|
+
# end
|
230
|
+
|
231
|
+
# context 'when both x and y are out of bounds' do
|
232
|
+
# let(:y) { 5 }
|
233
|
+
# let(:x) { 5 }
|
234
|
+
|
235
|
+
# it { subject.must_equal([]) }
|
236
|
+
# end
|
237
|
+
|
238
|
+
# context 'when x and y are in bounds' do
|
239
|
+
# let(:y) { 0 }
|
240
|
+
# let(:x) { 2 }
|
241
|
+
|
242
|
+
# it { subject.must_be_instance_of(Vedeu::Models::Cell) }
|
243
|
+
# end
|
244
|
+
# end
|
245
|
+
|
246
|
+
# describe '#output' do
|
247
|
+
# it { instance.must_respond_to(:output) }
|
248
|
+
# end
|
249
|
+
|
250
|
+
# describe '#render' do
|
251
|
+
# before do
|
252
|
+
# Vedeu.stubs(:width).returns(3)
|
253
|
+
# Vedeu.stubs(:height).returns(3)
|
254
|
+
# end
|
255
|
+
|
256
|
+
# subject { instance.render }
|
257
|
+
|
258
|
+
# it { subject.must_be_instance_of(String) }
|
259
|
+
# end
|
260
|
+
|
261
|
+
# describe '#reset' do
|
262
|
+
# subject { instance.reset }
|
263
|
+
|
264
|
+
# it { subject.must_be_instance_of(Array) }
|
265
|
+
|
266
|
+
# it { instance.must_respond_to(:clear) }
|
267
|
+
# end
|
268
|
+
|
269
|
+
# describe '#write' do
|
270
|
+
# let(:data) { Vedeu::Views::Char.new(value: 'a') }
|
271
|
+
|
272
|
+
# subject { instance.write(y, x, data) }
|
273
|
+
|
274
|
+
# context 'when x is out of bounds' do
|
275
|
+
# let(:y) { 1 }
|
276
|
+
# let(:x) { 5 }
|
277
|
+
|
278
|
+
# it { subject.must_equal(false) }
|
279
|
+
# end
|
280
|
+
|
281
|
+
# context 'when y is out of bounds' do
|
282
|
+
# let(:y) { 5 }
|
283
|
+
# let(:x) { 1 }
|
284
|
+
|
285
|
+
# it { subject.must_equal(false) }
|
286
|
+
# end
|
287
|
+
|
288
|
+
# context 'when both x and y are out of bounds' do
|
289
|
+
# let(:y) { 5 }
|
290
|
+
# let(:x) { 5 }
|
291
|
+
|
292
|
+
# it { subject.must_equal(false) }
|
293
|
+
# end
|
294
|
+
|
295
|
+
# context 'when x and y are in bounds' do
|
296
|
+
# let(:y) { 0 }
|
297
|
+
# let(:x) { 2 }
|
298
|
+
|
299
|
+
# it { subject.must_equal(true) }
|
300
|
+
# end
|
301
|
+
# end
|
302
|
+
|
303
|
+
# end # VirtualBuffer
|
304
|
+
|
305
|
+
# end # Buffers
|
306
|
+
|
307
|
+
# end # Vedeu
|
@@ -24,9 +24,9 @@ class VedeuMaterialColoursApp
|
|
24
24
|
# Be aware that running an application with debugging enabled will affect
|
25
25
|
# performance.
|
26
26
|
Vedeu.configure do
|
27
|
-
|
27
|
+
debug!
|
28
28
|
log '/tmp/vedeu_material_colours_app.log'
|
29
|
-
|
29
|
+
renderers Vedeu::Renderers::HTML.new(filename: '/tmp/material', timestamp: true)
|
30
30
|
end
|
31
31
|
|
32
32
|
Vedeu.interface 'main_interface' do
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<style type='text/css'>
|
4
|
+
body {
|
5
|
+
background:#000;
|
6
|
+
}
|
7
|
+
td {
|
8
|
+
border:1px #171717 solid;
|
9
|
+
font-size:12px;
|
10
|
+
font-family:monospace;
|
11
|
+
height:18px;
|
12
|
+
margin:1px;
|
13
|
+
text-align:center;
|
14
|
+
vertical-align:center;
|
15
|
+
width:18px;
|
16
|
+
}
|
17
|
+
</style>
|
18
|
+
</head>
|
19
|
+
<body>
|
20
|
+
<table>
|
21
|
+
<%= @object.html_body -%>
|
22
|
+
</table>
|
23
|
+
</body>
|
24
|
+
</html>
|