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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f1c1d57417fc05b09722865230c56b1ae0c255f
4
- data.tar.gz: bc49bf53438c817107da4b3487f3f3c7d8d65e88
3
+ metadata.gz: e590fa41d87fd5be6367a2895240ddc3ea8b624d
4
+ data.tar.gz: 872c9d6dd4aa0c150609d528405c9db36a863bf1
5
5
  SHA512:
6
- metadata.gz: 64922d74b257a74850aa87cf2455ba58a368060b0d3316f2a14fd3d63b774aaf2017c3ffb11dcdd2934e5f0007661d2c7b252a933a5e1a32ddad7cf761a2a8eb
7
- data.tar.gz: 5e3b0890b6121e88a5001e29b6cdf1541e2db0499bfe02f08fecc486bf9347956813394d5e5c7909e4453a0bb9e206a231272933d884afca2690e6a5bc9c1c88
6
+ metadata.gz: 9b30dbfb6dadb583d08726d1f6d4eca4fb82023216a52c69e10bc05d4af66572ce62291fc618863210ce4888e408032afa8b4ebd0f1a7a41f6a29364cd73c7a9
7
+ data.tar.gz: d8354d2b6a0dd7bfc6a5965a159fe7642b51bb0520affa5ca1f328cea82b258b12ae5e25f0d051478c0337147f3931e6ddb3306fca38e137b21686fed3eb6c6a
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ Rake::TestTask.new(:minitest) do |t|
5
5
  t.libs << 'lib/vedeu'
6
6
  t.test_files = FileList["test/lib/vedeu/*_test.rb",
7
7
  "test/lib/vedeu/**/*_test.rb"]
8
- t.verbose = false
8
+ # t.options = '-v' # verbose mode
9
9
  end
10
10
 
11
11
  task default: :minitest
@@ -16,6 +16,7 @@ module Vedeu
16
16
  def enqueue
17
17
  interfaces.map do |interface|
18
18
  interface.enqueue(interface.to_s)
19
+ interface
19
20
  end
20
21
  end
21
22
 
@@ -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
@@ -13,9 +13,9 @@ module Vedeu
13
13
  def evaluate
14
14
  fail StopIteration if no_result?
15
15
 
16
- json = Parser.parse(result)
16
+ parsed_data = Parser.parse(result)
17
17
 
18
- Composition.enqueue(json)
18
+ Composition.enqueue(parsed_data)
19
19
  end
20
20
 
21
21
  private
@@ -24,8 +24,8 @@ module Vedeu
24
24
  end
25
25
 
26
26
  def max_y
27
- if ((y + height) > Terminal.height)
28
- Terminal.height
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) > Terminal.width)
38
- Terminal.width
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
@@ -8,7 +8,6 @@ module Vedeu
8
8
 
9
9
  def enqueue(result)
10
10
  store.unshift(result)
11
- store
12
11
  end
13
12
 
14
13
  def enqueued?
data/lib/vedeu/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Vedeu
2
- VERSION = '0.0.26'
2
+ VERSION = '0.0.27'
3
3
  end
@@ -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) { { name: 'dummy', width: 40, height: 25 } }
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 '#enqueue' do
21
- let(:subject) { described_instance.enqueue }
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({ name: 'dummy', width: 10, height: 2 })
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 'creates a composition and enqueues the interface for rendering' do
28
- skip
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
- it 'returns a String' do
192
- 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")
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) { :do_something } }
23
+ let(:subject) { described_instance.on(event) { proc { |x, y| x + y } } }
24
24
  let(:event) { :some_event }
25
25
 
26
- it 'returns the handlers value' do
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
- # 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
-
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.26
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-05 00:00:00.000000000 Z
11
+ date: 2014-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler