vedeu 0.6.51 → 0.6.52
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vedeu/borders/refresh.rb +1 -0
- data/lib/vedeu/buffers/all.rb +2 -0
- data/lib/vedeu/buffers/empty.rb +78 -0
- data/lib/vedeu/buffers/view.rb +51 -0
- data/lib/vedeu/colours/colour.rb +24 -12
- data/lib/vedeu/editor/cropper.rb +1 -1
- data/lib/vedeu/editor/cursor.rb +6 -2
- data/lib/vedeu/editor/document.rb +50 -32
- data/lib/vedeu/esc/actions.rb +0 -7
- data/lib/vedeu/esc/borders.rb +0 -7
- data/lib/vedeu/esc/colours.rb +0 -2
- data/lib/vedeu/esc/mouse.rb +0 -7
- data/lib/vedeu/events/event.rb +2 -2
- data/lib/vedeu/interfaces/clear.rb +1 -0
- data/lib/vedeu/logging/all.rb +1 -0
- data/lib/vedeu/logging/clock_time.rb +34 -0
- data/lib/vedeu/logging/log.rb +20 -18
- data/lib/vedeu/logging/timer.rb +2 -2
- data/lib/vedeu/models/cell.rb +10 -0
- data/lib/vedeu/models/views/char.rb +12 -0
- data/lib/vedeu/models/views/line.rb +5 -0
- data/lib/vedeu/models/views/stream.rb +6 -0
- data/lib/vedeu/output/compressor.rb +31 -2
- data/lib/vedeu/output/output.rb +25 -2
- data/lib/vedeu/output/presentation/colour.rb +9 -0
- data/lib/vedeu/output/presentation/styles.rb +3 -0
- data/lib/vedeu/output/renderers/file.rb +1 -1
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/buffers/empty_test.rb +87 -0
- data/test/lib/vedeu/buffers/view_test.rb +36 -0
- data/test/lib/vedeu/colours/colour_test.rb +10 -13
- data/test/lib/vedeu/editor/cursor_test.rb +23 -5
- data/test/lib/vedeu/interfaces/clear_test.rb +4 -6
- data/test/lib/vedeu/logging/clock_time_test.rb +13 -0
- data/test/lib/vedeu/logging/timer_test.rb +3 -5
- data/test/lib/vedeu/models/cell_test.rb +16 -0
- data/test/lib/vedeu/models/views/char_test.rb +18 -0
- data/test/lib/vedeu/models/views/html_char_test.rb +30 -17
- data/test/lib/vedeu/models/views/line_test.rb +14 -0
- data/test/lib/vedeu/models/views/stream_test.rb +14 -0
- data/test/lib/vedeu/output/compressor_test.rb +43 -21
- data/test/lib/vedeu/output/renderers/json_test.rb +4 -1
- data/test/lib/vedeu/output/renderers/terminal_test.rb +4 -3
- data/test/lib/vedeu/templating/encoder_test.rb +1 -1
- data/test/lib/vedeu/templating/helpers_test.rb +6 -6
- data/vedeu.gemspec +1 -1
- metadata +13 -4
@@ -15,6 +15,9 @@ module Vedeu
|
|
15
15
|
@style ||= if attributes[:style]
|
16
16
|
Vedeu::Presentation::Style.coerce(attributes[:style])
|
17
17
|
|
18
|
+
elsif self.is_a?(Vedeu::Views::Char) && name
|
19
|
+
Vedeu::Presentation::Style.coerce(interface.style)
|
20
|
+
|
18
21
|
elsif parent
|
19
22
|
Vedeu::Presentation::Style.coerce(parent.style)
|
20
23
|
|
data/lib/vedeu/version.rb
CHANGED
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Buffers
|
6
|
+
|
7
|
+
describe Empty do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Buffers::Empty }
|
10
|
+
let(:instance) { described.new(attributes) }
|
11
|
+
let(:attributes) {
|
12
|
+
{
|
13
|
+
height: height,
|
14
|
+
name: _name,
|
15
|
+
width: width,
|
16
|
+
}
|
17
|
+
}
|
18
|
+
let(:height) { 10 }
|
19
|
+
let(:_name) {}
|
20
|
+
let(:width) { 30 }
|
21
|
+
|
22
|
+
before do
|
23
|
+
Vedeu.stubs(:height).returns(12)
|
24
|
+
Vedeu.stubs(:width).returns(36)
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#initialize' do
|
28
|
+
it { instance.must_be_instance_of(described) }
|
29
|
+
|
30
|
+
context 'when the height is given' do
|
31
|
+
it { instance.instance_variable_get('@height').must_equal(10) }
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when the height not is given' do
|
35
|
+
let(:height) {}
|
36
|
+
|
37
|
+
it { instance.instance_variable_get('@height').must_equal(12) }
|
38
|
+
end
|
39
|
+
|
40
|
+
it { instance.instance_variable_get('@name').must_equal(_name) }
|
41
|
+
|
42
|
+
context 'when the width is given' do
|
43
|
+
it { instance.instance_variable_get('@width').must_equal(30) }
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'when the width not is given' do
|
47
|
+
let(:width) {}
|
48
|
+
|
49
|
+
it { instance.instance_variable_get('@width').must_equal(36) }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe 'accessors' do
|
54
|
+
it { instance.must_respond_to(:name) }
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#buffer' do
|
58
|
+
let(:position) { Vedeu::Geometry::Position.new(1, 1) }
|
59
|
+
|
60
|
+
subject { instance.buffer }
|
61
|
+
|
62
|
+
it { subject.must_be_instance_of(Array) }
|
63
|
+
it { subject.first.must_be_instance_of(Array) }
|
64
|
+
it { subject.first.first.must_be_instance_of(Vedeu::Models::Cell) }
|
65
|
+
|
66
|
+
it { subject.size.must_equal(31) }
|
67
|
+
it { subject.first.size.must_equal(11) }
|
68
|
+
it { subject.first.first.position.must_equal(position) }
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#height' do
|
72
|
+
subject { instance.height }
|
73
|
+
|
74
|
+
it { subject.must_equal(height + 1) }
|
75
|
+
end
|
76
|
+
|
77
|
+
describe '#width' do
|
78
|
+
subject { instance.width }
|
79
|
+
|
80
|
+
it { subject.must_equal(width + 1) }
|
81
|
+
end
|
82
|
+
|
83
|
+
end # Empty
|
84
|
+
|
85
|
+
end # Buffers
|
86
|
+
|
87
|
+
end # Vedeu
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Buffers
|
6
|
+
|
7
|
+
describe View do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Buffers::View }
|
10
|
+
let(:instance) { described.new(attributes) }
|
11
|
+
let(:_name) { 'Vedeu::Buffers::View' }
|
12
|
+
let(:attributes) {
|
13
|
+
{
|
14
|
+
name: _name,
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
describe '#initialize' do
|
19
|
+
it { instance.must_be_instance_of(described) }
|
20
|
+
|
21
|
+
context 'when a name is given' do
|
22
|
+
it { instance.instance_variable_get('@name').must_equal(_name) }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when a name is not given' do
|
26
|
+
let(:_name) {}
|
27
|
+
|
28
|
+
it { instance.instance_variable_get('@name').must_equal('') }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end # View
|
33
|
+
|
34
|
+
end # Buffers
|
35
|
+
|
36
|
+
end # Vedeu
|
@@ -19,19 +19,8 @@ module Vedeu
|
|
19
19
|
|
20
20
|
describe '#initialize' do
|
21
21
|
it { instance.must_be_instance_of(described) }
|
22
|
-
it {
|
23
|
-
|
24
|
-
must_be_instance_of(Vedeu::Colours::Background)
|
25
|
-
}
|
26
|
-
it {
|
27
|
-
instance.instance_variable_get('@foreground').
|
28
|
-
must_be_instance_of(Vedeu::Colours::Foreground)
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
|
-
describe 'accessors' do
|
33
|
-
it { instance.must_respond_to(:background) }
|
34
|
-
it { instance.must_respond_to(:foreground) }
|
22
|
+
it { instance.instance_variable_get('@background').must_equal(background)}
|
23
|
+
it { instance.instance_variable_get('@foreground').must_equal(foreground)}
|
35
24
|
end
|
36
25
|
|
37
26
|
describe '.coerce' do
|
@@ -187,6 +176,10 @@ module Vedeu
|
|
187
176
|
it { subject.must_equal(expected) }
|
188
177
|
end
|
189
178
|
|
179
|
+
describe '#background' do
|
180
|
+
# @todo Add more tests.
|
181
|
+
end
|
182
|
+
|
190
183
|
describe '#background=' do
|
191
184
|
let(:_value) { '#000000' }
|
192
185
|
|
@@ -209,6 +202,10 @@ module Vedeu
|
|
209
202
|
end
|
210
203
|
end
|
211
204
|
|
205
|
+
describe '#foreground' do
|
206
|
+
# @todo Add more tests.
|
207
|
+
end
|
208
|
+
|
212
209
|
describe '#foreground=' do
|
213
210
|
let(:_value) { '#ff0000' }
|
214
211
|
|
@@ -68,13 +68,22 @@ module Vedeu
|
|
68
68
|
end
|
69
69
|
|
70
70
|
describe '#down' do
|
71
|
-
let(:y)
|
71
|
+
let(:y) { 11 }
|
72
|
+
let(:size) {}
|
72
73
|
|
73
|
-
subject { instance.down }
|
74
|
+
subject { instance.down(size) }
|
74
75
|
|
75
76
|
it { subject.must_be_instance_of(described) }
|
76
77
|
|
77
78
|
it { subject.y.must_equal(12) }
|
79
|
+
it { subject.x.must_equal(0) }
|
80
|
+
|
81
|
+
context 'when a size is given and x > size' do
|
82
|
+
let(:x) { 15 }
|
83
|
+
let(:size) { 11 }
|
84
|
+
|
85
|
+
it { subject.x.must_equal(11) }
|
86
|
+
end
|
78
87
|
end
|
79
88
|
|
80
89
|
describe '#left' do
|
@@ -144,15 +153,24 @@ module Vedeu
|
|
144
153
|
end
|
145
154
|
|
146
155
|
describe '#up' do
|
147
|
-
let(:y)
|
148
|
-
let(:oy)
|
156
|
+
let(:y) { 11 }
|
157
|
+
let(:oy) { 2 }
|
158
|
+
let(:size) {}
|
149
159
|
|
150
|
-
subject { instance.up }
|
160
|
+
subject { instance.up(size) }
|
151
161
|
|
152
162
|
it { subject.must_be_instance_of(described) }
|
153
163
|
|
154
164
|
it { subject.y.must_equal(10) }
|
155
165
|
it { subject.oy.must_equal(1) }
|
166
|
+
it { subject.x.must_equal(0) }
|
167
|
+
|
168
|
+
context 'when a size is given and x > size' do
|
169
|
+
let(:x) { 15 }
|
170
|
+
let(:size) { 11 }
|
171
|
+
|
172
|
+
it { subject.x.must_equal(11) }
|
173
|
+
end
|
156
174
|
end
|
157
175
|
|
158
176
|
describe '#x' do
|
@@ -44,13 +44,11 @@ module Vedeu
|
|
44
44
|
let(:output) {
|
45
45
|
[
|
46
46
|
[
|
47
|
-
Vedeu::Views::Char.new(value: ' ', position: [1, 1]),
|
48
|
-
Vedeu::Views::Char.new(value: ' ', position: [1, 2]),
|
49
|
-
|
47
|
+
Vedeu::Views::Char.new(name: _name, value: ' ', position: [1, 1]),
|
48
|
+
Vedeu::Views::Char.new(name: _name, value: ' ', position: [1, 2]),
|
50
49
|
], [
|
51
|
-
Vedeu::Views::Char.new(value: ' ', position: [2, 1]),
|
52
|
-
Vedeu::Views::Char.new(value: ' ', position: [2, 2]),
|
53
|
-
|
50
|
+
Vedeu::Views::Char.new(name: _name, value: ' ', position: [2, 1]),
|
51
|
+
Vedeu::Views::Char.new(name: _name, value: ' ', position: [2, 2]),
|
54
52
|
]
|
55
53
|
]
|
56
54
|
}
|
@@ -9,18 +9,16 @@ module Vedeu
|
|
9
9
|
let(:described) { Vedeu::Logging::Timer }
|
10
10
|
let(:instance) { described.new(_message) }
|
11
11
|
let(:_message) { 'Testing' }
|
12
|
-
let(:_time) {
|
13
|
-
let(:started) { 1434492219.5238185 }
|
12
|
+
let(:_time) { 1219.523818 }
|
14
13
|
|
15
14
|
before do
|
16
|
-
|
17
|
-
_time.stubs(:to_f).returns(started)
|
15
|
+
Vedeu.stubs(:clock_time).returns(_time)
|
18
16
|
end
|
19
17
|
|
20
18
|
describe '#initialize' do
|
21
19
|
it { instance.must_be_instance_of(described) }
|
22
20
|
it { instance.instance_variable_get('@message').must_equal(_message) }
|
23
|
-
it { instance.instance_variable_get('@started').must_equal(
|
21
|
+
it { instance.instance_variable_get('@started').must_equal(_time) }
|
24
22
|
end
|
25
23
|
|
26
24
|
describe '.timer' do
|
@@ -11,12 +11,14 @@ module Vedeu
|
|
11
11
|
let(:attributes) {
|
12
12
|
{
|
13
13
|
colour: colour,
|
14
|
+
name: _name,
|
14
15
|
style: style,
|
15
16
|
value: _value,
|
16
17
|
position: position,
|
17
18
|
}
|
18
19
|
}
|
19
20
|
let(:colour) { Vedeu::Colours::Colour.new(background: '#000000') }
|
21
|
+
let(:_name) {}
|
20
22
|
let(:style) {}
|
21
23
|
let(:_value) {}
|
22
24
|
let(:position) {}
|
@@ -24,6 +26,7 @@ module Vedeu
|
|
24
26
|
describe '#initialize' do
|
25
27
|
it { instance.must_be_instance_of(described) }
|
26
28
|
it { instance.instance_variable_get('@colour').must_equal(colour) }
|
29
|
+
it { instance.instance_variable_get('@name').must_equal(_name) }
|
27
30
|
it { instance.instance_variable_get('@style').must_equal(style) }
|
28
31
|
it { instance.instance_variable_get('@value').must_equal('') }
|
29
32
|
it { instance.instance_variable_get('@position').must_equal([1, 1]) }
|
@@ -32,6 +35,7 @@ module Vedeu
|
|
32
35
|
describe 'accessors' do
|
33
36
|
it {
|
34
37
|
instance.must_respond_to(:colour)
|
38
|
+
instance.must_respond_to(:name)
|
35
39
|
instance.must_respond_to(:style)
|
36
40
|
instance.must_respond_to(:value)
|
37
41
|
}
|
@@ -57,6 +61,18 @@ module Vedeu
|
|
57
61
|
end
|
58
62
|
end
|
59
63
|
|
64
|
+
describe '#interface' do
|
65
|
+
let(:interface) { Vedeu::Interfaces::Interface.new }
|
66
|
+
|
67
|
+
before do
|
68
|
+
Vedeu.interfaces.stubs(:by_name).with(_name).returns(interface)
|
69
|
+
end
|
70
|
+
|
71
|
+
subject { instance.interface }
|
72
|
+
|
73
|
+
it { subject.must_be_instance_of(Vedeu::Interfaces::Interface) }
|
74
|
+
end
|
75
|
+
|
60
76
|
describe '#position' do
|
61
77
|
subject { instance.position }
|
62
78
|
|
@@ -25,6 +25,7 @@ module Vedeu
|
|
25
25
|
{
|
26
26
|
border: border,
|
27
27
|
colour: colour,
|
28
|
+
name: _name,
|
28
29
|
parent: parent,
|
29
30
|
position: position,
|
30
31
|
style: style,
|
@@ -43,6 +44,7 @@ module Vedeu
|
|
43
44
|
}
|
44
45
|
let(:border) { nil }
|
45
46
|
let(:colour) { nil }
|
47
|
+
let(:_name) { 'Vedeu::Views::Char' }
|
46
48
|
let(:style) { nil }
|
47
49
|
let(:position) { nil }
|
48
50
|
let(:parent_colour) { nil }
|
@@ -51,6 +53,7 @@ module Vedeu
|
|
51
53
|
describe '#initialize' do
|
52
54
|
it { instance.must_be_instance_of(described) }
|
53
55
|
it { instance.instance_variable_get('@border').must_equal(border) }
|
56
|
+
it { instance.instance_variable_get('@name').must_equal(_name) }
|
54
57
|
it { instance.instance_variable_get('@parent').must_equal(parent) }
|
55
58
|
it { instance.instance_variable_get('@value').must_equal(_value) }
|
56
59
|
|
@@ -61,6 +64,8 @@ module Vedeu
|
|
61
64
|
it {
|
62
65
|
instance.must_respond_to(:border)
|
63
66
|
instance.must_respond_to(:border=)
|
67
|
+
instance.must_respond_to(:name)
|
68
|
+
instance.must_respond_to(:name=)
|
64
69
|
instance.must_respond_to(:parent)
|
65
70
|
instance.must_respond_to(:parent=)
|
66
71
|
instance.must_respond_to(:attributes)
|
@@ -92,6 +97,18 @@ module Vedeu
|
|
92
97
|
end
|
93
98
|
end
|
94
99
|
|
100
|
+
describe '#interface' do
|
101
|
+
let(:interface) { Vedeu::Interfaces::Interface.new }
|
102
|
+
|
103
|
+
before do
|
104
|
+
Vedeu.interfaces.stubs(:by_name).with(_name).returns(interface)
|
105
|
+
end
|
106
|
+
|
107
|
+
subject { instance.interface }
|
108
|
+
|
109
|
+
it { subject.must_be_instance_of(Vedeu::Interfaces::Interface) }
|
110
|
+
end
|
111
|
+
|
95
112
|
describe '#position' do
|
96
113
|
subject { instance.position }
|
97
114
|
end
|
@@ -111,6 +128,7 @@ module Vedeu
|
|
111
128
|
background: '',
|
112
129
|
foreground: '',
|
113
130
|
},
|
131
|
+
name: 'Vedeu::Views::Char',
|
114
132
|
parent: {
|
115
133
|
background: '',
|
116
134
|
foreground: '',
|
@@ -19,12 +19,14 @@ module Vedeu
|
|
19
19
|
{
|
20
20
|
border: border,
|
21
21
|
colour: colour,
|
22
|
+
name: _name,
|
22
23
|
parent: parent,
|
23
24
|
value: _value
|
24
25
|
}
|
25
26
|
}
|
26
27
|
let(:border) {}
|
27
28
|
let(:colour) {}
|
29
|
+
let(:_name) { 'Vedeu::Views::HTMLChar' }
|
28
30
|
let(:parent) { Vedeu::Views::Line.new(colour: parent_colour) }
|
29
31
|
let(:parent_colour) {}
|
30
32
|
let(:_value) {}
|
@@ -61,25 +63,36 @@ module Vedeu
|
|
61
63
|
end
|
62
64
|
|
63
65
|
context 'when there is no colour' do
|
64
|
-
context 'when there is
|
65
|
-
|
66
|
-
Vedeu::Colours::Colour.new(background: '#002222',
|
67
|
-
foreground: '#dd2200')
|
68
|
-
}
|
69
|
-
|
70
|
-
it { subject.must_equal(
|
71
|
-
"<td style='" \
|
72
|
-
"border:1px #002222 solid;" \
|
73
|
-
"background:#002222;" \
|
74
|
-
"color:#dd2200;" \
|
75
|
-
"border-top:1px #dd2200 solid;" \
|
76
|
-
"border-left:1px #dd2200 solid;" \
|
77
|
-
"'> </td>"
|
78
|
-
) }
|
66
|
+
context 'when there is an interface' do
|
67
|
+
it { subject.must_equal("<td style=''> </td>") }
|
79
68
|
end
|
80
69
|
|
81
|
-
context 'when there is no
|
82
|
-
|
70
|
+
context 'when there is no interface' do
|
71
|
+
let(:_name) {}
|
72
|
+
|
73
|
+
context 'when there is a parent colour' do
|
74
|
+
let(:parent_colour) {
|
75
|
+
Vedeu::Colours::Colour.new(background: '#002222',
|
76
|
+
foreground: '#dd2200')
|
77
|
+
}
|
78
|
+
|
79
|
+
it { subject.must_equal(
|
80
|
+
"<td style='" \
|
81
|
+
"border:1px #002222 solid;" \
|
82
|
+
"background:#002222;" \
|
83
|
+
"color:#dd2200;" \
|
84
|
+
"border-top:1px #dd2200 solid;" \
|
85
|
+
"border-left:1px #dd2200 solid;" \
|
86
|
+
"'> </td>"
|
87
|
+
) }
|
88
|
+
end
|
89
|
+
|
90
|
+
context 'when there is no parent colour' do
|
91
|
+
let(:parent) {}
|
92
|
+
let(:parent_colour) {}
|
93
|
+
|
94
|
+
it { subject.must_equal("<td style=''> </td>") }
|
95
|
+
end
|
83
96
|
end
|
84
97
|
end
|
85
98
|
end
|