vedeu 0.4.47 → 0.4.48

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: 32f9ff175fb990493d886e0e0b121b50d45e8829
4
- data.tar.gz: 78f1802b9c3c208a08947d4ea91a6c393f17214f
3
+ metadata.gz: c5ceca13f9b58a2952c6d8805faf464dabeb3610
4
+ data.tar.gz: e588afaa1dfde0bd1d6f2297880621f5399fdb0e
5
5
  SHA512:
6
- metadata.gz: 883b22230cf46167bb986ee49549dfe151ab43108f9d1bdd71fc77a2cc9de0fa9d819b9f6365dd059c443ab09ca3da01a43c01b6c5d21599e399f92073dd342f
7
- data.tar.gz: aefa345c4db2d5123ce8c54569f301a3e812cf3b3109ece81d47d86dcb857baf761450fe49a5ad7cd3a3561f4ed74e600a9be5ea61f4a640ba0ca8f5951574c0
6
+ metadata.gz: 45ef186c4d5da19d0d482a0ce89772f8de5e135dd974e6526370ffa13078b2d33ac905aec0abeaa863f930d62a96917613eb4fe1de3c63e9a6bf5c1550502293
7
+ data.tar.gz: e2c3aa1c381a0e4c9912f14bccbc66b2ec1242c53a9c20544bf3e894b6cb350e04bcdd786995f15382e195a565b5882ff61bb0bf7d36a33d26a72a086f8ffd51
@@ -8,7 +8,6 @@ require 'vedeu/traps'
8
8
 
9
9
  require 'vedeu/null/all'
10
10
  require 'vedeu/geometry/all'
11
- require 'vedeu/storage/all'
12
11
  require 'vedeu/repositories/all'
13
12
 
14
13
  require 'vedeu/api'
@@ -41,36 +41,18 @@ module Vedeu
41
41
  dn: attributes[:yn],
42
42
  d_dn: attributes[:y_yn],
43
43
  default: attributes[:y_default],
44
- options: attributes[:options])
44
+ maximised: attributes[:maximised],
45
+ centred: attributes[:centred])
45
46
  x_xn = Vedeu::Dimension.pair(d: attributes[:x],
46
47
  dn: attributes[:xn],
47
48
  d_dn: attributes[:x_xn],
48
49
  default: attributes[:x_default],
49
- options: attributes[:options])
50
+ maximised: attributes[:maximised],
51
+ centred: attributes[:centred])
50
52
 
51
- from_dimensions(y_yn: y_yn, x_xn: x_xn)
52
- end
53
-
54
- # @param y_yn [Array<Fixnum>]
55
- # @param x_xn [Array<Fixnum>]
56
- # @return [Vedeu::Area]
57
- def self.from_dimensions(y_yn:, x_xn:)
58
53
  new(y: y_yn.first, yn: y_yn.last, x: x_xn.first, xn: x_xn.last)
59
54
  end
60
55
 
61
- # @param height [Fixnum]
62
- # @param width [Fixnum]
63
- # @return [Vedeu::Area]
64
- def self.from_height_and_width(height:, width:)
65
- new(y: 1, yn: height, x: 1, xn: width)
66
- end
67
-
68
- # @param (see #initialize)
69
- # @return [Vedeu::Area]
70
- def self.from_points(y:, yn:, x:, xn:)
71
- new(y: y, yn: yn, x: x, xn: xn)
72
- end
73
-
74
56
  # Returns a new instance of Vedeu::Area.
75
57
  #
76
58
  # @param y [Fixnum]
@@ -59,9 +59,15 @@ module Vedeu
59
59
  # @return [Fixnum|NilClass]
60
60
  attr_reader :default
61
61
 
62
- # @!attribute [r] options
63
- # @return [Hash<Symbol => Boolean]
64
- attr_reader :options
62
+ # @!attribute [r] maximised
63
+ # @return [Boolean]
64
+ attr_reader :maximised
65
+ alias_method :maximised?, :maximised
66
+
67
+ # @!attribute [r] centred
68
+ # @return [Boolean]
69
+ attr_reader :centred
70
+ alias_method :centred?, :centred
65
71
 
66
72
  private
67
73
 
@@ -98,11 +104,6 @@ module Vedeu
98
104
  end
99
105
  end
100
106
 
101
- # @return [Boolean]
102
- def centred?
103
- options[:centred]
104
- end
105
-
106
107
  # @return [Fixnum]
107
108
  def centred_d
108
109
  (default / 2) - (length / 2)
@@ -135,24 +136,17 @@ module Vedeu
135
136
  end
136
137
  end
137
138
 
138
- # @return [Boolean]
139
- def maximised?
140
- options[:maximised]
141
- end
142
-
143
139
  # Returns the default options/attributes for this class.
144
140
  #
145
141
  # @return [Hash<Symbol => NilClass,Boolean>]
146
142
  def defaults
147
143
  {
148
- d: nil,
149
- dn: nil,
150
- d_dn: nil,
151
- default: nil,
152
- options: {
153
- centred: false,
154
- maximised: false,
155
- },
144
+ d: nil,
145
+ dn: nil,
146
+ d_dn: nil,
147
+ default: nil,
148
+ centred: false,
149
+ maximised: false,
156
150
  }
157
151
  end
158
152
 
@@ -162,16 +162,9 @@ module Vedeu
162
162
  xn: _xn,
163
163
  x_xn: @width,
164
164
  x_default: Vedeu.width,
165
- options: dimension_options,
166
- )
167
- end
168
-
169
- # @return [Hash<Symbol => Boolean>]
170
- def dimension_options
171
- {
172
165
  centred: centred,
173
166
  maximised: maximised,
174
- }
167
+ )
175
168
  end
176
169
 
177
170
  # Returns the row/line start position for the interface.
@@ -108,7 +108,7 @@ module Vedeu
108
108
  def render
109
109
  return [] unless visible?
110
110
 
111
- Vedeu.trigger(:_cursor_hide_, name)
111
+ Vedeu.trigger(:_hide_cursor_, name)
112
112
 
113
113
  output = [
114
114
  Vedeu::Clear::NamedInterface.render(name),
@@ -116,7 +116,7 @@ module Vedeu
116
116
  Vedeu::Viewport.render(self),
117
117
  ]
118
118
 
119
- Vedeu.trigger(:_cursor_show_, name)
119
+ Vedeu.trigger(:_show_cursor_, name)
120
120
 
121
121
  output
122
122
  end
@@ -63,17 +63,8 @@ module Vedeu
63
63
 
64
64
  # @return [Vedeu::Area]
65
65
  def area
66
- @area ||= Vedeu::Area.from_dimensions(y_yn: y_yn, x_xn: x_xn)
67
- end
68
-
69
- # @return [Array<Fixnum>]
70
- def x_xn
71
- @x_xn ||= Vedeu::Dimension.pair(default: Vedeu.width)
72
- end
73
-
74
- # @return [Array<Fixnum>]
75
- def y_yn
76
- @y_yn ||= Vedeu::Dimension.pair(default: Vedeu.height)
66
+ @area ||= Vedeu::Area.from_attributes(y_default: Vedeu.height,
67
+ x_default: Vedeu.width)
77
68
  end
78
69
 
79
70
  end # Geometry
@@ -34,9 +34,11 @@ module Vedeu
34
34
 
35
35
  end # Vedeu
36
36
 
37
+ require_relative 'store'
37
38
  require_relative 'registerable'
38
39
  require_relative 'collection'
39
40
  require_relative 'collections/all'
40
41
  require_relative 'model'
41
42
  require_relative 'repositories/all'
42
43
  require_relative 'repository'
44
+
@@ -1,6 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # The current version of Vedeu.
4
- VERSION = '0.4.47'
4
+ VERSION = '0.4.48'
5
5
 
6
6
  end
@@ -31,40 +31,35 @@ module Vedeu
31
31
  it { instance.instance_variable_get('@xn').must_equal(xn) }
32
32
  end
33
33
 
34
- describe '.from_dimensions' do
35
- let(:y_yn) { [5, 8] }
36
- let(:x_xn) { [15, 25] }
37
-
38
- subject { described.from_dimensions(y_yn: y_yn, x_xn: x_xn) }
39
-
40
- it { subject.must_be_instance_of(described) }
41
- it { subject.instance_variable_get('@y').must_equal(5) }
42
- it { subject.instance_variable_get('@yn').must_equal(8) }
43
- it { subject.instance_variable_get('@x').must_equal(15) }
44
- it { subject.instance_variable_get('@xn').must_equal(25) }
45
- end
46
-
47
- describe '.from_height_and_width' do
48
- let(:height) { 5 }
49
- let(:width) { 15 }
50
-
51
- subject { described.from_height_and_width(height: height, width: width) }
52
-
53
- it { subject.must_be_instance_of(described) }
54
- it { subject.instance_variable_get('@y').must_equal(1) }
55
- it { subject.instance_variable_get('@yn').must_equal(5) }
56
- it { subject.instance_variable_get('@x').must_equal(1) }
57
- it { subject.instance_variable_get('@xn').must_equal(15) }
58
- end
59
-
60
- describe '.from_points' do
61
- subject { described.from_points(y: y, yn: yn, x: x, xn: xn) }
34
+ describe '.from_attributes' do
35
+ let(:attributes) {
36
+ {
37
+ y: y,
38
+ yn: yn,
39
+ y_yn: y_yn,
40
+ y_default: y_default,
41
+ x: x,
42
+ xn: xn,
43
+ x_xn: x_xn,
44
+ x_default: x_default,
45
+ maximised: maximised,
46
+ centred: centred,
47
+ }
48
+ }
49
+ let(:y) {}
50
+ let(:yn) {}
51
+ let(:y_yn) {}
52
+ let(:y_default) {}
53
+ let(:x) {}
54
+ let(:xn) {}
55
+ let(:x_xn) {}
56
+ let(:x_default) {}
57
+ let(:maximised) {}
58
+ let(:centred) {}
59
+
60
+ subject { described.from_attributes(attributes) }
62
61
 
63
62
  it { subject.must_be_instance_of(described) }
64
- it { subject.instance_variable_get('@y').must_equal(y) }
65
- it { subject.instance_variable_get('@yn').must_equal(yn) }
66
- it { subject.instance_variable_get('@x').must_equal(x) }
67
- it { subject.instance_variable_get('@xn').must_equal(xn) }
68
63
  end
69
64
 
70
65
  describe '#eql?' do
@@ -8,18 +8,20 @@ module Vedeu
8
8
  let(:instance) { described.new(attributes) }
9
9
  let(:attributes) {
10
10
  {
11
- d: d,
12
- dn: dn,
13
- d_dn: d_dn,
14
- default: default,
15
- options: options,
11
+ d: d,
12
+ dn: dn,
13
+ d_dn: d_dn,
14
+ default: default,
15
+ maximised: maximised,
16
+ centred: centred,
16
17
  }
17
18
  }
18
- let(:d) {}
19
- let(:dn) {}
20
- let(:d_dn) {}
21
- let(:default) {}
22
- let(:options) { {} }
19
+ let(:d) {}
20
+ let(:dn) {}
21
+ let(:d_dn) {}
22
+ let(:default) {}
23
+ let(:maximised) {}
24
+ let(:centred) {}
23
25
 
24
26
  describe '#initialize' do
25
27
  it { instance.must_be_instance_of(described) }
@@ -27,7 +29,8 @@ module Vedeu
27
29
  it { instance.instance_variable_get('@dn').must_equal(dn) }
28
30
  it { instance.instance_variable_get('@d_dn').must_equal(d_dn) }
29
31
  it { instance.instance_variable_get('@default').must_equal(default) }
30
- it { instance.instance_variable_get('@options').must_equal(options) }
32
+ it { instance.instance_variable_get('@maximised').must_equal(maximised) }
33
+ it { instance.instance_variable_get('@centred').must_equal(centred) }
31
34
  end
32
35
 
33
36
  describe '.pair' do
@@ -40,14 +43,14 @@ module Vedeu
40
43
  it { subject.must_equal([15, 38]) }
41
44
 
42
45
  context 'when maximised' do
43
- let(:options) { { maximised: true } }
44
- let(:default) { 80 }
46
+ let(:maximised) { true }
47
+ let(:default) { 80 }
45
48
 
46
49
  it { subject.must_equal([1, 80]) }
47
50
  end
48
51
 
49
52
  context 'when centred and a length can be determined' do
50
- let(:options) { { centred: true } }
53
+ let(:centred) { true }
51
54
  let(:default) { 80 }
52
55
 
53
56
  context 'when d and dn are given' do
@@ -87,7 +90,7 @@ module Vedeu
87
90
  end
88
91
 
89
92
  context 'when centred and a length can be determined' do
90
- let(:options) { { centred: true } }
93
+ let(:centred) { true }
91
94
  let(:default) { 80 }
92
95
 
93
96
  context 'when d and dn are given' do
@@ -158,7 +161,7 @@ module Vedeu
158
161
  end
159
162
 
160
163
  context 'when centred and a length can be determined' do
161
- let(:options) { { centred: true } }
164
+ let(:centred) { true }
162
165
  let(:default) { 80 }
163
166
 
164
167
  context 'when d and dn are given' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vedeu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.47
4
+ version: 0.4.48
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
@@ -406,7 +406,6 @@ files:
406
406
  - lib/vedeu/models/interface.rb
407
407
  - lib/vedeu/models/line.rb
408
408
  - lib/vedeu/models/menu.rb
409
- - lib/vedeu/models/panel.rb
410
409
  - lib/vedeu/models/stream.rb
411
410
  - lib/vedeu/null/all.rb
412
411
  - lib/vedeu/null/border.rb
@@ -466,11 +465,7 @@ files:
466
465
  - lib/vedeu/repositories/repositories/keymaps.rb
467
466
  - lib/vedeu/repositories/repositories/menus.rb
468
467
  - lib/vedeu/repositories/repository.rb
469
- - lib/vedeu/storage/all.rb
470
- - lib/vedeu/storage/associative_store.rb
471
- - lib/vedeu/storage/conveyor_store.rb
472
- - lib/vedeu/storage/fifo_store.rb
473
- - lib/vedeu/storage/store.rb
468
+ - lib/vedeu/repositories/store.rb
474
469
  - lib/vedeu/support/all.rb
475
470
  - lib/vedeu/support/common.rb
476
471
  - lib/vedeu/support/log.rb
@@ -609,10 +604,7 @@ files:
609
604
  - test/lib/vedeu/repositories/repositories/keymaps_test.rb
610
605
  - test/lib/vedeu/repositories/repositories/menus_test.rb
611
606
  - test/lib/vedeu/repositories/repository_test.rb
612
- - test/lib/vedeu/storage/associative_store_test.rb
613
- - test/lib/vedeu/storage/conveyor_store_test.rb
614
- - test/lib/vedeu/storage/fifo_store_test.rb
615
- - test/lib/vedeu/storage/store_test.rb
607
+ - test/lib/vedeu/repositories/store_test.rb
616
608
  - test/lib/vedeu/support/common_test.rb
617
609
  - test/lib/vedeu/support/log_test.rb
618
610
  - test/lib/vedeu/support/options_test.rb
@@ -780,10 +772,7 @@ test_files:
780
772
  - test/lib/vedeu/repositories/repositories/keymaps_test.rb
781
773
  - test/lib/vedeu/repositories/repositories/menus_test.rb
782
774
  - test/lib/vedeu/repositories/repository_test.rb
783
- - test/lib/vedeu/storage/associative_store_test.rb
784
- - test/lib/vedeu/storage/conveyor_store_test.rb
785
- - test/lib/vedeu/storage/fifo_store_test.rb
786
- - test/lib/vedeu/storage/store_test.rb
775
+ - test/lib/vedeu/repositories/store_test.rb
787
776
  - test/lib/vedeu/support/common_test.rb
788
777
  - test/lib/vedeu/support/log_test.rb
789
778
  - test/lib/vedeu/support/options_test.rb
@@ -1,23 +0,0 @@
1
- module Vedeu
2
-
3
- # Abstract interface class without the baggage.
4
- #
5
- # @api private
6
- class Panel
7
-
8
- # Returns a new instance of Vedeu::Panel.
9
- #
10
- # @return [Vedeu::Panel]
11
- def initialize
12
- end
13
-
14
- private
15
-
16
- # @return [Vedeu::Area]
17
- def area
18
- @area = Vedeu::Area.from_dimensions(y_yn: y_yn, x_xn: x_xn)
19
- end
20
-
21
- end # Panel
22
-
23
- end # Vedeu
@@ -1,5 +0,0 @@
1
- require_relative 'store'
2
-
3
- require_relative 'associative_store'
4
- require_relative 'conveyor_store'
5
- require_relative 'fifo_store'
@@ -1,50 +0,0 @@
1
- module Vedeu
2
-
3
- # Name/Value storage.
4
- #
5
- # name: [value]
6
- #
7
- # @api private
8
- class AssociativeStore
9
-
10
- include Vedeu::Store
11
-
12
- # Returns a new instance of Vedeu::AssociativeStore.
13
- #
14
- # @param storage [Hash]
15
- # @return [Vedeu::AssociativeStore]
16
- def initialize(storage = {})
17
- @storage = storage
18
- end
19
-
20
- # @param name [String]
21
- def load(name)
22
- return nil if empty?
23
-
24
- storage[name]
25
- end
26
-
27
- # @param data [Object]
28
- # @param name [String|Symbol]
29
- def save(data, name = nil)
30
- if name
31
- storage[name] = data
32
-
33
- elsif data.respond_to?(:name)
34
- storage[data.name] = data
35
-
36
- end
37
-
38
- storage
39
- end
40
-
41
- private
42
-
43
- # @return [Hash]
44
- def in_memory
45
- {}
46
- end
47
-
48
- end # AssociativeStore
49
-
50
- end # Vedeu
@@ -1,72 +0,0 @@
1
- module Vedeu
2
-
3
- # Conveyor belt like storage. The belt can move forward (`load_next`) or
4
- # backwards (`load_previous`), or a named entry can be retrieved.
5
- #
6
- # @api private
7
- class ConveyorStore
8
-
9
- include Vedeu::Store
10
-
11
- # Returns a new instance of Vedeu::ConveyorStore.
12
- #
13
- # @param storage [Array]
14
- # @return [Vedeu::ConveyorStore]
15
- def initialize(storage = [])
16
- @storage = storage
17
- end
18
-
19
- # @return [Object]
20
- def load
21
- storage.first
22
- end
23
- alias_method :current, :load
24
-
25
- # @param name [String]
26
- # @return [Object]
27
- def load_named(name)
28
- return nil if empty?
29
-
30
- return nil unless storage.include?(name)
31
-
32
- storage.rotate!(storage.index(name))
33
-
34
- load
35
- end
36
-
37
- # @return [Object]
38
- def load_next
39
- storage.rotate!
40
-
41
- load
42
- end
43
-
44
- # @return [Object]
45
- def load_previous
46
- storage.rotate!(-1)
47
-
48
- load
49
- end
50
-
51
- # @param data [Object]
52
- # @param front [Boolean]
53
- def save(data, front = false)
54
- if front
55
- storage.push(data)
56
-
57
- else
58
- storage.unshift(data)
59
-
60
- end
61
- end
62
-
63
- private
64
-
65
- # @return [Array]
66
- def in_memory
67
- []
68
- end
69
-
70
- end # ConveyorStore
71
-
72
- end # Vedeu
@@ -1,40 +0,0 @@
1
- module Vedeu
2
-
3
- # First-in first-out storage.
4
- #
5
- # in -> [3] -> [2] -> [1] -> out
6
- #
7
- # @api private
8
- class FifoStore
9
-
10
- include Vedeu::Store
11
-
12
- # Returns a new instance of Vedeu::FifoStore.
13
- #
14
- # @param storage [Array]
15
- # @return [Vedeu::FifoStore]
16
- def initialize(storage = [])
17
- @storage = storage
18
- end
19
-
20
- # @return [Object]
21
- def load
22
- storage.pop
23
- end
24
-
25
- # @param data [Object]
26
- # @return [Array<Object>]
27
- def save(data)
28
- storage.unshift(data)
29
- end
30
-
31
- private
32
-
33
- # @return [Array]
34
- def in_memory
35
- []
36
- end
37
-
38
- end # FifoStore
39
-
40
- end # Vedeu
@@ -1,76 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe AssociativeStore do
6
-
7
- let(:described) { Vedeu::AssociativeStore }
8
- let(:instance) { described.new(storage) }
9
- let(:storage) { {} }
10
-
11
- describe '#initialize' do
12
- it { instance.must_be_instance_of(described) }
13
- it { instance.instance_variable_get('@storage').must_equal(storage) }
14
- end
15
-
16
- describe '#load' do
17
- let(:_name) {}
18
-
19
- subject { instance.load(_name) }
20
-
21
- context 'when the storage is empty' do
22
- it { subject.must_equal(nil) }
23
- end
24
-
25
- context 'when the storage is not empty' do
26
- let(:storage) { { hydrogen: '1', helium: '2' } }
27
-
28
- context 'when the named entry exists' do
29
- let(:_name) { :helium }
30
-
31
- it { subject.must_equal('2') }
32
- end
33
-
34
- context 'when the named entry does not exist' do
35
- let(:_name) { :beryllium }
36
-
37
- it { subject.must_equal(nil) }
38
- end
39
- end
40
- end
41
-
42
- describe '#reset' do
43
- subject { instance.reset }
44
-
45
- it { subject.must_be_instance_of(Hash) }
46
- it { subject.must_equal({}) }
47
- end
48
-
49
- describe '#save' do
50
- let(:data) { [:some_data] }
51
- let(:_name) {}
52
-
53
- subject { instance.save(data, _name) }
54
-
55
- context 'when a name is given' do
56
- let(:_name) { :hydrogen }
57
-
58
- it { subject.must_equal(hydrogen: [:some_data]) }
59
- end
60
-
61
- context 'when a name is not given' do
62
- context 'when the data respond to name' do
63
- let(:data) { ModelTestClass.new(name: 'helium')}
64
-
65
- it { subject.key?('helium').must_equal(true) }
66
- end
67
-
68
- context 'when the data does not respond to name' do
69
- it { subject.must_equal({}) }
70
- end
71
- end
72
- end
73
-
74
- end # AssociativeStore
75
-
76
- end # Vedeu
@@ -1,140 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe ConveyorStore do
6
-
7
- let(:described) { Vedeu::ConveyorStore }
8
- let(:instance) { described.new(storage) }
9
- let(:storage) { [] }
10
-
11
- describe '#initialize' do
12
- it { instance.must_be_instance_of(described) }
13
- it { instance.instance_variable_get('@storage').must_equal(storage) }
14
- end
15
-
16
- describe '#load' do
17
- subject { instance.load }
18
-
19
- it { instance.must_respond_to(:current) }
20
-
21
- context 'when the storage is empty' do
22
- it { subject.must_equal(nil) }
23
- end
24
-
25
- context 'when the storage is not empty' do
26
- let(:storage) { [:hydrogen] }
27
-
28
- it { subject.must_equal(:hydrogen) }
29
- end
30
- end
31
-
32
- describe '#load_named' do
33
- let(:_name) {}
34
-
35
- subject { instance.load_named(_name) }
36
-
37
- context 'when the storage is empty' do
38
- it { subject.must_equal(nil) }
39
- end
40
-
41
- context 'when the storage is not empty' do
42
- let(:storage) { [:lithium, :helium, :hydrogen] }
43
-
44
- context 'when the named entry exists' do
45
- let(:_name) { :helium }
46
-
47
- it { subject.must_equal(:helium) }
48
-
49
- it 'rotates the store to the named entry' do
50
- instance.storage.must_equal([:lithium, :helium, :hydrogen])
51
- subject
52
- instance.storage.must_equal([:helium, :hydrogen, :lithium])
53
- end
54
- end
55
-
56
- context 'when the named entry does not exist' do
57
- let(:_name) { :beryllium }
58
-
59
- it { subject.must_equal(nil) }
60
- end
61
- end
62
- end
63
-
64
- describe '#load_next' do
65
- subject { instance.load_next }
66
-
67
- context 'when the storage is empty' do
68
- it { subject.must_equal(nil) }
69
- end
70
-
71
- context 'when the storage is not empty' do
72
- let(:storage) { [:lithium, :helium, :hydrogen] }
73
-
74
- it { subject.must_equal(:helium) }
75
-
76
- it 'rotates the store' do
77
- instance.storage.must_equal([:lithium, :helium, :hydrogen])
78
- instance.load_next
79
- instance.load_next
80
- instance.storage.must_equal([:hydrogen, :lithium, :helium])
81
- end
82
- end
83
- end
84
-
85
- describe '#load_previous' do
86
- subject { instance.load_previous }
87
-
88
- context 'when the storage is empty' do
89
- it { subject.must_equal(nil) }
90
- end
91
-
92
- context 'when the storage is not empty' do
93
- let(:storage) { [:lithium, :helium, :hydrogen] }
94
-
95
- it { subject.must_equal(:hydrogen) }
96
-
97
- it 'rotates the store' do
98
- instance.storage.must_equal([:lithium, :helium, :hydrogen])
99
- instance.load_previous
100
- instance.load_previous
101
- instance.storage.must_equal([:helium, :hydrogen, :lithium])
102
- end
103
- end
104
- end
105
-
106
- describe '#reset' do
107
- subject { instance.reset }
108
-
109
- it { subject.must_be_instance_of(Array) }
110
- it { subject.must_equal([]) }
111
- end
112
-
113
- describe '#save' do
114
- let(:data) { :beryllium }
115
- let(:front) { false }
116
-
117
- subject { instance.save(data, front) }
118
-
119
- context 'when the storage is empty' do
120
- it { subject.must_equal([:beryllium]) }
121
- end
122
-
123
- context 'when the storage is not empty' do
124
- let(:storage) { [:lithium, :helium, :hydrogen] }
125
-
126
- context 'and `front` is false' do
127
- it { subject.must_equal([:beryllium, :lithium, :helium, :hydrogen]) }
128
- end
129
-
130
- context 'and `front` is true' do
131
- let(:front) { true }
132
-
133
- it { subject.must_equal([:lithium, :helium, :hydrogen, :beryllium]) }
134
- end
135
- end
136
- end
137
-
138
- end # ConveyorStore
139
-
140
- end # Vedeu
@@ -1,54 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe FifoStore do
6
-
7
- let(:described) { Vedeu::FifoStore }
8
- let(:instance) { described.new(storage) }
9
- let(:storage) { [] }
10
-
11
- describe '#initialize' do
12
- it { instance.must_be_instance_of(described) }
13
- it { instance.instance_variable_get('@storage').must_equal(storage) }
14
- end
15
-
16
- describe '#load' do
17
- subject { instance.load }
18
-
19
- context 'when the storage is empty' do
20
- it { subject.must_equal(nil) }
21
- end
22
-
23
- context 'when the storage is not empty' do
24
- let(:storage) { [:lithium, :helium, :hydrogen] }
25
-
26
- it { subject.must_equal(:hydrogen) }
27
-
28
- it 'removes the item from storage on retrieval' do
29
- instance.size.must_equal(3)
30
- subject
31
- instance.size.must_equal(2)
32
- end
33
- end
34
- end
35
-
36
- describe '#reset' do
37
- subject { instance.reset }
38
-
39
- it { subject.must_be_instance_of(Array) }
40
- it { subject.must_equal([]) }
41
- end
42
-
43
- describe '#save' do
44
- let(:data) { :beryllium }
45
- let(:storage) { [:lithium, :helium, :hydrogen] }
46
-
47
- subject { instance.save(data) }
48
-
49
- it { subject.must_equal([:beryllium, :lithium, :helium, :hydrogen]) }
50
- end
51
-
52
- end # FifoStore
53
-
54
- end # Vedeu