stockpile 1.1 → 2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.autotest +3 -22
- data/.minitest.rb +2 -2
- data/.rubocop.yml +212 -0
- data/.simplecov-prelude.rb +9 -0
- data/.travis.yml +6 -7
- data/.workenv +5 -0
- data/Code-of-Conduct.md +76 -0
- data/Gemfile +1 -1
- data/History.md +48 -0
- data/Licence.rdoc +1 -1
- data/Manifest.txt +5 -1
- data/README.rdoc +5 -6
- data/Rakefile +35 -27
- data/lib/stockpile.rb +4 -4
- data/lib/stockpile/base.rb +9 -7
- data/lib/stockpile/memory.rb +11 -8
- data/test/minitest_config.rb +2 -6
- data/test/test_stockpile.rb +37 -37
- data/test/test_stockpile_base.rb +46 -41
- metadata +28 -24
- data/History.rdoc +0 -24
data/test/test_stockpile_base.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'minitest_config'
|
2
3
|
|
3
4
|
describe Stockpile::Base do
|
@@ -20,19 +21,17 @@ describe Stockpile::Base do
|
|
20
21
|
}
|
21
22
|
|
22
23
|
describe 'constructor' do
|
23
|
-
it
|
24
|
+
it 'uses the default connection width by default' do
|
24
25
|
stub ::Stockpile, :narrow?, lambda { false } do
|
25
|
-
refute Stockpile::Base.new.narrow?,
|
26
|
-
"should be narrow, but is not"
|
26
|
+
refute Stockpile::Base.new.narrow?, 'should be narrow, but is not'
|
27
27
|
end
|
28
28
|
|
29
29
|
stub ::Stockpile, :narrow?, lambda { true } do
|
30
|
-
assert Stockpile::Base.new.narrow?,
|
31
|
-
"is not narrow, but should be"
|
30
|
+
assert Stockpile::Base.new.narrow?, 'is not narrow, but should be'
|
32
31
|
end
|
33
32
|
end
|
34
33
|
|
35
|
-
it
|
34
|
+
it 'can be told which connection width to use explicitly' do
|
36
35
|
stub ::Stockpile, :narrow?, lambda { false } do
|
37
36
|
assert mem_narrow.narrow?
|
38
37
|
end
|
@@ -42,7 +41,7 @@ describe Stockpile::Base do
|
|
42
41
|
end
|
43
42
|
end
|
44
43
|
|
45
|
-
it
|
44
|
+
it 'passes settings through to the client' do
|
46
45
|
options = {
|
47
46
|
url: 'test://xyz/'
|
48
47
|
}
|
@@ -50,54 +49,60 @@ describe Stockpile::Base do
|
|
50
49
|
assert_equal 'test://xyz/', mem.connect.options[:url]
|
51
50
|
end
|
52
51
|
|
53
|
-
it
|
52
|
+
it 'has no clients by default' do
|
54
53
|
assert_clients [], ::Stockpile::Memory.new
|
55
54
|
end
|
55
|
+
|
56
|
+
it 'works with an OpenStruct provided as options' do
|
57
|
+
require 'ostruct'
|
58
|
+
mem = ::Stockpile::Memory.new(OpenStruct.new(url: 'test://xyz/'))
|
59
|
+
assert_equal 'test://xyz/', mem.connect.options[:url]
|
60
|
+
end
|
56
61
|
end
|
57
62
|
|
58
|
-
describe
|
59
|
-
it
|
63
|
+
describe '#connect' do
|
64
|
+
it 'raises NotImplementedError unless #client_connect is implemented' do
|
60
65
|
assert_raises NotImplementedError do
|
61
66
|
::Stockpile::Base.new.connect
|
62
67
|
end
|
63
68
|
end
|
64
69
|
|
65
|
-
it
|
70
|
+
it 'creates a connection to the client' do
|
66
71
|
assert_nil mem.connection
|
67
72
|
refute_nil mem.connect
|
68
73
|
end
|
69
74
|
|
70
|
-
it
|
75
|
+
it 'creates a namespaced connection to the client' do
|
71
76
|
assert_nil mem_namespace.connection
|
72
77
|
refute_nil mem_namespace.connect
|
73
78
|
end
|
74
79
|
|
75
|
-
describe
|
80
|
+
describe 'with a wide connection width' do
|
76
81
|
before do
|
77
|
-
mem_wide.connect(:hoge,
|
82
|
+
mem_wide.connect(:hoge, quux: {})
|
78
83
|
end
|
79
84
|
|
80
|
-
it
|
85
|
+
it 'connects multiple clients' do
|
81
86
|
assert_clients [ :hoge, :quux ], mem_wide
|
82
87
|
end
|
83
88
|
|
84
|
-
it
|
89
|
+
it 'connects *different* clients' do
|
85
90
|
refute_same mem_wide.connection, mem_wide.connection_for(:hoge)
|
86
91
|
refute_same mem_wide.connection, mem_wide.connection_for(:quux)
|
87
92
|
refute_same mem_wide.connection_for(:hoge), mem_wide.connection_for(:quux)
|
88
93
|
end
|
89
94
|
end
|
90
95
|
|
91
|
-
describe
|
96
|
+
describe 'with a narrow connection width' do
|
92
97
|
before do
|
93
98
|
mem_narrow.connect(:hoge, :quux)
|
94
99
|
end
|
95
100
|
|
96
|
-
it
|
101
|
+
it 'appears to connect multiple clients' do
|
97
102
|
assert_clients [ :hoge, :quux ], mem_narrow
|
98
103
|
end
|
99
104
|
|
100
|
-
it
|
105
|
+
it 'returns identical clients' do
|
101
106
|
assert_same mem_narrow.connection, mem_narrow.connection_for(:hoge)
|
102
107
|
assert_same mem_narrow.connection, mem_narrow.connection_for(:quux)
|
103
108
|
assert_same mem_narrow.connection_for(:hoge), mem_narrow.connection_for(:quux)
|
@@ -105,8 +110,8 @@ describe Stockpile::Base do
|
|
105
110
|
end
|
106
111
|
end
|
107
112
|
|
108
|
-
describe
|
109
|
-
it
|
113
|
+
describe '#connection_for' do
|
114
|
+
it 'raises NotImplementedError unless #client_connect is implemented' do
|
110
115
|
assert_raises NotImplementedError do
|
111
116
|
instance_stub ::Stockpile::Base, :connection, -> { true } do
|
112
117
|
::Stockpile::Base.new.connection_for(:foo)
|
@@ -114,16 +119,16 @@ describe Stockpile::Base do
|
|
114
119
|
end
|
115
120
|
end
|
116
121
|
|
117
|
-
describe
|
118
|
-
it
|
122
|
+
describe 'with a wide connection width' do
|
123
|
+
it 'connects the main client' do
|
119
124
|
mem_wide.connection_for(:global)
|
120
125
|
assert mem_wide.connection
|
121
126
|
refute_same mem_wide.connection, mem_wide.connection_for(:global)
|
122
127
|
end
|
123
128
|
end
|
124
129
|
|
125
|
-
describe
|
126
|
-
it
|
130
|
+
describe 'with a narrow connection width' do
|
131
|
+
it 'connects the main client' do
|
127
132
|
mem_narrow.connection_for(:global)
|
128
133
|
assert mem_narrow.connection
|
129
134
|
assert_same mem_narrow.connection, mem_narrow.connection_for(:global)
|
@@ -133,8 +138,8 @@ describe Stockpile::Base do
|
|
133
138
|
|
134
139
|
let(:connection) { Stockpile::Memory::Data }
|
135
140
|
|
136
|
-
describe
|
137
|
-
it
|
141
|
+
describe '#disconnect' do
|
142
|
+
it 'raises NotImplementedError unless #client_disconnect is implemented' do
|
138
143
|
base = ::Stockpile::Base.new
|
139
144
|
assert_raises NotImplementedError do
|
140
145
|
instance_stub ::Stockpile::Base, :connect do
|
@@ -145,7 +150,7 @@ describe Stockpile::Base do
|
|
145
150
|
end
|
146
151
|
end
|
147
152
|
|
148
|
-
describe
|
153
|
+
describe 'with a wide connection width' do
|
149
154
|
let(:global) { mem_wide.connection }
|
150
155
|
let(:hoge) { mem_wide.connection_for(:hoge) }
|
151
156
|
|
@@ -154,18 +159,18 @@ describe Stockpile::Base do
|
|
154
159
|
assert hoge.connected? && global.connected?
|
155
160
|
end
|
156
161
|
|
157
|
-
it
|
162
|
+
it 'disconnects the global client' do
|
158
163
|
mem_wide.disconnect
|
159
164
|
assert hoge.connected? && !global.connected?
|
160
165
|
end
|
161
166
|
|
162
|
-
it
|
167
|
+
it 'disconnects the redis and global clients' do
|
163
168
|
mem_wide.disconnect(:hoge)
|
164
169
|
refute hoge.connected? || global.connected?
|
165
170
|
end
|
166
171
|
end
|
167
172
|
|
168
|
-
describe
|
173
|
+
describe 'with a narrow connection width' do
|
169
174
|
let(:global) { mem_narrow.connection }
|
170
175
|
let(:hoge) { mem_narrow.connection_for(:hoge) }
|
171
176
|
|
@@ -174,20 +179,20 @@ describe Stockpile::Base do
|
|
174
179
|
assert hoge.connected? && global.connected?
|
175
180
|
end
|
176
181
|
|
177
|
-
it
|
182
|
+
it '#disconnect disconnects all clients' do
|
178
183
|
mem_narrow.disconnect
|
179
184
|
refute hoge.connected? || global.connected?
|
180
185
|
end
|
181
186
|
|
182
|
-
it
|
187
|
+
it '#disconnect(:hoge) disconnects all clients' do
|
183
188
|
mem_narrow.disconnect(:hoge)
|
184
189
|
refute hoge.connected? || global.connected?
|
185
190
|
end
|
186
191
|
end
|
187
192
|
end
|
188
193
|
|
189
|
-
describe
|
190
|
-
it
|
194
|
+
describe '#reconnect' do
|
195
|
+
it 'raises NotImplementedError unless #client_reconnect is implemented' do
|
191
196
|
base = ::Stockpile::Base.new
|
192
197
|
assert_raises NotImplementedError do
|
193
198
|
instance_stub ::Stockpile::Base, :connect do
|
@@ -198,7 +203,7 @@ describe Stockpile::Base do
|
|
198
203
|
end
|
199
204
|
end
|
200
205
|
|
201
|
-
describe
|
206
|
+
describe 'with a wide connection width' do
|
202
207
|
let(:global) { mem_wide.connection }
|
203
208
|
let(:hoge) { mem_wide.connection_for(:hoge) }
|
204
209
|
|
@@ -209,18 +214,18 @@ describe Stockpile::Base do
|
|
209
214
|
refute hoge.connected? || global.connected?
|
210
215
|
end
|
211
216
|
|
212
|
-
it
|
217
|
+
it 'reconnects the global client' do
|
213
218
|
mem_wide.reconnect
|
214
219
|
assert !hoge.connected? && global.connected?
|
215
220
|
end
|
216
221
|
|
217
|
-
it
|
222
|
+
it 'reconnects the redis and global clients' do
|
218
223
|
mem_wide.reconnect(:hoge)
|
219
224
|
assert hoge.connected? && global.connected?
|
220
225
|
end
|
221
226
|
end
|
222
227
|
|
223
|
-
describe
|
228
|
+
describe 'with a narrow connection width' do
|
224
229
|
let(:global) { mem_narrow.connection }
|
225
230
|
let(:hoge) { mem_narrow.connection_for(:hoge) }
|
226
231
|
|
@@ -231,12 +236,12 @@ describe Stockpile::Base do
|
|
231
236
|
refute hoge.connected? || global.connected?
|
232
237
|
end
|
233
238
|
|
234
|
-
it
|
239
|
+
it '#reconnect reconnects the all clients' do
|
235
240
|
mem_narrow.reconnect
|
236
241
|
assert hoge.connected? && global.connected?
|
237
242
|
end
|
238
243
|
|
239
|
-
it
|
244
|
+
it '#reconnect(:hoge:) reconnects all clients' do
|
240
245
|
mem_narrow.reconnect(:hoge)
|
241
246
|
assert hoge.connected? && global.connected?
|
242
247
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stockpile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '
|
4
|
+
version: '2.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Austin Ziegler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '5.
|
19
|
+
version: '5.8'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '5.
|
26
|
+
version: '5.8'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rdoc
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,47 +95,47 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.2'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name: minitest-
|
98
|
+
name: minitest-autotest
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '0
|
103
|
+
version: '1.0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '0
|
110
|
+
version: '1.0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name: minitest-
|
112
|
+
name: minitest-bisect
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '1.
|
117
|
+
version: '1.2'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '1.
|
124
|
+
version: '1.2'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name: minitest-
|
126
|
+
name: minitest-bonus-assertions
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
131
|
+
version: '2.0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
138
|
+
version: '2.0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: minitest-focus
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -212,14 +212,14 @@ dependencies:
|
|
212
212
|
requirements:
|
213
213
|
- - "~>"
|
214
214
|
- !ruby/object:Gem::Version
|
215
|
-
version: '3.
|
215
|
+
version: '3.15'
|
216
216
|
type: :development
|
217
217
|
prerelease: false
|
218
218
|
version_requirements: !ruby/object:Gem::Requirement
|
219
219
|
requirements:
|
220
220
|
- - "~>"
|
221
221
|
- !ruby/object:Gem::Version
|
222
|
-
version: '3.
|
222
|
+
version: '3.15'
|
223
223
|
description: |-
|
224
224
|
Stockpile is a simple key-value store connection manager framework. Stockpile
|
225
225
|
itself does not implement a connection manager, but places expectations for
|
@@ -229,18 +229,18 @@ description: |-
|
|
229
229
|
Stockpile also provides an adapter so that its functionality can be accessed
|
230
230
|
from within a module.
|
231
231
|
|
232
|
-
Release
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
Stockpile#connection_for have been documented.
|
232
|
+
Release 2.0 fixes an issue when Stockpile options are provided with an
|
233
|
+
OpenStruct, originally reported as
|
234
|
+
{stockpile-redis#1}[https://github.com/halostatue/stockpile-redis/issues/1].
|
235
|
+
Support for Ruby 1.9 has been dropped.
|
237
236
|
email:
|
238
237
|
- halostatue@gmail.com
|
239
238
|
executables: []
|
240
239
|
extensions: []
|
241
240
|
extra_rdoc_files:
|
241
|
+
- Code-of-Conduct.md
|
242
242
|
- Contributing.rdoc
|
243
|
-
- History.
|
243
|
+
- History.md
|
244
244
|
- Licence.rdoc
|
245
245
|
- Manifest.txt
|
246
246
|
- README.rdoc
|
@@ -248,10 +248,14 @@ files:
|
|
248
248
|
- ".autotest"
|
249
249
|
- ".gemtest"
|
250
250
|
- ".minitest.rb"
|
251
|
+
- ".rubocop.yml"
|
252
|
+
- ".simplecov-prelude.rb"
|
251
253
|
- ".travis.yml"
|
254
|
+
- ".workenv"
|
255
|
+
- Code-of-Conduct.md
|
252
256
|
- Contributing.rdoc
|
253
257
|
- Gemfile
|
254
|
-
- History.
|
258
|
+
- History.md
|
255
259
|
- Licence.rdoc
|
256
260
|
- Manifest.txt
|
257
261
|
- README.rdoc
|
@@ -276,7 +280,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
276
280
|
requirements:
|
277
281
|
- - ">="
|
278
282
|
- !ruby/object:Gem::Version
|
279
|
-
version:
|
283
|
+
version: '2.0'
|
280
284
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
281
285
|
requirements:
|
282
286
|
- - ">="
|
@@ -284,7 +288,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
284
288
|
version: '0'
|
285
289
|
requirements: []
|
286
290
|
rubyforge_project:
|
287
|
-
rubygems_version: 2.
|
291
|
+
rubygems_version: 2.5.1
|
288
292
|
signing_key:
|
289
293
|
specification_version: 4
|
290
294
|
summary: Stockpile is a simple key-value store connection manager framework
|
data/History.rdoc
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
=== 1.1 / 2015-02-10
|
2
|
-
|
3
|
-
* 3 minor enhancements
|
4
|
-
|
5
|
-
* Created a base adapter, Stockpile::Base, that implements the core public
|
6
|
-
interface of a connection manager in a consistent way for argument parsing.
|
7
|
-
|
8
|
-
* Created a memory adapter as an example adapter. (This had previously been
|
9
|
-
a test adapter created in the test environment.)
|
10
|
-
|
11
|
-
* Documented changes to how clients can be specified for Stockpile.new,
|
12
|
-
Stockpile#connect, and Stockpile#connection_for.
|
13
|
-
|
14
|
-
* 1 bugfix
|
15
|
-
|
16
|
-
* Fix {issue #2}[https://github.com/halostatue/stockpile/issues/2], where
|
17
|
-
the use of the cache adapter causes the Stockpile cache manager to
|
18
|
-
initialize too early.
|
19
|
-
|
20
|
-
=== 1.0 / 2015-01-21
|
21
|
-
|
22
|
-
* 1 major enhancement
|
23
|
-
|
24
|
-
* Birthday!
|