vedeu 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +40 -0
- data/README.md +1 -0
- data/docs/dsl.md +24 -24
- data/lib/vedeu/all.rb +21 -44
- data/lib/vedeu/api.rb +13 -13
- data/lib/vedeu/application/application_controller.rb +2 -0
- data/lib/vedeu/bindings/movement.rb +53 -18
- data/lib/vedeu/bindings/refresh.rb +1 -1
- data/lib/vedeu/bindings/system.rb +2 -2
- data/lib/vedeu/bindings/visibility.rb +3 -3
- data/lib/vedeu/borders/all.rb +13 -0
- data/lib/vedeu/borders/border.rb +209 -202
- data/lib/vedeu/{dsl/border.rb → borders/dsl.rb} +15 -15
- data/lib/vedeu/{null/border.rb → borders/null.rb} +9 -9
- data/lib/vedeu/borders/render.rb +347 -0
- data/lib/vedeu/borders/repository.rb +19 -0
- data/lib/vedeu/buffers/all.rb +13 -0
- data/lib/vedeu/buffers/buffer.rb +182 -176
- data/lib/vedeu/{null/buffer.rb → buffers/null.rb} +8 -8
- data/lib/vedeu/buffers/repository.rb +24 -0
- data/lib/vedeu/buffers/virtual_buffer.rb +2 -2
- data/lib/vedeu/cursors/all.rb +11 -0
- data/lib/vedeu/cursors/cursor.rb +276 -0
- data/lib/vedeu/cursors/refresh.rb +84 -0
- data/lib/vedeu/cursors/repository.rb +34 -0
- data/lib/vedeu/dsl/interface.rb +9 -9
- data/lib/vedeu/dsl/shared.rb +11 -11
- data/lib/vedeu/{exceptions.rb → error.rb} +2 -2
- data/lib/vedeu/esc/esc.rb +1 -1
- data/lib/vedeu/geometry/all.rb +18 -0
- data/lib/vedeu/geometry/area.rb +170 -160
- data/lib/vedeu/geometry/coordinate.rb +61 -39
- data/lib/vedeu/geometry/dimension.rb +139 -132
- data/lib/vedeu/{dsl/geometry.rb → geometry/dsl.rb} +11 -11
- data/lib/vedeu/geometry/generic_coordinate.rb +159 -153
- data/lib/vedeu/geometry/geometry.rb +310 -212
- data/lib/vedeu/geometry/grid.rb +73 -69
- data/lib/vedeu/{null/geometry.rb → geometry/null.rb} +10 -10
- data/lib/vedeu/geometry/position.rb +124 -120
- data/lib/vedeu/geometry/repository.rb +19 -0
- data/lib/vedeu/input/editor/document.rb +2 -2
- data/lib/vedeu/internal_api.rb +8 -8
- data/lib/vedeu/models/escape.rb +2 -2
- data/lib/vedeu/models/interface.rb +1 -1
- data/lib/vedeu/models/page.rb +89 -0
- data/lib/vedeu/models/row.rb +66 -0
- data/lib/vedeu/models/toggleable.rb +1 -1
- data/lib/vedeu/models/views/char.rb +7 -6
- data/lib/vedeu/models/views/line.rb +1 -1
- data/lib/vedeu/models/views/view.rb +2 -2
- data/lib/vedeu/options.rb +19 -0
- data/lib/vedeu/output/clear/named_interface.rb +1 -1
- data/lib/vedeu/output/direct.rb +1 -1
- data/lib/vedeu/output/presentation.rb +2 -1
- data/lib/vedeu/output/viewport.rb +3 -3
- data/lib/vedeu/repositories/model.rb +9 -1
- data/lib/vedeu/repositories/repository.rb +5 -0
- data/lib/vedeu/terminal/terminal.rb +3 -3
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/borders/border_test.rb +299 -291
- data/test/lib/vedeu/{dsl/border_test.rb → borders/dsl_test.rb} +6 -6
- data/test/lib/vedeu/{null/border_test.rb → borders/null_test.rb} +6 -6
- data/test/lib/vedeu/borders/render_test.rb +125 -0
- data/test/lib/vedeu/borders/repository_test.rb +17 -0
- data/test/lib/vedeu/buffers/buffer_test.rb +116 -112
- data/test/lib/vedeu/{null/buffer_test.rb → buffers/null_test.rb} +5 -5
- data/test/lib/vedeu/buffers/repository_test.rb +18 -0
- data/test/lib/vedeu/cursors/cursor_test.rb +370 -0
- data/test/lib/vedeu/cursors/refresh_test.rb +69 -0
- data/test/lib/vedeu/cursors/repository_test.rb +41 -0
- data/test/lib/vedeu/dsl/interface_test.rb +5 -5
- data/test/lib/vedeu/{exceptions_test.rb → error_test.rb} +0 -0
- data/test/lib/vedeu/geometry/area_test.rb +141 -137
- data/test/lib/vedeu/geometry/coordinate_test.rb +93 -89
- data/test/lib/vedeu/geometry/dimension_test.rb +137 -133
- data/test/lib/vedeu/{dsl/geometry_test.rb → geometry/dsl_test.rb} +17 -17
- data/test/lib/vedeu/geometry/generic_coordinate_test.rb +32 -28
- data/test/lib/vedeu/geometry/geometry_test.rb +282 -157
- data/test/lib/vedeu/geometry/grid_test.rb +35 -31
- data/test/lib/vedeu/{null/geometry_test.rb → geometry/null_test.rb} +5 -5
- data/test/lib/vedeu/geometry/position_test.rb +146 -142
- data/test/lib/vedeu/geometry/repository_test.rb +19 -0
- data/test/lib/vedeu/input/editor/document_test.rb +1 -1
- data/test/lib/vedeu/models/escape_test.rb +1 -1
- data/test/lib/vedeu/models/interface_test.rb +2 -2
- data/test/lib/vedeu/models/page_test.rb +235 -0
- data/test/lib/vedeu/models/row_test.rb +111 -0
- data/test/lib/vedeu/models/views/char_test.rb +3 -3
- data/test/lib/vedeu/options_test.rb +57 -0
- data/test/lib/vedeu/output/clear/named_interface_test.rb +1 -1
- data/test/lib/vedeu/output/renderers/json_test.rb +1 -1
- data/test/lib/vedeu/output/viewport_test.rb +15 -9
- data/test/lib/vedeu/refresh/refresh_buffer_test.rb +12 -12
- data/test/lib/vedeu/repositories/repositories_test.rb +1 -1
- data/test/lib/vedeu/repositories/repository_test.rb +7 -0
- data/test/lib/vedeu/terminal/terminal_test.rb +1 -1
- data/test/test_helper.rb +1 -1
- data/vedeu.gemspec +2 -2
- metadata +57 -63
- data/lib/vedeu/borders/borders.rb +0 -15
- data/lib/vedeu/borders/render_border.rb +0 -331
- data/lib/vedeu/buffers/buffers.rb +0 -20
- data/lib/vedeu/cursor/cursor.rb +0 -174
- data/lib/vedeu/cursor/cursors.rb +0 -30
- data/lib/vedeu/cursor/move.rb +0 -239
- data/lib/vedeu/cursor/reposition.rb +0 -78
- data/lib/vedeu/geometry/geometries.rb +0 -15
- data/lib/vedeu/refresh/refresh_cursor.rb +0 -92
- data/test/lib/vedeu/borders/borders_test.rb +0 -13
- data/test/lib/vedeu/borders/render_border_test.rb +0 -121
- data/test/lib/vedeu/buffers/buffers_test.rb +0 -14
- data/test/lib/vedeu/cursor/cursor_test.rb +0 -246
- data/test/lib/vedeu/cursor/cursors_test.rb +0 -37
- data/test/lib/vedeu/cursor/move_test.rb +0 -301
- data/test/lib/vedeu/cursor/reposition_test.rb +0 -63
- data/test/lib/vedeu/geometry/geometries_test.rb +0 -15
- data/test/lib/vedeu/refresh/refresh_cursor_test.rb +0 -65
@@ -2,13 +2,13 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
module
|
5
|
+
module Borders
|
6
6
|
|
7
|
-
describe
|
7
|
+
describe DSL do
|
8
8
|
|
9
|
-
let(:described) { Vedeu::DSL
|
9
|
+
let(:described) { Vedeu::Borders::DSL }
|
10
10
|
let(:instance) { described.new(model, client) }
|
11
|
-
let(:model) { Vedeu::Border.new(attributes) }
|
11
|
+
let(:model) { Vedeu::Borders::Border.new(attributes) }
|
12
12
|
let(:client) {}
|
13
13
|
let(:attributes) { { name: 'borders' } }
|
14
14
|
let(:boolean) { true }
|
@@ -243,8 +243,8 @@ module Vedeu
|
|
243
243
|
it { instance.must_respond_to(:vertical=) }
|
244
244
|
end
|
245
245
|
|
246
|
-
end #
|
246
|
+
end # DSL
|
247
247
|
|
248
|
-
end #
|
248
|
+
end # Borders
|
249
249
|
|
250
250
|
end # Vedeu
|
@@ -2,11 +2,11 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
module
|
5
|
+
module Borders
|
6
6
|
|
7
|
-
describe
|
7
|
+
describe Null do
|
8
8
|
|
9
|
-
let(:described) { Vedeu::Null
|
9
|
+
let(:described) { Vedeu::Borders::Null }
|
10
10
|
let(:instance) { described.new(attributes) }
|
11
11
|
let(:attributes){
|
12
12
|
{
|
@@ -15,7 +15,7 @@ module Vedeu
|
|
15
15
|
}
|
16
16
|
let(:_name) { 'null_border' }
|
17
17
|
let(:geometry) {
|
18
|
-
Vedeu::Geometry.new(name: _name, x: 4, y: 6, xn: 10, yn: 12)
|
18
|
+
Vedeu::Geometry::Geometry.new(name: _name, x: 4, y: 6, xn: 10, yn: 12)
|
19
19
|
}
|
20
20
|
|
21
21
|
before { Vedeu.geometries.stubs(:by_name).returns(geometry) }
|
@@ -93,8 +93,8 @@ module Vedeu
|
|
93
93
|
it { subject.must_equal(7) }
|
94
94
|
end
|
95
95
|
|
96
|
-
end #
|
96
|
+
end # Null
|
97
97
|
|
98
|
-
end #
|
98
|
+
end # Borders
|
99
99
|
|
100
100
|
end # Vedeu
|
@@ -0,0 +1,125 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Borders
|
6
|
+
|
7
|
+
describe Render do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Borders::Render }
|
10
|
+
let(:instance) { described.new(border) }
|
11
|
+
let(:border) {
|
12
|
+
Vedeu::Borders::Border.new(enabled: enabled,
|
13
|
+
name: _name,
|
14
|
+
title: title,
|
15
|
+
caption: caption,
|
16
|
+
show_top: show_top,
|
17
|
+
show_bottom: show_bottom,
|
18
|
+
show_left: show_left,
|
19
|
+
show_right: show_right)
|
20
|
+
}
|
21
|
+
let(:visible) { false }
|
22
|
+
let(:enabled) { false }
|
23
|
+
let(:_name) { 'Vedeu::RenderBorder' }
|
24
|
+
let(:title) {}
|
25
|
+
let(:caption) {}
|
26
|
+
let(:show_top) { true }
|
27
|
+
let(:show_bottom) { true }
|
28
|
+
let(:show_left) { true }
|
29
|
+
let(:show_right) { true }
|
30
|
+
|
31
|
+
it { described.must_respond_to(:with) }
|
32
|
+
|
33
|
+
describe '#initialize' do
|
34
|
+
it { instance.must_be_instance_of(described) }
|
35
|
+
it { instance.instance_variable_get('@border').must_equal(border) }
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#render' do
|
39
|
+
let(:geometry) {
|
40
|
+
Vedeu::Geometry::Geometry.new(name: _name, x: 1, xn: 7, y: 1, yn: 4)
|
41
|
+
}
|
42
|
+
let(:interface) {
|
43
|
+
Vedeu::Interface.new(name: _name, visible: visible)
|
44
|
+
}
|
45
|
+
before do
|
46
|
+
Vedeu.geometries.stubs(:by_name).returns(geometry)
|
47
|
+
Vedeu.interfaces.stubs(:by_name).returns(interface)
|
48
|
+
end
|
49
|
+
|
50
|
+
subject { instance.render }
|
51
|
+
|
52
|
+
context 'when the interface is not visible' do
|
53
|
+
it { subject.must_equal([]) }
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when the interface is visible' do
|
57
|
+
let(:visible) { true }
|
58
|
+
|
59
|
+
context 'when the border is not enabled' do
|
60
|
+
it { subject.must_equal([]) }
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'when the border is enabled' do
|
64
|
+
let(:enabled) { true }
|
65
|
+
|
66
|
+
context 'and a title is given' do
|
67
|
+
let(:title) { 'T' }
|
68
|
+
|
69
|
+
# @todo Add more tests.
|
70
|
+
it { subject.size.must_equal(18) }
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'and a title is not given' do
|
74
|
+
# @todo Add more tests.
|
75
|
+
it { subject.size.must_equal(18) }
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'and a caption is given' do
|
79
|
+
let(:caption) { 'C' }
|
80
|
+
|
81
|
+
# @todo Add more tests.
|
82
|
+
it { subject.size.must_equal(18) }
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'and a caption is not given' do
|
86
|
+
# @todo Add more tests.
|
87
|
+
it { subject.size.must_equal(18) }
|
88
|
+
end
|
89
|
+
|
90
|
+
context 'and the left side is disabled' do
|
91
|
+
let(:show_left) { false }
|
92
|
+
|
93
|
+
# @todo Add more tests.
|
94
|
+
it { subject.size.must_equal(16) }
|
95
|
+
end
|
96
|
+
|
97
|
+
context 'and the right side is disabled' do
|
98
|
+
let(:show_right) { false }
|
99
|
+
|
100
|
+
# @todo Add more tests.
|
101
|
+
it { subject.size.must_equal(16) }
|
102
|
+
end
|
103
|
+
|
104
|
+
context 'and the top side is disabled' do
|
105
|
+
let(:show_top) { false }
|
106
|
+
|
107
|
+
# @todo Add more tests.
|
108
|
+
it { subject.size.must_equal(13) }
|
109
|
+
end
|
110
|
+
|
111
|
+
context 'and the bottom side is disabled' do
|
112
|
+
let(:show_bottom) { false }
|
113
|
+
|
114
|
+
# @todo Add more tests.
|
115
|
+
it { subject.size.must_equal(13) }
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
end # Render
|
122
|
+
|
123
|
+
end # Borders
|
124
|
+
|
125
|
+
end # Vedeu
|
@@ -2,152 +2,156 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
{
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
5
|
+
module Buffers
|
6
|
+
|
7
|
+
describe Buffer do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Buffers::Buffer }
|
10
|
+
let(:instance) { described.new(attributes) }
|
11
|
+
let(:attributes) {
|
12
|
+
{
|
13
|
+
name: _name,
|
14
|
+
back: back,
|
15
|
+
front: front,
|
16
|
+
previous: previous,
|
17
|
+
}
|
15
18
|
}
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
19
|
+
let(:_name) { 'krypton' }
|
20
|
+
let(:back) {}
|
21
|
+
let(:front) {}
|
22
|
+
let(:previous) {}
|
23
|
+
let(:interface) {}
|
24
|
+
|
25
|
+
describe '#initialize' do
|
26
|
+
it { instance.must_be_instance_of(described) }
|
27
|
+
it { instance.instance_variable_get('@name').must_equal(_name) }
|
28
|
+
it { instance.instance_variable_get('@back').must_equal(back) }
|
29
|
+
it { instance.instance_variable_get('@front').must_equal(front) }
|
30
|
+
it { instance.instance_variable_get('@previous').must_equal(previous) }
|
31
|
+
it do
|
32
|
+
instance.instance_variable_get('@repository').must_equal(Vedeu.buffers)
|
33
|
+
end
|
31
34
|
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe 'accessors' do
|
35
|
-
it { instance.must_respond_to(:back) }
|
36
|
-
it { instance.must_respond_to(:back=) }
|
37
|
-
it { instance.must_respond_to(:front) }
|
38
|
-
it { instance.must_respond_to(:front=) }
|
39
|
-
it { instance.must_respond_to(:previous) }
|
40
|
-
it { instance.must_respond_to(:previous=) }
|
41
|
-
it { instance.must_respond_to(:name) }
|
42
|
-
end
|
43
|
-
|
44
|
-
describe '#add' do
|
45
|
-
let(:content) { Vedeu::Views::View.new(value: [Vedeu::Views::Line.new]) }
|
46
|
-
|
47
|
-
subject { instance.add(content) }
|
48
35
|
|
49
|
-
|
50
|
-
|
36
|
+
describe 'accessors' do
|
37
|
+
it { instance.must_respond_to(:back) }
|
38
|
+
it { instance.must_respond_to(:back=) }
|
39
|
+
it { instance.must_respond_to(:front) }
|
40
|
+
it { instance.must_respond_to(:front=) }
|
41
|
+
it { instance.must_respond_to(:previous) }
|
42
|
+
it { instance.must_respond_to(:previous=) }
|
43
|
+
it { instance.must_respond_to(:name) }
|
44
|
+
end
|
51
45
|
|
52
|
-
|
53
|
-
|
46
|
+
describe '#add' do
|
47
|
+
let(:content) { Vedeu::Views::View.new(value: [Vedeu::Views::Line.new]) }
|
54
48
|
|
55
|
-
|
56
|
-
let(:back) {
|
57
|
-
Vedeu::Views::View.new(value: [Vedeu::Views::Line.new])
|
58
|
-
}
|
49
|
+
subject { instance.add(content) }
|
59
50
|
|
60
51
|
it { subject.must_equal(true) }
|
61
52
|
end
|
62
53
|
|
63
|
-
|
64
|
-
|
65
|
-
end
|
66
|
-
end
|
54
|
+
describe '#back?' do
|
55
|
+
subject { instance.back? }
|
67
56
|
|
68
|
-
|
69
|
-
|
57
|
+
context 'with content' do
|
58
|
+
let(:back) {
|
59
|
+
Vedeu::Views::View.new(value: [Vedeu::Views::Line.new])
|
60
|
+
}
|
70
61
|
|
71
|
-
|
72
|
-
|
73
|
-
|
62
|
+
it { subject.must_equal(true) }
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'without content' do
|
66
|
+
it { subject.must_equal(false) }
|
67
|
+
end
|
74
68
|
end
|
75
69
|
|
76
|
-
|
70
|
+
describe '#clear' do
|
71
|
+
let(:emptiness) { mock }
|
77
72
|
|
78
|
-
|
79
|
-
|
80
|
-
returns(emptiness)
|
81
|
-
|
82
|
-
subject
|
83
|
-
}
|
84
|
-
end
|
73
|
+
before do
|
74
|
+
Vedeu::Clear::NamedInterface.stubs(:render).returns(emptiness)
|
75
|
+
Vedeu::Output.stubs(:render).returns(emptiness)
|
76
|
+
end
|
85
77
|
|
86
|
-
|
87
|
-
subject { instance.front? }
|
78
|
+
subject { instance.clear }
|
88
79
|
|
89
|
-
|
90
|
-
|
91
|
-
|
80
|
+
it {
|
81
|
+
Vedeu::Clear::NamedInterface.expects(:render).with(_name).
|
82
|
+
returns(emptiness)
|
83
|
+
Vedeu::Output.expects(:render).with(emptiness)
|
84
|
+
subject
|
92
85
|
}
|
93
|
-
|
94
|
-
it { subject.must_equal(true) }
|
95
86
|
end
|
96
87
|
|
97
|
-
|
98
|
-
|
99
|
-
end
|
100
|
-
end
|
88
|
+
describe '#front?' do
|
89
|
+
subject { instance.front? }
|
101
90
|
|
102
|
-
|
103
|
-
|
91
|
+
context 'with content' do
|
92
|
+
let(:front) {
|
93
|
+
Vedeu::Views::View.new(value: [Vedeu::Views::Line.new])
|
94
|
+
}
|
104
95
|
|
105
|
-
|
106
|
-
|
107
|
-
Vedeu::Views::View.new(value: [Vedeu::Views::Line.new])
|
108
|
-
}
|
96
|
+
it { subject.must_equal(true) }
|
97
|
+
end
|
109
98
|
|
110
|
-
|
99
|
+
context 'without content' do
|
100
|
+
it { subject.must_equal(false) }
|
101
|
+
end
|
111
102
|
end
|
112
103
|
|
113
|
-
|
114
|
-
|
104
|
+
describe '#previous?' do
|
105
|
+
subject { instance.previous? }
|
106
|
+
|
107
|
+
context 'with content' do
|
108
|
+
let(:previous) {
|
109
|
+
Vedeu::Views::View.new(value: [Vedeu::Views::Line.new])
|
110
|
+
}
|
111
|
+
|
112
|
+
it { subject.must_equal(true) }
|
113
|
+
end
|
114
|
+
|
115
|
+
context 'without content' do
|
116
|
+
it { subject.must_equal(false) }
|
117
|
+
end
|
115
118
|
end
|
116
|
-
end
|
117
119
|
|
118
|
-
|
119
|
-
|
120
|
+
describe '#hide' do
|
121
|
+
before { Vedeu::Output.stubs(:render) }
|
120
122
|
|
121
|
-
|
123
|
+
subject { instance.hide }
|
122
124
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
125
|
+
it {
|
126
|
+
Vedeu::Output.expects(:render)
|
127
|
+
subject
|
128
|
+
}
|
129
|
+
end
|
128
130
|
|
129
|
-
|
130
|
-
|
131
|
+
describe '#show' do
|
132
|
+
before { Vedeu::Output.stubs(:render) }
|
131
133
|
|
132
|
-
|
134
|
+
subject { instance.show }
|
133
135
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
136
|
+
it {
|
137
|
+
Vedeu::Output.expects(:render)
|
138
|
+
subject
|
139
|
+
}
|
140
|
+
end
|
139
141
|
|
140
|
-
|
141
|
-
|
142
|
+
describe '#render' do
|
143
|
+
before { Vedeu::Output.stubs(:render) }
|
142
144
|
|
143
|
-
|
145
|
+
subject { instance.render }
|
144
146
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
147
|
+
it {
|
148
|
+
Vedeu::Output.expects(:render)
|
149
|
+
subject
|
150
|
+
}
|
151
|
+
end
|
152
|
+
|
153
|
+
end # Buffer
|
150
154
|
|
151
|
-
end #
|
155
|
+
end # Buffers
|
152
156
|
|
153
157
|
end # Vedeu
|