vedeu 0.0.26 → 0.0.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/lib/vedeu/models/composition.rb +1 -0
- data/lib/vedeu/models/interface.rb +4 -4
- data/lib/vedeu/process/process.rb +2 -2
- data/lib/vedeu/support/geometry.rb +12 -4
- data/lib/vedeu/support/queue.rb +0 -1
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/models/composition_test.rb +54 -6
- data/test/lib/vedeu/models/interface_test.rb +22 -2
- data/test/lib/vedeu/output/interface_renderer_test.rb +46 -1
- data/test/lib/vedeu/support/events_test.rb +11 -3
- data/test/lib/vedeu/support/parser_test.rb +7 -25
- data/test/lib/vedeu/support/wordwrap_test.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e590fa41d87fd5be6367a2895240ddc3ea8b624d
|
4
|
+
data.tar.gz: 872c9d6dd4aa0c150609d528405c9db36a863bf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b30dbfb6dadb583d08726d1f6d4eca4fb82023216a52c69e10bc05d4af66572ce62291fc618863210ce4888e408032afa8b4ebd0f1a7a41f6a29364cd73c7a9
|
7
|
+
data.tar.gz: d8354d2b6a0dd7bfc6a5965a159fe7642b51bb0520affa5ca1f328cea82b258b12ae5e25f0d051478c0337147f3931e6ddb3306fca38e137b21686fed3eb6c6a
|
data/Rakefile
CHANGED
@@ -26,13 +26,13 @@ module Vedeu
|
|
26
26
|
|
27
27
|
def refresh
|
28
28
|
if enqueued?
|
29
|
-
current = dequeue
|
29
|
+
self.current = dequeue
|
30
30
|
|
31
31
|
elsif no_content?
|
32
|
-
current = clear_interface
|
32
|
+
self.current = clear_interface
|
33
33
|
|
34
34
|
else
|
35
|
-
current
|
35
|
+
self.current
|
36
36
|
|
37
37
|
end
|
38
38
|
end
|
@@ -48,7 +48,7 @@ module Vedeu
|
|
48
48
|
private
|
49
49
|
|
50
50
|
def no_content?
|
51
|
-
current.nil? || current.empty?
|
51
|
+
self.current.nil? || self.current.empty?
|
52
52
|
end
|
53
53
|
|
54
54
|
def render_content
|
@@ -24,8 +24,8 @@ module Vedeu
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def max_y
|
27
|
-
if ((y + height) >
|
28
|
-
|
27
|
+
if ((y + height) > screen_height)
|
28
|
+
screen_height
|
29
29
|
|
30
30
|
else
|
31
31
|
(y + height)
|
@@ -34,8 +34,8 @@ module Vedeu
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def max_x
|
37
|
-
if ((x + width) >
|
38
|
-
|
37
|
+
if ((x + width) > screen_width)
|
38
|
+
screen_width
|
39
39
|
|
40
40
|
else
|
41
41
|
(x + width)
|
@@ -62,5 +62,13 @@ module Vedeu
|
|
62
62
|
def y
|
63
63
|
interface.y
|
64
64
|
end
|
65
|
+
|
66
|
+
def screen_height
|
67
|
+
@height ||= Terminal.height
|
68
|
+
end
|
69
|
+
|
70
|
+
def screen_width
|
71
|
+
@width ||= Terminal.width
|
72
|
+
end
|
65
73
|
end
|
66
74
|
end
|
data/lib/vedeu/support/queue.rb
CHANGED
data/lib/vedeu/version.rb
CHANGED
@@ -7,7 +7,13 @@ module Vedeu
|
|
7
7
|
let(:described_class) { Composition }
|
8
8
|
let(:described_instance) { described_class.new(attributes) }
|
9
9
|
let(:attributes) { { interfaces: interfaces } }
|
10
|
-
let(:interfaces) {
|
10
|
+
let(:interfaces) {
|
11
|
+
{
|
12
|
+
name: 'dummy',
|
13
|
+
width: 40,
|
14
|
+
height: 25
|
15
|
+
}
|
16
|
+
}
|
11
17
|
|
12
18
|
describe '#initialize' do
|
13
19
|
let(:subject) { described_instance }
|
@@ -15,17 +21,59 @@ module Vedeu
|
|
15
21
|
it 'returns a Composition instance' do
|
16
22
|
subject.must_be_instance_of(Composition)
|
17
23
|
end
|
24
|
+
|
25
|
+
it 'sets an instance variable' do
|
26
|
+
subject.instance_variable_get('@interfaces')
|
27
|
+
.must_be_instance_of(Array)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#interfaces' do
|
32
|
+
let(:subject) { described_instance.interfaces }
|
33
|
+
|
34
|
+
it 'returns an Array' do
|
35
|
+
subject.must_be_instance_of(Array)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'returns a collection of interfaces' do
|
39
|
+
subject.first.must_be_instance_of(Interface)
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when no interfaces are associated' do
|
43
|
+
let(:attributes) { {} }
|
44
|
+
|
45
|
+
it 'returns an empty collection' do
|
46
|
+
subject.must_be_empty
|
47
|
+
end
|
48
|
+
end
|
18
49
|
end
|
19
50
|
|
20
|
-
describe '
|
21
|
-
let(:subject)
|
51
|
+
describe '.enqueue' do
|
52
|
+
let(:subject) { described_class.enqueue(composition) }
|
53
|
+
let(:composition) {
|
54
|
+
{
|
55
|
+
interfaces: [
|
56
|
+
{ name: "enq1", lines: { streams: { text: "Some text..." } } },
|
57
|
+
{ name: "enq2", lines: { streams: { text: "Some text..." } } }
|
58
|
+
]
|
59
|
+
}
|
60
|
+
}
|
22
61
|
|
23
62
|
before do
|
24
|
-
InterfaceRepository.create(
|
63
|
+
InterfaceRepository.create(name: 'enq1', width: 15, height: 2)
|
64
|
+
InterfaceRepository.create(name: 'enq2', width: 15, height: 2)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'returns an Array' do
|
68
|
+
subject.must_be_instance_of(Array)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'returns a collection of interfaces' do
|
72
|
+
subject.first.must_be_instance_of(Interface)
|
25
73
|
end
|
26
74
|
|
27
|
-
it '
|
28
|
-
|
75
|
+
it 'enqueues the interfaces for rendering' do
|
76
|
+
subject.first.enqueued?.must_equal(true)
|
29
77
|
end
|
30
78
|
end
|
31
79
|
|
@@ -188,8 +188,28 @@ module Vedeu
|
|
188
188
|
subject.must_be_instance_of(String)
|
189
189
|
end
|
190
190
|
|
191
|
-
|
192
|
-
|
191
|
+
context 'when content is queued up to be displayed' do
|
192
|
+
before { described_instance.enqueue("\e[38;5;196m\e[48;5;16m\e[1;1HContent\e[1;1H\e[2;1HContent\e[2;1H\e[3;1HContent\e[3;1H") }
|
193
|
+
|
194
|
+
it 'returns the fresh content' do
|
195
|
+
subject.must_equal("\e[38;5;196m\e[48;5;16m\e[1;1HContent\e[1;1H\e[2;1HContent\e[2;1H\e[3;1HContent\e[3;1H")
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
context 'when there is no content to display (initial state)' do
|
200
|
+
it 'returns a blank interface' do
|
201
|
+
subject.must_equal("\e[38;5;196m\e[48;5;16m\e[1;1H \e[1;1H\e[2;1H \e[2;1H\e[3;1H \e[3;1H")
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
context 'when there is stale content from last run' do
|
206
|
+
before do
|
207
|
+
described_instance.current = "\e[38;5;196m\e[48;5;16m\e[1;1HOld\e[1;1H\e[2;1HContent\e[2;1H\e[3;1Here\e[3;1H"
|
208
|
+
end
|
209
|
+
|
210
|
+
it 'returns the previously shown content' do
|
211
|
+
subject.must_equal("\e[38;5;196m\e[48;5;16m\e[1;1HOld\e[1;1H\e[2;1HContent\e[2;1H\e[3;1Here\e[3;1H")
|
212
|
+
end
|
193
213
|
end
|
194
214
|
end
|
195
215
|
|
@@ -6,7 +6,52 @@ module Vedeu
|
|
6
6
|
describe InterfaceRenderer do
|
7
7
|
let(:described_class) { InterfaceRenderer }
|
8
8
|
let(:described_instance) { described_class.new(interface) }
|
9
|
-
let(:interface) { }
|
9
|
+
let(:interface) { Interface.new(attributes) }
|
10
|
+
let(:attributes) { { name: 'dummy', width: 20, height: 2 } }
|
10
11
|
|
12
|
+
describe '#initialize' do
|
13
|
+
let(:subject) { described_instance }
|
14
|
+
|
15
|
+
it 'returns an InterfaceRenderer instance' do
|
16
|
+
subject.must_be_instance_of(InterfaceRenderer)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'sets an instance variable' do
|
20
|
+
subject.instance_variable_get("@interface").must_equal(interface)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '.clear' do
|
25
|
+
let(:subject) { described_class.clear(interface) }
|
26
|
+
|
27
|
+
it 'returns a String' do
|
28
|
+
subject.must_be_instance_of(String)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'returns the escape sequence to clear the whole interface' do
|
32
|
+
subject.must_equal("\e[1;1H \e[1;1H\e[2;1H \e[2;1H")
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'when the interface has colour attributes' do
|
36
|
+
let(:attributes) { { name: 'dummy', width: 20, height: 2, colour: { foreground: '#00ff00', background: '#ffff00' } } }
|
37
|
+
|
38
|
+
it 'returns the escape sequence to clear the whole interface' do
|
39
|
+
subject.must_equal("\e[38;5;46m\e[48;5;226m\e[1;1H \e[1;1H\e[2;1H \e[2;1H")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '.render' do
|
45
|
+
let(:subject) { described_class.render(interface) }
|
46
|
+
let(:attributes) { { name: 'dummy', width: 20, height: 2, lines: "Some text..." } }
|
47
|
+
|
48
|
+
it 'returns a String' do
|
49
|
+
subject.must_be_instance_of(String)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'returns the content for the interface' do
|
53
|
+
subject.must_equal("\e[1;1HSome text...")
|
54
|
+
end
|
55
|
+
end
|
11
56
|
end
|
12
57
|
end
|
@@ -20,10 +20,10 @@ module Vedeu
|
|
20
20
|
end
|
21
21
|
|
22
22
|
describe '#on' do
|
23
|
-
let(:subject) { described_instance.on(event) {
|
23
|
+
let(:subject) { described_instance.on(event) { proc { |x, y| x + y } } }
|
24
24
|
let(:event) { :some_event }
|
25
25
|
|
26
|
-
it 'returns
|
26
|
+
it 'returns an Array' do
|
27
27
|
subject.must_be_instance_of(Array)
|
28
28
|
end
|
29
29
|
end
|
@@ -31,7 +31,15 @@ module Vedeu
|
|
31
31
|
describe '#trigger' do
|
32
32
|
let(:subject) { described_instance.trigger(event, args) }
|
33
33
|
let(:event) { :some_event }
|
34
|
-
let(:args) {}
|
34
|
+
let(:args) { :arg }
|
35
|
+
|
36
|
+
before do
|
37
|
+
described_instance.on(:some_event) { proc { |x| x } }
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'returns an Array' do
|
41
|
+
subject.must_be_instance_of(Array)
|
42
|
+
end
|
35
43
|
end
|
36
44
|
end
|
37
45
|
end
|
@@ -27,30 +27,12 @@ module Vedeu
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
# context 'when the output is an interface name and a stream' do
|
38
|
-
# it 'returns a composition' do
|
39
|
-
# subject.must_equal('')
|
40
|
-
# end
|
41
|
-
# end
|
42
|
-
|
43
|
-
# context 'when the output contains a single interface' do
|
44
|
-
# it 'returns a Composition instance' do
|
45
|
-
# subject.must_be_instance_of(Composition)
|
46
|
-
# end
|
47
|
-
# end
|
48
|
-
|
49
|
-
# context 'when the output contains multiple interfaces' do
|
50
|
-
# it 'returns a Composition instance' do
|
51
|
-
# subject.must_be_instance_of(Composition)
|
52
|
-
# end
|
53
|
-
# end
|
54
|
-
# end
|
30
|
+
describe '#parse' do
|
31
|
+
let(:subject) { described_class.parse(output) }
|
32
|
+
|
33
|
+
it 'returns a Composition' do
|
34
|
+
subject.must_be_instance_of(Composition)
|
35
|
+
end
|
36
|
+
end
|
55
37
|
end
|
56
38
|
end
|
@@ -59,6 +59,15 @@ module Vedeu
|
|
59
59
|
subject.must_equal(formatted_value)
|
60
60
|
end
|
61
61
|
end
|
62
|
+
|
63
|
+
context 'when the content is less than the prune size' do
|
64
|
+
let(:options) { { width: 70, prune: true } }
|
65
|
+
let(:value) { 'Some text...' }
|
66
|
+
|
67
|
+
it 'returns formatted text' do
|
68
|
+
subject.must_equal(value)
|
69
|
+
end
|
70
|
+
end
|
62
71
|
end
|
63
72
|
end
|
64
73
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vedeu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Laking
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|