moneta 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +21 -11
- data/CHANGES +4 -0
- data/Gemfile +19 -6
- data/lib/moneta/adapters/file.rb +1 -1
- data/lib/moneta/version.rb +1 -1
- data/spec/features/null.rb +28 -28
- data/spec/features/persist.rb +3 -3
- data/spec/features/returndifferent.rb +4 -4
- data/spec/features/returnsame.rb +4 -4
- data/spec/features/store.rb +104 -104
- data/spec/helper.rb +1 -3
- data/spec/moneta/adapters/cassandra/adapter_cassandra_spec.rb +1 -1
- data/spec/moneta/adapters/cassandra/adapter_cassandra_with_default_expires_spec.rb +1 -1
- data/spec/moneta/adapters/cassandra/standard_cassandra_spec.rb +1 -1
- data/spec/moneta/adapters/datamapper/adapter_datamapper_spec.rb +1 -1
- data/spec/moneta/adapters/datamapper/standard_datamapper_spec.rb +1 -1
- data/spec/moneta/adapters/datamapper/standard_datamapper_with_expires_spec.rb +1 -1
- data/spec/moneta/adapters/datamapper/standard_datamapper_with_repository_spec.rb +1 -1
- data/spec/moneta/proxies/enumerable/enumerable_spec.rb +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 057afad07820c6a0099c1c8f0d08e8a8db0d8f163ae699a6c492b5114e7690da
|
4
|
+
data.tar.gz: 277352fb763982da85855f170234cf6a2660afeb3b90f6bf34df6dccda586291
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0266a4e3016c53408a92a5929152f088ff26c0981561e279e0812726a085e65a6ea90305d362ca04383ee0225915bd470f687c97d9eeafeff960ca21de716616
|
7
|
+
data.tar.gz: 95f6df87a40afeeff7d0c490c88f9c9950a12949358df57da9014cff3ffba1e7893ca43cdfb1d90c20750050d6bc0617e76655a025bff58caa1c89567256a894
|
data/.github/workflows/ruby.yml
CHANGED
@@ -9,12 +9,13 @@ on:
|
|
9
9
|
jobs:
|
10
10
|
adapters:
|
11
11
|
runs-on: ubuntu-latest
|
12
|
+
continue-on-error: ${{ matrix.ruby-version == '3.0' }}
|
12
13
|
|
13
14
|
strategy:
|
14
15
|
fail-fast: false
|
15
16
|
|
16
17
|
matrix:
|
17
|
-
ruby-version: [2.7, 2.6, 2.5, 2.4, jruby]
|
18
|
+
ruby-version: ['3.0', '2.7', '2.6', '2.5', '2.4', jruby]
|
18
19
|
adapter:
|
19
20
|
- Client
|
20
21
|
- Cookie
|
@@ -66,6 +67,7 @@ jobs:
|
|
66
67
|
couch:
|
67
68
|
name: "Couch adapter"
|
68
69
|
runs-on: ubuntu-latest
|
70
|
+
continue-on-error: ${{ matrix.ruby-version == '3.0' }}
|
69
71
|
|
70
72
|
services:
|
71
73
|
couch:
|
@@ -83,7 +85,7 @@ jobs:
|
|
83
85
|
|
84
86
|
strategy:
|
85
87
|
matrix:
|
86
|
-
ruby-version: [2.7, 2.4, jruby]
|
88
|
+
ruby-version: ['3.0', '2.7', '2.4', jruby]
|
87
89
|
|
88
90
|
env:
|
89
91
|
BUNDLE_WITH: RestClient
|
@@ -118,7 +120,7 @@ jobs:
|
|
118
120
|
|
119
121
|
strategy:
|
120
122
|
matrix:
|
121
|
-
ruby-version: [2.7, 2.4, jruby]
|
123
|
+
ruby-version: ['2.7', '2.4', jruby]
|
122
124
|
|
123
125
|
env:
|
124
126
|
BUNDLE_WITH: Cassandra
|
@@ -139,6 +141,7 @@ jobs:
|
|
139
141
|
mysql-adapters:
|
140
142
|
name: "MySQL adapters"
|
141
143
|
runs-on: ubuntu-latest
|
144
|
+
continue-on-error: ${{ matrix.ruby-version == '3.0' }}
|
142
145
|
|
143
146
|
services:
|
144
147
|
mysql:
|
@@ -155,7 +158,7 @@ jobs:
|
|
155
158
|
|
156
159
|
strategy:
|
157
160
|
matrix:
|
158
|
-
ruby-version: [2.7, 2.4, jruby]
|
161
|
+
ruby-version: ['3.0', '2.7', '2.4', jruby]
|
159
162
|
|
160
163
|
env:
|
161
164
|
BUNDLE_WITH: ActiveRecord Sequel DataMapper mysql
|
@@ -194,6 +197,7 @@ jobs:
|
|
194
197
|
postgres-adapters:
|
195
198
|
name: "Postgres adapters"
|
196
199
|
runs-on: ubuntu-latest
|
200
|
+
continue-on-error: ${{ matrix.ruby-version == '3.0' }}
|
197
201
|
|
198
202
|
services:
|
199
203
|
postgres:
|
@@ -210,7 +214,7 @@ jobs:
|
|
210
214
|
|
211
215
|
strategy:
|
212
216
|
matrix:
|
213
|
-
ruby-version: [2.7, 2.4, jruby]
|
217
|
+
ruby-version: ['3.0', '2.7', '2.4', jruby]
|
214
218
|
|
215
219
|
env:
|
216
220
|
BUNDLE_WITH: ActiveRecord Sequel DataMapper postgresql
|
@@ -243,10 +247,11 @@ jobs:
|
|
243
247
|
sqlite-adapters:
|
244
248
|
name: "SQLite adapters"
|
245
249
|
runs-on: ubuntu-latest
|
250
|
+
continue-on-error: ${{ matrix.ruby-version == '3.0' }}
|
246
251
|
|
247
252
|
strategy:
|
248
253
|
matrix:
|
249
|
-
ruby-version: [2.7, 2.4, jruby]
|
254
|
+
ruby-version: ['3.0', '2.7', '2.4', jruby]
|
250
255
|
|
251
256
|
env:
|
252
257
|
BUNDLE_WITH: ActiveRecord Sequel DataMapper sqlite
|
@@ -267,6 +272,7 @@ jobs:
|
|
267
272
|
redis:
|
268
273
|
name: "Redis adapters"
|
269
274
|
runs-on: ubuntu-latest
|
275
|
+
continue-on-error: ${{ matrix.ruby-version == '3.0' }}
|
270
276
|
|
271
277
|
services:
|
272
278
|
redis:
|
@@ -281,7 +287,7 @@ jobs:
|
|
281
287
|
|
282
288
|
strategy:
|
283
289
|
matrix:
|
284
|
-
ruby-version: [2.7, 2.4, jruby]
|
290
|
+
ruby-version: ['3.0', '2.7', '2.4', jruby]
|
285
291
|
|
286
292
|
env:
|
287
293
|
BUNDLE_WITH: Redis
|
@@ -302,10 +308,11 @@ jobs:
|
|
302
308
|
memcached:
|
303
309
|
name: "Memcached adapters"
|
304
310
|
runs-on: ubuntu-latest
|
311
|
+
continue-on-error: ${{ matrix.ruby-version == '3.0' }}
|
305
312
|
|
306
313
|
strategy:
|
307
314
|
matrix:
|
308
|
-
ruby-version: [2.7, 2.4, jruby]
|
315
|
+
ruby-version: ['3.0', '2.7', '2.4', jruby]
|
309
316
|
|
310
317
|
env:
|
311
318
|
BUNDLE_WITH: Memcached
|
@@ -332,6 +339,7 @@ jobs:
|
|
332
339
|
mongo:
|
333
340
|
name: "Mongo adapter"
|
334
341
|
runs-on: ubuntu-latest
|
342
|
+
continue-on-error: ${{ matrix.ruby-version == '3.0' }}
|
335
343
|
|
336
344
|
services:
|
337
345
|
mongo:
|
@@ -346,7 +354,7 @@ jobs:
|
|
346
354
|
|
347
355
|
strategy:
|
348
356
|
matrix:
|
349
|
-
ruby-version: [2.7, 2.4
|
357
|
+
ruby-version: ['3.0', '2.7', '2.4', jruby]
|
350
358
|
|
351
359
|
env:
|
352
360
|
BUNDLE_WITH: Mongo
|
@@ -367,10 +375,11 @@ jobs:
|
|
367
375
|
residual-specs:
|
368
376
|
name: "Proxies and other specs"
|
369
377
|
runs-on: ubuntu-latest
|
378
|
+
continue-on-error: ${{ matrix.ruby-version == '3.0' }}
|
370
379
|
|
371
380
|
strategy:
|
372
381
|
matrix:
|
373
|
-
ruby-version: [2.7, 2.4, jruby]
|
382
|
+
ruby-version: ['3.0', '2.7', '2.4', jruby]
|
374
383
|
|
375
384
|
env:
|
376
385
|
BUNDLE_WITH: transformers GDBM Fog
|
@@ -400,6 +409,7 @@ jobs:
|
|
400
409
|
rubocop:
|
401
410
|
name: "Rubocop"
|
402
411
|
runs-on: ubuntu-latest
|
412
|
+
continue-on-error: ${{ matrix.ruby-version == '3.0' }}
|
403
413
|
|
404
414
|
steps:
|
405
415
|
- uses: actions/checkout@v2
|
@@ -407,7 +417,7 @@ jobs:
|
|
407
417
|
- name: Set up Ruby
|
408
418
|
uses: ruby/setup-ruby@v1
|
409
419
|
with:
|
410
|
-
ruby-version:
|
420
|
+
ruby-version: '3.0'
|
411
421
|
bundler: latest
|
412
422
|
bundler-cache: true
|
413
423
|
|
data/CHANGES
CHANGED
data/Gemfile
CHANGED
@@ -89,8 +89,8 @@ group :Memcached, optional: true do
|
|
89
89
|
end
|
90
90
|
|
91
91
|
group :MemcachedNative, optional: true do
|
92
|
-
gem 'memcached', platforms: :ruby
|
93
92
|
gem 'jruby-memcached', platforms: :jruby
|
93
|
+
gem 'memcached', platforms: :ruby
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -99,7 +99,9 @@ group :Riak, optional: true do
|
|
99
99
|
end
|
100
100
|
|
101
101
|
group :Cassandra, optional: true do
|
102
|
-
|
102
|
+
install_if lambda { RUBY_ENGINE != 'ruby' || Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.0.0') } do
|
103
|
+
gem 'cassandra-driver'
|
104
|
+
end
|
103
105
|
end
|
104
106
|
|
105
107
|
group :TokyoTyrant, optional: true do
|
@@ -131,7 +133,9 @@ group :TokyoCabinet, optional: true do
|
|
131
133
|
end
|
132
134
|
|
133
135
|
group :KyotoCabinet, optional: true do
|
134
|
-
|
136
|
+
install_if lambda { Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7.0') } do
|
137
|
+
gem 'kyotocabinet-ruby-reanimated', platforms: :ruby
|
138
|
+
end
|
135
139
|
end
|
136
140
|
|
137
141
|
group :H2, optional: true do
|
@@ -148,9 +152,11 @@ group :RestClient do
|
|
148
152
|
end
|
149
153
|
|
150
154
|
group :DataMapper, optional: true do
|
151
|
-
|
152
|
-
|
153
|
-
|
155
|
+
install_if lambda { RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.0.0') } do
|
156
|
+
gem 'dm-core'
|
157
|
+
gem 'dm-migrations'
|
158
|
+
gem 'dm-mysql-adapter'
|
159
|
+
end
|
154
160
|
end
|
155
161
|
|
156
162
|
group :Fog, optional: true do
|
@@ -173,6 +179,12 @@ group :postgresql, optional: true do
|
|
173
179
|
gem 'pg', platforms: :ruby
|
174
180
|
end
|
175
181
|
|
182
|
+
group :SDBM, optional: true do
|
183
|
+
install_if lambda { Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0') } do
|
184
|
+
gem 'sdbm', platforms: :ruby
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
176
188
|
# Rack integration testing
|
177
189
|
group :rack do
|
178
190
|
gem 'rack'
|
@@ -194,4 +206,5 @@ end
|
|
194
206
|
# Used for running a dev console
|
195
207
|
group :console, optional: true do
|
196
208
|
gem 'irb'
|
209
|
+
gem 'rdoc'
|
197
210
|
end
|
data/lib/moneta/adapters/file.rb
CHANGED
@@ -16,7 +16,7 @@ module Moneta
|
|
16
16
|
# @param [Hash] options
|
17
17
|
# @option options [String] :dir Directory where files will be stored
|
18
18
|
def initialize(options = {})
|
19
|
-
configure(options)
|
19
|
+
configure(**options)
|
20
20
|
FileUtils.mkpath(config.dir)
|
21
21
|
raise "#{config.dir} is not a directory" unless ::File.directory?(config.dir)
|
22
22
|
end
|
data/lib/moneta/version.rb
CHANGED
data/spec/features/null.rb
CHANGED
@@ -1,66 +1,66 @@
|
|
1
1
|
shared_examples :null do
|
2
2
|
it 'reads from keys like a Hash' do
|
3
|
-
moneta_property_of(keys: 1).check do |
|
4
|
-
store[keys[0]].should be_nil
|
5
|
-
store.load(keys[0]).should be_nil
|
3
|
+
moneta_property_of(keys: 1).check do |m|
|
4
|
+
store[m.keys[0]].should be_nil
|
5
|
+
store.load(m.keys[0]).should be_nil
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'guarantees that the same value is returned when setting a key' do
|
10
|
-
moneta_property_of(keys: 1, values: 1).check do |
|
11
|
-
(store[keys[0]] = values[0]).should equal(values[0])
|
10
|
+
moneta_property_of(keys: 1, values: 1).check do |m|
|
11
|
+
(store[m.keys[0]] = m.values[0]).should equal(m.values[0])
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'returns false from #key? if a key is not available' do
|
16
|
-
moneta_property_of(keys: 1).check(1) do |
|
17
|
-
store.key?(keys[0]).should be false
|
16
|
+
moneta_property_of(keys: 1).check(1) do |m|
|
17
|
+
store.key?(m.keys[0]).should be false
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'returns nil from delete if a value for a key does not exist' do
|
22
|
-
moneta_property_of(keys: 1).check do |
|
23
|
-
store.delete(keys[0]).should be_nil
|
22
|
+
moneta_property_of(keys: 1).check do |m|
|
23
|
+
store.delete(m.keys[0]).should be_nil
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'removes all keys from the store with clear' do
|
28
|
-
moneta_property_of(keys: 2, values: 2).check do |
|
29
|
-
store[keys[0]] = values[0]
|
30
|
-
store[keys[1]] = values[1]
|
28
|
+
moneta_property_of(keys: 2, values: 2).check do |m|
|
29
|
+
store[m.keys[0]] = m.values[0]
|
30
|
+
store[m.keys[1]] = m.values[1]
|
31
31
|
store.clear.should equal(store)
|
32
|
-
store.key?(keys[0]).should be false
|
33
|
-
store.key?(keys[1]).should be false
|
32
|
+
store.key?(m.keys[0]).should be false
|
33
|
+
store.key?(m.keys[1]).should be false
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'fetches a key with a default value with fetch, if the key is not available' do
|
38
|
-
moneta_property_of(keys: 1, values: 1).check do |
|
39
|
-
store.fetch(keys[0], values[0]).should == values[0]
|
38
|
+
moneta_property_of(keys: 1, values: 1).check do |m|
|
39
|
+
store.fetch(m.keys[0], m.values[0]).should == m.values[0]
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'fetches a key with a block with fetch, if the key is not available' do
|
44
|
-
moneta_property_of(keys: 1, values: 1).check do |
|
45
|
-
store.fetch(keys[0]) do |k|
|
46
|
-
k.should equal(keys[0])
|
47
|
-
values[0]
|
48
|
-
end.should equal(values[0])
|
44
|
+
moneta_property_of(keys: 1, values: 1).check do |m|
|
45
|
+
store.fetch(m.keys[0]) do |k|
|
46
|
+
k.should equal(m.keys[0])
|
47
|
+
m.values[0]
|
48
|
+
end.should equal(m.values[0])
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'accepts frozen options' do
|
53
|
-
moneta_property_of(keys: 1, values: 1).check do |
|
53
|
+
moneta_property_of(keys: 1, values: 1).check do |m|
|
54
54
|
options = {option1: 1, options2: 2}
|
55
55
|
options.freeze
|
56
56
|
store.clear.should equal(store)
|
57
|
-
store.key?(keys[0], options).should be false
|
58
|
-
store.load(keys[0], options).should be_nil
|
59
|
-
store.fetch(keys[0], 42, options).should == 42
|
60
|
-
store.fetch(keys[0], options) { 42 }.should == 42
|
61
|
-
store.delete(keys[0], options).should be_nil
|
57
|
+
store.key?(m.keys[0], options).should be false
|
58
|
+
store.load(m.keys[0], options).should be_nil
|
59
|
+
store.fetch(m.keys[0], 42, options).should == 42
|
60
|
+
store.fetch(m.keys[0], options) { 42 }.should == 42
|
61
|
+
store.delete(m.keys[0], options).should be_nil
|
62
62
|
store.clear(options).should equal(store)
|
63
|
-
store.store(keys[0], values[0], options).should == values[0]
|
63
|
+
store.store(m.keys[0], m.values[0], options).should == m.values[0]
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
data/spec/features/persist.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
shared_examples :persist do
|
2
2
|
it 'persists values' do
|
3
|
-
moneta_property_of(keys: 1, values: 1).check do |
|
3
|
+
moneta_property_of(keys: 1, values: 1).check do |m|
|
4
4
|
new_store.tap do |store|
|
5
|
-
store[keys[0]] = values[0]
|
5
|
+
store[m.keys[0]] = m.values[0]
|
6
6
|
store.close
|
7
7
|
end
|
8
8
|
new_store.tap do |store|
|
9
|
-
store[keys[0]].should == values[0]
|
9
|
+
store[m.keys[0]].should == m.values[0]
|
10
10
|
store.close
|
11
11
|
end
|
12
12
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
shared_examples :returndifferent do
|
2
2
|
it 'guarantees that a different value is retrieved' do
|
3
|
-
moneta_property_of(keys: 1, values: 1).check do |
|
4
|
-
next if [TrueClass,FalseClass,NilClass,Numeric].any?(&values[0].method(:is_a?))
|
5
|
-
store[keys[0]] = values[0]
|
6
|
-
store[keys[0]].should_not be_equal(values[0])
|
3
|
+
moneta_property_of(keys: 1, values: 1).check do |m|
|
4
|
+
next if [TrueClass,FalseClass,NilClass,Numeric].any?(&m.values[0].method(:is_a?))
|
5
|
+
store[m.keys[0]] = m.values[0]
|
6
|
+
store[m.keys[0]].should_not be_equal(m.values[0])
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
data/spec/features/returnsame.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
shared_examples :returnsame do
|
2
2
|
it 'guarantees that the same value is retrieved' do
|
3
|
-
moneta_property_of(keys: 1, values: 1).check do |
|
4
|
-
next if [TrueClass,FalseClass,Numeric].any?(&values[0].method(:is_a?))
|
5
|
-
store[keys[0]] = values[0]
|
6
|
-
store[keys[0]].should be_equal(values[0])
|
3
|
+
moneta_property_of(keys: 1, values: 1).check do |m|
|
4
|
+
next if [TrueClass, FalseClass, Numeric].any?(&m.values[0].method(:is_a?))
|
5
|
+
store[m.keys[0]] = m.values[0]
|
6
|
+
store[m.keys[0]].should be_equal(m.values[0])
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
data/spec/features/store.rb
CHANGED
@@ -1,106 +1,106 @@
|
|
1
1
|
shared_examples :store do
|
2
2
|
it 'writes values to keys that like a Hash' do
|
3
|
-
moneta_property_of(keys: 1, values: 1).check do |
|
4
|
-
store[keys[0]] = values[0]
|
5
|
-
store[keys[0]].should == values[0]
|
6
|
-
store.load(keys[0]).should == values[0]
|
3
|
+
moneta_property_of(keys: 1, values: 1).check do |m|
|
4
|
+
store[m.keys[0]] = m.values[0]
|
5
|
+
store[m.keys[0]].should == m.values[0]
|
6
|
+
store.load(m.keys[0]).should == m.values[0]
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'returns true from #key? if a key is available' do
|
11
|
-
moneta_property_of(keys: 1, values: 1).check do |
|
12
|
-
store[keys[0]] = values[0]
|
13
|
-
store.key?(keys[0]).should be true
|
11
|
+
moneta_property_of(keys: 1, values: 1).check do |m|
|
12
|
+
store[m.keys[0]] = m.values[0]
|
13
|
+
store.key?(m.keys[0]).should be true
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'stores values with #store' do
|
18
|
-
moneta_property_of(keys: 1, values: 1).check do |
|
19
|
-
value = values[0]
|
20
|
-
store.store(keys[0], value).should equal(value)
|
21
|
-
store[keys[0]].should == values[0]
|
22
|
-
store.load(keys[0]).should == values[0]
|
18
|
+
moneta_property_of(keys: 1, values: 1).check do |m|
|
19
|
+
value = m.values[0]
|
20
|
+
store.store(m.keys[0], value).should equal(value)
|
21
|
+
store[m.keys[0]].should == m.values[0]
|
22
|
+
store.load(m.keys[0]).should == m.values[0]
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'stores values after clear' do
|
27
|
-
moneta_property_of(keys: 2, values: 2).check do |
|
28
|
-
store[keys[0]] = values[0]
|
29
|
-
store[keys[1]] = values[1]
|
27
|
+
moneta_property_of(keys: 2, values: 2).check do |m|
|
28
|
+
store[m.keys[0]] = m.values[0]
|
29
|
+
store[m.keys[1]] = m.values[1]
|
30
30
|
store.clear.should equal(store)
|
31
|
-
store[keys[0]] = values[0]
|
32
|
-
store[keys[0]].should == values[0]
|
33
|
-
store[keys[1]].should be_nil
|
31
|
+
store[m.keys[0]] = m.values[0]
|
32
|
+
store[m.keys[0]].should == m.values[0]
|
33
|
+
store[m.keys[1]].should be_nil
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'removes and returns a value from the backing store via delete if it exists' do
|
38
|
-
moneta_property_of(keys: 1, values: 1).check do |
|
39
|
-
store[keys[0]] = values[0]
|
40
|
-
store.delete(keys[0]).should == values[0]
|
41
|
-
store.key?(keys[0]).should be false
|
38
|
+
moneta_property_of(keys: 1, values: 1).check do |m|
|
39
|
+
store[m.keys[0]] = m.values[0]
|
40
|
+
store.delete(m.keys[0]).should == m.values[0]
|
41
|
+
store.key?(m.keys[0]).should be false
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'overwrites existing values' do
|
46
|
-
moneta_property_of(keys: 1, values: 2).check do |
|
47
|
-
store[keys[0]] = values[0]
|
48
|
-
store[keys[0]].should == values[0]
|
49
|
-
store[keys[0]] = values[1]
|
50
|
-
store[keys[0]].should == values[1]
|
46
|
+
moneta_property_of(keys: 1, values: 2).check do |m|
|
47
|
+
store[m.keys[0]] = m.values[0]
|
48
|
+
store[m.keys[0]].should == m.values[0]
|
49
|
+
store[m.keys[0]] = m.values[1]
|
50
|
+
store[m.keys[0]].should == m.values[1]
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
54
|
it 'stores frozen values' do
|
55
|
-
moneta_property_of(keys: 1, values: 1).check do |
|
56
|
-
value = values[0].freeze
|
57
|
-
(store[keys[0]] = value).should equal(value)
|
58
|
-
store[keys[0]].should == values[0]
|
55
|
+
moneta_property_of(keys: 1, values: 1).check do |m|
|
56
|
+
value = m.values[0].freeze
|
57
|
+
(store[m.keys[0]] = value).should equal(value)
|
58
|
+
store[m.keys[0]].should == m.values[0]
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'stores frozen keys' do
|
63
|
-
moneta_property_of(keys: 1, values: 1).check do |
|
64
|
-
key = keys[0].freeze
|
65
|
-
store[key] = values[0]
|
66
|
-
store[keys[0]].should == values[0]
|
63
|
+
moneta_property_of(keys: 1, values: 1).check do |m|
|
64
|
+
key = m.keys[0].freeze
|
65
|
+
store[key] = m.values[0]
|
66
|
+
store[m.keys[0]].should == m.values[0]
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
it 'fetches a key with a default value with fetch, if the key is available' do
|
71
|
-
moneta_property_of(keys: 1, values: 2).check do |
|
72
|
-
next if values[0].nil?
|
73
|
-
store[keys[0]] = values[0]
|
74
|
-
store.fetch(keys[0], values[1]).should == values[0]
|
71
|
+
moneta_property_of(keys: 1, values: 2).check do |m|
|
72
|
+
next if m.values[0].nil?
|
73
|
+
store[m.keys[0]] = m.values[0]
|
74
|
+
store.fetch(m.keys[0], m.values[1]).should == m.values[0]
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
78
|
it 'does not run the block in fetch if the key is available' do
|
79
|
-
moneta_property_of(keys: 1, values: 1).check do |
|
80
|
-
next if values[0].nil?
|
81
|
-
store[keys[0]] = values[0]
|
79
|
+
moneta_property_of(keys: 1, values: 1).check do |m|
|
80
|
+
next if m.values[0].nil?
|
81
|
+
store[m.keys[0]] = m.values[0]
|
82
82
|
unaltered = 'unaltered'
|
83
|
-
store.fetch(keys[0]) { unaltered = 'altered' }
|
83
|
+
store.fetch(m.keys[0]) { unaltered = 'altered' }
|
84
84
|
unaltered.should == 'unaltered'
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
88
|
shared_examples :values_at do |name|
|
89
89
|
it 'retrieves stored values' do
|
90
|
-
moneta_property_of(keys: 3, values: 3).check do |
|
91
|
-
store[keys[0]] = values[0]
|
92
|
-
store[keys[1]] = values[1]
|
93
|
-
store[keys[2]] = values[2]
|
94
|
-
expect(store.public_send(name, keys[1], keys[2], keys[0])).to eq [values[1], values[2], values[0]]
|
90
|
+
moneta_property_of(keys: 3, values: 3).check do |m|
|
91
|
+
store[m.keys[0]] = m.values[0]
|
92
|
+
store[m.keys[1]] = m.values[1]
|
93
|
+
store[m.keys[2]] = m.values[2]
|
94
|
+
expect(store.public_send(name, m.keys[1], m.keys[2], m.keys[0])).to eq [m.values[1], m.values[2], m.values[0]]
|
95
95
|
store.clear
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
99
|
it 'returns nil in place of missing values' do
|
100
|
-
moneta_property_of(keys: 3, values: 2).check do |
|
101
|
-
store[keys[0]] = values[0]
|
102
|
-
store[keys[1]] = values[1]
|
103
|
-
expect(store.public_send(name, keys[1], keys[2], keys[0])).to eq [values[1], nil, values[0]]
|
100
|
+
moneta_property_of(keys: 3, values: 2).check do |m|
|
101
|
+
store[m.keys[0]] = m.values[0]
|
102
|
+
store[m.keys[1]] = m.values[1]
|
103
|
+
expect(store.public_send(name, m.keys[1], m.keys[2], m.keys[0])).to eq [m.values[1], nil, m.values[0]]
|
104
104
|
store.clear
|
105
105
|
end
|
106
106
|
end
|
@@ -114,29 +114,29 @@ shared_examples :store do
|
|
114
114
|
include_examples :values_at, :fetch_values
|
115
115
|
|
116
116
|
it 'yields to the block, if given, for keys that are not in the store' do
|
117
|
-
moneta_property_of(keys: 4, values: 3).check do |
|
118
|
-
store[keys[0]] = values[0]
|
119
|
-
store[keys[1]] = values[1]
|
120
|
-
store[keys[2]] = values[2]
|
117
|
+
moneta_property_of(keys: 4, values: 3).check do |m|
|
118
|
+
store[m.keys[0]] = m.values[0]
|
119
|
+
store[m.keys[1]] = m.values[1]
|
120
|
+
store[m.keys[2]] = m.values[2]
|
121
121
|
|
122
122
|
expect do |b|
|
123
|
-
store.fetch_values(keys[0], keys[1], keys[2], keys[3], &b)
|
124
|
-
end.to yield_with_args(keys[3])
|
123
|
+
store.fetch_values(m.keys[0], m.keys[1], m.keys[2], m.keys[3], &b)
|
124
|
+
end.to yield_with_args(m.keys[3])
|
125
125
|
|
126
126
|
store.clear
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
130
|
it 'uses the value of the block, if given, for keys that are not in the store' do
|
131
|
-
moneta_property_of(keys: 4, values: 4).check do |
|
132
|
-
store[keys[0]] = values[0]
|
133
|
-
store[keys[1]] = values[1]
|
134
|
-
store[keys[2]] = values[2]
|
131
|
+
moneta_property_of(keys: 4, values: 4).check do |m|
|
132
|
+
store[m.keys[0]] = m.values[0]
|
133
|
+
store[m.keys[1]] = m.values[1]
|
134
|
+
store[m.keys[2]] = m.values[2]
|
135
135
|
|
136
|
-
expect(store.fetch_values(keys[0], keys[1], keys[2], keys[3]) do |key|
|
137
|
-
expect(key).to eq keys[3]
|
138
|
-
values[3]
|
139
|
-
end).to eq [values[0], values[1], values[2], values[3]]
|
136
|
+
expect(store.fetch_values(m.keys[0], m.keys[1], m.keys[2], m.keys[3]) do |key|
|
137
|
+
expect(key).to eq m.keys[3]
|
138
|
+
m.values[3]
|
139
|
+
end).to eq [m.values[0], m.values[1], m.values[2], m.values[3]]
|
140
140
|
|
141
141
|
store.clear
|
142
142
|
end
|
@@ -149,26 +149,26 @@ shared_examples :store do
|
|
149
149
|
|
150
150
|
describe '#slice' do
|
151
151
|
it 'returns pairs of stored keys and values' do
|
152
|
-
moneta_property_of(keys: 3, values: 3).check do |
|
153
|
-
store[keys[0]] = values[0]
|
154
|
-
store[keys[1]] = values[1]
|
155
|
-
store[keys[2]] = values[2]
|
152
|
+
moneta_property_of(keys: 3, values: 3).check do |m|
|
153
|
+
store[m.keys[0]] = m.values[0]
|
154
|
+
store[m.keys[1]] = m.values[1]
|
155
|
+
store[m.keys[2]] = m.values[2]
|
156
156
|
|
157
|
-
expect(store.slice(*[keys[0], keys[1], keys[2]].shuffle).to_a).to \
|
158
|
-
contain_exactly([keys[0], values[0]], [keys[1], values[1]], [keys[2], values[2]])
|
157
|
+
expect(store.slice(*[m.keys[0], m.keys[1], m.keys[2]].shuffle).to_a).to \
|
158
|
+
contain_exactly([m.keys[0], m.values[0]], [m.keys[1], m.values[1]], [m.keys[2], m.values[2]])
|
159
159
|
|
160
160
|
store.clear
|
161
161
|
end
|
162
162
|
end
|
163
163
|
|
164
164
|
it 'does not return pairs for any keys absent from the store' do
|
165
|
-
moneta_property_of(keys: 4, values: 3).check do |
|
166
|
-
store[keys[0]] = values[0]
|
167
|
-
store[keys[1]] = values[1]
|
168
|
-
store[keys[2]] = values[2]
|
165
|
+
moneta_property_of(keys: 4, values: 3).check do |m|
|
166
|
+
store[m.keys[0]] = m.values[0]
|
167
|
+
store[m.keys[1]] = m.values[1]
|
168
|
+
store[m.keys[2]] = m.values[2]
|
169
169
|
|
170
|
-
expect(store.slice(*[keys[0], keys[1], keys[2], keys[3]].shuffle).to_a).to \
|
171
|
-
contain_exactly([keys[0], values[0]], [keys[1], values[1]], [keys[2], values[2]])
|
170
|
+
expect(store.slice(*[m.keys[0], m.keys[1], m.keys[2], m.keys[3]].shuffle).to_a).to \
|
171
|
+
contain_exactly([m.keys[0], m.values[0]], [m.keys[1], m.values[1]], [m.keys[2], m.values[2]])
|
172
172
|
|
173
173
|
store.clear
|
174
174
|
end
|
@@ -177,44 +177,44 @@ shared_examples :store do
|
|
177
177
|
|
178
178
|
shared_examples :merge! do
|
179
179
|
it 'stores values' do
|
180
|
-
moneta_property_of(keys: 3, values: 3).check do |
|
181
|
-
expect(store.public_send(method, pairs.call({ keys[0] => values[0], keys[1] => values[1], keys[2] => values[2] }))).to be store
|
182
|
-
expect(store.key?(keys[0])).to be true
|
183
|
-
expect(store[keys[0]]).to eq values[0]
|
184
|
-
expect(store.key?(keys[1])).to be true
|
185
|
-
expect(store[keys[1]]).to eq values[1]
|
186
|
-
expect(store.key?(keys[2])).to be true
|
187
|
-
expect(store[keys[2]]).to eq values[2]
|
180
|
+
moneta_property_of(keys: 3, values: 3).check do |m|
|
181
|
+
expect(store.public_send(method, pairs.call({ m.keys[0] => m.values[0], m.keys[1] => m.values[1], m.keys[2] => m.values[2] }))).to be store
|
182
|
+
expect(store.key?(m.keys[0])).to be true
|
183
|
+
expect(store[m.keys[0]]).to eq m.values[0]
|
184
|
+
expect(store.key?(m.keys[1])).to be true
|
185
|
+
expect(store[m.keys[1]]).to eq m.values[1]
|
186
|
+
expect(store.key?(m.keys[2])).to be true
|
187
|
+
expect(store[m.keys[2]]).to eq m.values[2]
|
188
188
|
store.clear
|
189
189
|
end
|
190
190
|
end
|
191
191
|
|
192
192
|
it 'overwrites existing values' do
|
193
|
-
moneta_property_of(keys: 2, values: 3).check do |
|
194
|
-
expect(store[keys[0]] = values[0]).to eq values[0]
|
195
|
-
expect(store.public_send(method, pairs.call({ keys[0] => values[1], keys[1] => values[2] }))).to be store
|
196
|
-
expect(store.key?(keys[0])).to be true
|
197
|
-
expect(store[keys[0]]).to eq values[1]
|
198
|
-
expect(store.key?(keys[1])).to be true
|
199
|
-
expect(store[keys[1]]).to eq values[2]
|
193
|
+
moneta_property_of(keys: 2, values: 3).check do |m|
|
194
|
+
expect(store[m.keys[0]] = m.values[0]).to eq m.values[0]
|
195
|
+
expect(store.public_send(method, pairs.call({ m.keys[0] => m.values[1], m.keys[1] => m.values[2] }))).to be store
|
196
|
+
expect(store.key?(m.keys[0])).to be true
|
197
|
+
expect(store[m.keys[0]]).to eq m.values[1]
|
198
|
+
expect(store.key?(m.keys[1])).to be true
|
199
|
+
expect(store[m.keys[1]]).to eq m.values[2]
|
200
200
|
store.clear
|
201
201
|
end
|
202
202
|
end
|
203
203
|
|
204
204
|
it 'stores the return value of the block, if given, for keys that will be overwritten' do
|
205
|
-
moneta_property_of(keys: 2, values: 4).check do |
|
206
|
-
expect(store[keys[0]] = values[0]).to eq values[0]
|
207
|
-
expect(store.public_send(method, pairs.call({ keys[0] => values[1], keys[1] => values[2] })) do |key, old_val, new_val|
|
208
|
-
expect(key).to eq keys[0]
|
209
|
-
expect(old_val).to eq values[0]
|
210
|
-
expect(new_val).to eq values[1]
|
211
|
-
values[3]
|
205
|
+
moneta_property_of(keys: 2, values: 4).check do |m|
|
206
|
+
expect(store[m.keys[0]] = m.values[0]).to eq m.values[0]
|
207
|
+
expect(store.public_send(method, pairs.call({ m.keys[0] => m.values[1], m.keys[1] => m.values[2] })) do |key, old_val, new_val|
|
208
|
+
expect(key).to eq m.keys[0]
|
209
|
+
expect(old_val).to eq m.values[0]
|
210
|
+
expect(new_val).to eq m.values[1]
|
211
|
+
m.values[3]
|
212
212
|
end).to be store
|
213
213
|
|
214
|
-
expect(store.key?(keys[0])).to be true
|
215
|
-
expect(store[keys[0]]).to eq values[3]
|
216
|
-
expect(store.key?(keys[1])).to be true
|
217
|
-
expect(store[keys[1]]).to eq values[2]
|
214
|
+
expect(store.key?(m.keys[0])).to be true
|
215
|
+
expect(store[m.keys[0]]).to eq m.values[3]
|
216
|
+
expect(store.key?(m.keys[1])).to be true
|
217
|
+
expect(store[m.keys[1]]).to eq m.values[2]
|
218
218
|
store.clear
|
219
219
|
end
|
220
220
|
end
|
data/spec/helper.rb
CHANGED
@@ -335,9 +335,7 @@ module MonetaHelpers
|
|
335
335
|
value_values = values.times.map { call(values_meta) }
|
336
336
|
guard value_values.uniq.length == value_values.length
|
337
337
|
|
338
|
-
|
339
|
-
reject { |key, value| value.empty? }.
|
340
|
-
to_h
|
338
|
+
Struct.new(:keys, :values).new(key_values, value_values)
|
341
339
|
end
|
342
340
|
end
|
343
341
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative './helper.rb'
|
2
2
|
|
3
|
-
describe 'adapter_cassandra', retry: 3, adapter: :Cassandra do
|
3
|
+
describe 'adapter_cassandra', retry: 3, adapter: :Cassandra, unsupported: RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0') do
|
4
4
|
let(:t_res) { 1 }
|
5
5
|
let(:min_ttl) { 2 }
|
6
6
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative './helper.rb'
|
2
2
|
|
3
|
-
describe 'adapter_cassandra_with_default_expires', isolate: true, retry: 3, adapter: :Cassandra do
|
3
|
+
describe 'adapter_cassandra_with_default_expires', isolate: true, retry: 3, adapter: :Cassandra, unsupported: RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0') do
|
4
4
|
let(:t_res) { 1 }
|
5
5
|
let(:min_ttl) { 2 }
|
6
6
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative './helper.rb'
|
2
2
|
|
3
|
-
describe "standard_cassandra", retry: 3, adapter: :Cassandra do
|
3
|
+
describe "standard_cassandra", retry: 3, adapter: :Cassandra, unsupported: RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0') do
|
4
4
|
let(:t_res) { 1 }
|
5
5
|
let(:min_ttl) { 2 }
|
6
6
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
describe 'adapter_datamapper',
|
1
|
+
describe 'adapter_datamapper', unsupported: defined?(JRUBY_VERSION) || RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0'), adapter: :DataMapper, mysql: true do
|
2
2
|
before :all do
|
3
3
|
require 'dm-core'
|
4
4
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
describe "standard_datamapper",
|
1
|
+
describe "standard_datamapper", unsupported: defined?(JRUBY_VERSION) || RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0'), adapter: :DataMapper, mysql: true do
|
2
2
|
before :all do
|
3
3
|
require 'dm-core'
|
4
4
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
describe "standard_datamapper_with_expires",
|
1
|
+
describe "standard_datamapper_with_expires", unsupported: defined?(JRUBY_VERSION) || RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0'), adapter: :DataMapper, mysql: true do
|
2
2
|
let(:t_res) { 0.125 }
|
3
3
|
let(:min_ttl) { t_res }
|
4
4
|
use_timecop
|
@@ -1,4 +1,4 @@
|
|
1
|
-
describe 'standard_datamapper_with_repository',
|
1
|
+
describe 'standard_datamapper_with_repository', unsupported: defined?(JRUBY_VERSION) || RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0'), adapter: :DataMapper, mysql: true do
|
2
2
|
before :all do
|
3
3
|
require 'dm-core'
|
4
4
|
|
@@ -14,8 +14,8 @@ describe 'enumerable', proxy: :Enumerable do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'allows enumeration over key-value pairs' do
|
17
|
-
moneta_property_of(keys: 100, values: 100) do |
|
18
|
-
pairs = keys.zip(values)
|
17
|
+
moneta_property_of(keys: 100, values: 100) do |m|
|
18
|
+
pairs = m.keys.zip(m.values)
|
19
19
|
store.merge!(pairs)
|
20
20
|
expect(store.to_a).to contain_exactly(*pairs)
|
21
21
|
expect(store.each.to_a).to contain_exactly(*pairs)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moneta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Mendler
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2022-04-
|
14
|
+
date: 2022-04-13 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: multi_json
|
@@ -446,9 +446,9 @@ licenses:
|
|
446
446
|
- MIT
|
447
447
|
metadata:
|
448
448
|
bug_tracker_uri: https://github.com/moneta-rb/moneta/issues
|
449
|
-
changelog_uri: https://github.com/moneta-rb/moneta/blob/v1.5.
|
450
|
-
documentation_uri: https://www.rubydoc.info/gems/moneta/1.5.
|
451
|
-
source_code_uri: https://github.com/moneta-rb/moneta/tree/v1.5.
|
449
|
+
changelog_uri: https://github.com/moneta-rb/moneta/blob/v1.5.1/CHANGES
|
450
|
+
documentation_uri: https://www.rubydoc.info/gems/moneta/1.5.1
|
451
|
+
source_code_uri: https://github.com/moneta-rb/moneta/tree/v1.5.1
|
452
452
|
post_install_message:
|
453
453
|
rdoc_options: []
|
454
454
|
require_paths:
|
@@ -464,7 +464,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
464
464
|
- !ruby/object:Gem::Version
|
465
465
|
version: '0'
|
466
466
|
requirements: []
|
467
|
-
rubygems_version: 3.
|
467
|
+
rubygems_version: 3.2.29
|
468
468
|
signing_key:
|
469
469
|
specification_version: 4
|
470
470
|
summary: A unified interface to key/value stores, including Redis, Memcached, TokyoCabinet,
|