vedeu 0.2.8 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,6 +5,8 @@ module Vedeu
5
5
  describe Render do
6
6
 
7
7
  before do
8
+ Terminal.console.stubs(:print)
9
+
8
10
  Buffers.reset
9
11
  Cursors.reset
10
12
  Interfaces.reset
@@ -38,7 +40,7 @@ module Vedeu
38
40
  "\e[3;1H \e[3;1H" \
39
41
  "\e[1;1Hthis is the first" \
40
42
  "\e[2;1Hthis is the second and it is lon" \
41
- "\e[3;1Hthis is the third, it is even lo" \
43
+ "\e[3;1Hthis is the third, it is even lo"
42
44
  )
43
45
  end
44
46
 
@@ -91,55 +93,6 @@ module Vedeu
91
93
  "\e[3;1Hthis is the third, it is even lo"
92
94
  )
93
95
  end
94
-
95
- it 'returns to using the presentation attributes of the line after a ' \
96
- 'stream finishes' do
97
- Vedeu.interface 'oxygen' do
98
- width 40
99
- height 2
100
- end
101
-
102
- class OxygenView < Vedeu::View
103
- def render
104
- Vedeu.view 'oxygen' do
105
- line do
106
- colour background: '#000000', foreground: '#ffffff'
107
- stream do
108
- text 'the grass is '
109
- end
110
- stream do
111
- colour foreground: '#00ff00'
112
- text 'green'
113
- end
114
- stream do
115
- text ' and the sky is '
116
- end
117
- stream do
118
- colour foreground: '#0000ff'
119
- text 'blue'
120
- end
121
- stream do
122
- text '.'
123
- end
124
- end
125
- end
126
- end
127
- end
128
-
129
- IO.console.stub(:print, nil) do
130
- OxygenView.render
131
-
132
- Compositor.render('oxygen').must_equal(
133
- [
134
- "\e[1;1H \e[1;1H" \
135
- "\e[2;1H \e[2;1H" \
136
- "\e[1;1Ht\e[38;2;255;255;255m\e[48;2;0;0;0mh\e[38;2;255;255;255m\e[48;2;0;0;0me\e[38;2;255;255;255m\e[48;2;0;0;0m \e[38;2;255;255;255m\e[48;2;0;0;0mg\e[38;2;255;255;255m\e[48;2;0;0;0mr\e[38;2;255;255;255m\e[48;2;0;0;0ma\e[38;2;255;255;255m\e[48;2;0;0;0ms\e[38;2;255;255;255m\e[48;2;0;0;0ms\e[38;2;255;255;255m\e[48;2;0;0;0m \e[38;2;255;255;255m\e[48;2;0;0;0mi\e[38;2;255;255;255m\e[48;2;0;0;0ms\e[38;2;255;255;255m\e[48;2;0;0;0m \e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;255;0mg\e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;255;0mr\e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;255;0me\e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;255;0me\e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;255;0mn\e[38;2;255;255;255m\e[48;2;0;0;0m \e[38;2;255;255;255m\e[48;2;0;0;0ma\e[38;2;255;255;255m\e[48;2;0;0;0mn\e[38;2;255;255;255m\e[48;2;0;0;0md\e[38;2;255;255;255m\e[48;2;0;0;0m \e[38;2;255;255;255m\e[48;2;0;0;0mt\e[38;2;255;255;255m\e[48;2;0;0;0mh\e[38;2;255;255;255m\e[48;2;0;0;0me\e[38;2;255;255;255m\e[48;2;0;0;0m \e[38;2;255;255;255m\e[48;2;0;0;0ms\e[38;2;255;255;255m\e[48;2;0;0;0mk\e[38;2;255;255;255m\e[48;2;0;0;0my\e[38;2;255;255;255m\e[48;2;0;0;0m \e[38;2;255;255;255m\e[48;2;0;0;0mi\e[38;2;255;255;255m\e[48;2;0;0;0ms\e[38;2;255;255;255m\e[48;2;0;0;0m \e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;0;255mb\e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;0;255ml\e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;0;255mu\e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;0;255me\e[38;2;255;255;255m\e[48;2;0;0;0m.\e[38;2;255;255;255m\e[48;2;0;0;0m",
137
-
138
- "\e[1;1H\e[?25l"
139
- ]
140
- )
141
- end
142
- end
143
96
  end
144
97
 
145
98
  end # Render
@@ -32,56 +32,12 @@ module Vedeu
32
32
  end
33
33
  end
34
34
 
35
- describe '.back' do
36
- context 'when the buffer does not exist' do
37
- it 'raises an exception' do
38
- proc { Buffers.back('actinium') }.must_raise(BufferNotFound)
39
- end
40
- end
41
-
42
- context 'when the buffer exists' do
43
- before { Buffers.add({ name: 'mercury' }) }
44
-
45
- it 'returns a Hash' do
46
- Buffers.back('mercury').must_be_instance_of(Hash)
47
- end
48
-
49
- it 'returns the stored attributes' do
50
- Buffers.back('mercury').must_equal({ name: 'mercury' })
51
- end
52
- end
53
- end
54
-
55
- describe '.front' do
56
- context 'when the buffer does not exist' do
57
- it 'raises an exception' do
58
- proc { Buffers.front('mercury') }.must_raise(BufferNotFound)
59
- end
60
- end
61
-
62
- context 'when the buffer exists but there is no content' do
63
- before { Buffers.add({ name: 'actinium' }) }
35
+ describe '.update' do
36
+ let(:buffer) { Buffer.new({ name: 'einsteinium' }) }
64
37
 
65
- it 'returns a NilClass' do
66
- Buffers.front('actinium').must_be_instance_of(NilClass)
67
- end
68
- end
69
- end
38
+ subject { Buffers.update(buffer) }
70
39
 
71
- describe '.latest' do
72
- context 'when the buffer does not exist' do
73
- it 'raises an exception' do
74
- proc { Buffers.front('nobelium') }.must_raise(BufferNotFound)
75
- end
76
- end
77
-
78
- context 'when the buffer exists and there is content' do
79
- before { Buffers.add({ name: 'nobelium' }) }
80
-
81
- it 'returns the stored attributes' do
82
- Buffers.latest('nobelium').must_equal({ name: 'nobelium' })
83
- end
84
- end
40
+ it { subject.must_equal(true) }
85
41
  end
86
42
 
87
43
  end # Buffers
@@ -109,32 +109,6 @@ module Vedeu
109
109
  end
110
110
  end
111
111
 
112
- describe '#registered' do
113
- it 'returns all the names of the interfaces which can be focussed' do
114
- Focus.add({ name: 'thallium' })
115
- Focus.add({ name: 'lead' })
116
- Focus.add({ name: 'bismuth' })
117
-
118
- Focus.registered.must_equal(['thallium', 'lead', 'bismuth'])
119
- end
120
- end
121
-
122
- describe '.registered?' do
123
- it 'returns false when there are no interfaces registered' do
124
- Focus.registered?('thallium').must_equal(false)
125
- end
126
-
127
- it 'returns false when the named interface is not registered' do
128
- Focus.add({ name: 'thallium' })
129
- Focus.registered?('lead').must_equal(false)
130
- end
131
-
132
- it 'returns true if the named interface is registered' do
133
- Focus.add({ name: 'lead' })
134
- Focus.registered?('lead').must_equal(true)
135
- end
136
- end
137
-
138
112
  end # Focus
139
113
 
140
114
  end # Vedeu
@@ -6,14 +6,22 @@ module Vedeu
6
6
  class RepositoryTestClass
7
7
  include Repository
8
8
 
9
- def add(hash)
10
- @_storage = in_memory.merge!(hash)
9
+ def initialize(storage = {})
10
+ @storage = storage
11
11
  end
12
12
 
13
- def in_memory
14
- @_storage ||= {}
13
+ def add(entity)
14
+ if storage.is_a?(Hash)
15
+ @storage = in_memory.merge!(entity)
16
+
17
+ else
18
+ @storage << entity
19
+
20
+ end
15
21
  end
16
- alias_method :storage, :in_memory
22
+
23
+ attr_accessor :storage
24
+ alias_method :in_memory, :storage
17
25
 
18
26
  def not_found(name)
19
27
  fail EntityNotFound
@@ -68,8 +76,31 @@ module Vedeu
68
76
  RepositoryTestClass.new.registered.must_be_instance_of(Array)
69
77
  end
70
78
 
71
- it 'returns a collection of the names of all the registered entities' do
72
- RepositoryTestClass.new.registered.must_equal([])
79
+ context 'when the storage is a Hash' do
80
+ it 'returns a collection of the names of all the registered entities' do
81
+ repo = RepositoryTestClass.new
82
+ repo.add({ 'rutherfordium' => { name: 'rutherfordium' } })
83
+
84
+ repo.registered.must_equal(['rutherfordium'])
85
+ end
86
+ end
87
+
88
+ context 'when the storage is an Array' do
89
+ it 'returns the registered entities' do
90
+ repo = RepositoryTestClass.new([])
91
+ repo.add('rutherfordium')
92
+
93
+ repo.registered.must_equal(['rutherfordium'])
94
+ end
95
+ end
96
+
97
+ context 'when the storage is a Set' do
98
+ it 'returns the registered entities' do
99
+ repo = RepositoryTestClass.new(Set.new)
100
+ repo.add('rutherfordium')
101
+
102
+ repo.registered.must_equal(['rutherfordium'])
103
+ end
73
104
  end
74
105
 
75
106
  it 'returns an empty collection when the storage is empty' do
data/vedeu.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'vedeu'
7
- spec.version = '0.2.8'
7
+ spec.version = '0.2.9'
8
8
  spec.authors = ['Gavin Laking']
9
9
  spec.email = ['gavinlaking@gmail.com']
10
10
  spec.summary = %q{A terminal case of wonderland.}
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.2.8
4
+ version: 0.2.9
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-11-01 00:00:00.000000000 Z
11
+ date: 2014-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -207,6 +207,7 @@ files:
207
207
  - lib/vedeu/input/input.rb
208
208
  - lib/vedeu/launcher.rb
209
209
  - lib/vedeu/models/background.rb
210
+ - lib/vedeu/models/buffer.rb
210
211
  - lib/vedeu/models/char.rb
211
212
  - lib/vedeu/models/colour.rb
212
213
  - lib/vedeu/models/composition.rb
@@ -272,6 +273,7 @@ files:
272
273
  - test/lib/vedeu/input/input_test.rb
273
274
  - test/lib/vedeu/launcher_test.rb
274
275
  - test/lib/vedeu/models/background_test.rb
276
+ - test/lib/vedeu/models/buffer_test.rb
275
277
  - test/lib/vedeu/models/char_test.rb
276
278
  - test/lib/vedeu/models/colour_test.rb
277
279
  - test/lib/vedeu/models/composition_test.rb
@@ -365,6 +367,7 @@ test_files:
365
367
  - test/lib/vedeu/input/input_test.rb
366
368
  - test/lib/vedeu/launcher_test.rb
367
369
  - test/lib/vedeu/models/background_test.rb
370
+ - test/lib/vedeu/models/buffer_test.rb
368
371
  - test/lib/vedeu/models/char_test.rb
369
372
  - test/lib/vedeu/models/colour_test.rb
370
373
  - test/lib/vedeu/models/composition_test.rb