moneta 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +4 -0
- data/CONTRIBUTORS +2 -1
- data/lib/moneta/transformer/helper.rb +2 -2
- data/lib/moneta/version.rb +1 -1
- data/moneta.gemspec +9 -1
- data/script/contributors +1 -0
- data/spec/features/transform_value.rb +21 -27
- data/spec/helper.rb +45 -46
- data/spec/moneta/proxies/transformer/transformer_marshal_escape_spec.rb +7 -3
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 535578909c47f29047f67d577e053809a637f77ea8ba2dde7920198f8b08ac49
|
4
|
+
data.tar.gz: 275edd79995139f4918749d01ccdf8129748ea96e1ba4302716dd7cb1ed57bf9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c07c093306f66138db9db041a15103420fdd0e5fef93ca429098de02a732055d441c0968570704ba39dcb08608b7dbfa12b5cd5797e257df1c8be28a7b3b028d
|
7
|
+
data.tar.gz: a654005281162398bf492fd7fa3e3c59ee40f675d6a187579d4cbfcb0bfbd14e0a78a9f9bb3227e5c64c02e4c97e60bb9b39075457803882aeaa3d585b0e9a51
|
data/CHANGES
CHANGED
data/CONTRIBUTORS
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
Adrian Madrid <aemadrid@gmail.com>
|
2
|
-
Alastair Pharo <
|
2
|
+
Alastair Pharo <me@asph.dev>
|
3
3
|
Alejandro Crosa <acrosa@sharing.local>
|
4
4
|
Alessio Signorini <alessio@signorini.us>
|
5
5
|
Anthony Eden <anthonyeden@gmail.com>
|
@@ -24,6 +24,7 @@ Marek Skrobacki <skrobul@skrobul.com>
|
|
24
24
|
Mauro Asprea <mauroasprea@gmail.com>
|
25
25
|
Nathaniel Bibler <git@nathanielbibler.com>
|
26
26
|
Olle Jonsson <olle.jonsson@gmail.com>
|
27
|
+
Orien Madgwick <_@orien.io>
|
27
28
|
Patrik Rak <patrik@raxoft.cz>
|
28
29
|
Piotr Murach <pmurach@gmail.com>
|
29
30
|
Potapov Sergey <blake131313@gmail.com>
|
@@ -5,11 +5,11 @@ module Moneta
|
|
5
5
|
extend self
|
6
6
|
|
7
7
|
def escape(value)
|
8
|
-
value.gsub(/[^a-zA-Z0-9_-]+/) { '%' +
|
8
|
+
value.gsub(/[^a-zA-Z0-9_-]+/) { |match| '%' + match.unpack('H2' * match.bytesize).join('%').upcase }
|
9
9
|
end
|
10
10
|
|
11
11
|
def unescape(value)
|
12
|
-
value.gsub(/(
|
12
|
+
value.gsub(/(?:%[0-9a-fA-F]{2})+/) { |match| [match.delete('%')].pack('H*') }
|
13
13
|
end
|
14
14
|
|
15
15
|
def hmacverify(value, secret)
|
data/lib/moneta/version.rb
CHANGED
data/moneta.gemspec
CHANGED
@@ -13,10 +13,18 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.files = `git ls-files`.split("\n")
|
14
14
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
15
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
|
-
s.homepage = '
|
16
|
+
s.homepage = 'https://github.com/moneta-rb/moneta'
|
17
17
|
s.licenses = %w(MIT)
|
18
18
|
s.require_paths = %w(lib)
|
19
19
|
s.summary = %{A unified interface to key/value stores, including Redis, Memcached, TokyoCabinet, ActiveRecord and many more}
|
20
|
+
|
21
|
+
s.metadata = {
|
22
|
+
'bug_tracker_uri' => 'https://github.com/moneta-rb/moneta/issues',
|
23
|
+
'changelog_uri' => "https://github.com/moneta-rb/moneta/blob/v#{s.version}/CHANGES",
|
24
|
+
'documentation_uri' => "https://www.rubydoc.info/gems/moneta/#{s.version}",
|
25
|
+
'source_code_uri' => "https://github.com/moneta-rb/moneta/tree/v#{s.version}",
|
26
|
+
}
|
27
|
+
|
20
28
|
s.required_ruby_version = '>= 2.2.2'
|
21
29
|
|
22
30
|
s.add_development_dependency 'rspec', '~> 3.0'
|
data/script/contributors
CHANGED
@@ -1,11 +1,26 @@
|
|
1
1
|
shared_examples :transform_value do
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
describe 'with the :raw option' do
|
3
|
+
it 'can load without transforming the value' do
|
4
|
+
moneta_property_of(values: 1).check do |values:|
|
5
|
+
store['key'] = values[0]
|
6
|
+
load_value(store.load('key', raw: true)).should == values[0]
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'can store without transforming the value' do
|
11
|
+
moneta_property_of(values: 1).check do |values:|
|
12
|
+
store['key'] = values[0]
|
13
|
+
store.store('key', store.load('key', raw: true), raw: true)
|
14
|
+
store.load('key').should == values[0]
|
15
|
+
end
|
16
|
+
end
|
5
17
|
|
6
|
-
|
7
|
-
|
8
|
-
|
18
|
+
it 'can delete without transforming the value' do
|
19
|
+
moneta_property_of(values: 1).check do |values:|
|
20
|
+
store['key'] = values[0]
|
21
|
+
load_value(store.delete('key', raw: true)).should == values[0]
|
22
|
+
end
|
23
|
+
end
|
9
24
|
end
|
10
25
|
|
11
26
|
it 'allows to bypass transformer with raw syntactic sugar' do
|
@@ -20,25 +35,4 @@ shared_examples :transform_value do
|
|
20
35
|
store.raw['key'] = 'value2'
|
21
36
|
store.raw['key'].should == 'value2'
|
22
37
|
end
|
23
|
-
|
24
|
-
it 'returns unmarshalled value' do
|
25
|
-
store.store('key', 'unmarshalled value', raw: true)
|
26
|
-
store.load('key', raw: true).should == 'unmarshalled value'
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'might raise exception on invalid value' do
|
30
|
-
store.store('key', 'unmarshalled value', raw: true)
|
31
|
-
|
32
|
-
begin
|
33
|
-
store['key'].should == load_value('unmarshalled value')
|
34
|
-
store.delete('key').should == load_value('unmarshalled value')
|
35
|
-
rescue Exception => ex
|
36
|
-
expect do
|
37
|
-
store['key']
|
38
|
-
end.to raise_error
|
39
|
-
expect do
|
40
|
-
store.delete('key')
|
41
|
-
end.to raise_error
|
42
|
-
end
|
43
|
-
end
|
44
38
|
end
|
data/spec/helper.rb
CHANGED
@@ -13,7 +13,6 @@ require 'timecop'
|
|
13
13
|
|
14
14
|
class MonetaParallelFormatter < RSpec::Core::Formatters::BaseTextFormatter
|
15
15
|
def start(*args)
|
16
|
-
|
17
16
|
output.puts colorise_summary("STARTING #{ARGV.join(' ')}")
|
18
17
|
@stopped = false
|
19
18
|
@passed_count = 0
|
@@ -59,12 +58,12 @@ class MonetaSpecs
|
|
59
58
|
'integer' => :integer,
|
60
59
|
'float' => :float,
|
61
60
|
'boolean' => :boolean,
|
62
|
-
'string' => proc{ sized(range
|
63
|
-
'path' => proc{ array(range
|
61
|
+
'string' => proc { sized(range(5, 10)) { string(:alnum) } },
|
62
|
+
'path' => proc { array(range(2, 3)) { sized(range(5, 10)) { string(:alpha) } }.join('/') },
|
64
63
|
'binary' => [:string, :cntrl],
|
65
|
-
'object' => proc{ choose Value.new(:objkey1), Value.new(:objkey2) },
|
66
|
-
'hash' => proc{ dict(2){ sized(range
|
67
|
-
}
|
64
|
+
'object' => proc { choose Value.new(:objkey1), Value.new(:objkey2) },
|
65
|
+
'hash' => proc { dict(2) { sized(range(5, 10)) { [string(:alnum), string(:alnum)] } } }
|
66
|
+
}.freeze
|
68
67
|
|
69
68
|
VALUES = {
|
70
69
|
'nil' => [:literal, nil],
|
@@ -73,10 +72,10 @@ class MonetaSpecs
|
|
73
72
|
'boolean' => :boolean,
|
74
73
|
'string' => [:string, :alnum],
|
75
74
|
'binary' => [:string, :cntrl],
|
76
|
-
'object' => proc{ choose Value.new(:objval1), Value.new(:objval2) },
|
77
|
-
'hash' => proc{ dict{ [string(:alnum), array(2){ choose(string(:alnum), integer, dict{ [string(:alnum), integer] }) }] } },
|
78
|
-
'smallhash' => proc{ dict(2){ sized(range
|
79
|
-
}
|
75
|
+
'object' => proc { choose Value.new(:objval1), Value.new(:objval2) },
|
76
|
+
'hash' => proc { dict { [string(:alnum), array(2) { choose(string(:alnum), integer, dict { [string(:alnum), integer] }) }] } },
|
77
|
+
'smallhash' => proc { dict(2) { sized(range(5, 10)) { [string(:alnum), string(:alnum)] } } }
|
78
|
+
}.freeze
|
80
79
|
|
81
80
|
attr_reader :key, :value, :specs, :features
|
82
81
|
|
@@ -88,23 +87,23 @@ class MonetaSpecs
|
|
88
87
|
end
|
89
88
|
|
90
89
|
def new(options)
|
91
|
-
self.class.new({specs: specs, key: key, value: value}.merge(options))
|
90
|
+
self.class.new({ specs: specs, key: key, value: value }.merge(options))
|
92
91
|
end
|
93
92
|
|
94
93
|
def with_keys(*keys)
|
95
|
-
new(key:
|
94
|
+
new(key: key | keys.map(&:to_s))
|
96
95
|
end
|
97
96
|
|
98
97
|
def without_keys(*keys)
|
99
|
-
new(key:
|
98
|
+
new(key: key - keys.map(&:to_s))
|
100
99
|
end
|
101
100
|
|
102
101
|
def with_values(*values)
|
103
|
-
new(value:
|
102
|
+
new(value: value | values.map(&:to_s))
|
104
103
|
end
|
105
104
|
|
106
105
|
def without_values(*values)
|
107
|
-
new(value:
|
106
|
+
new(value: value - values.map(&:to_s))
|
108
107
|
end
|
109
108
|
|
110
109
|
def without_keys_or_values(*types)
|
@@ -209,53 +208,55 @@ end
|
|
209
208
|
|
210
209
|
ADAPTER_SPECS = MonetaSpecs.new(
|
211
210
|
specs: [:null, :store, :returndifferent,
|
212
|
-
|
213
|
-
|
211
|
+
:increment, :concurrent_increment, :concurrent_create, :persist, :multiprocess,
|
212
|
+
:create, :features, :store_large, :not_each_key],
|
214
213
|
key: %w(string path),
|
215
|
-
value: %w(string path binary)
|
214
|
+
value: %w(string path binary)
|
215
|
+
)
|
216
216
|
STANDARD_SPECS = MonetaSpecs.new(
|
217
217
|
specs: [:null, :store, :returndifferent,
|
218
|
-
|
219
|
-
|
220
|
-
|
218
|
+
:marshallable_key, :marshallable_value, :transform_value, :increment,
|
219
|
+
:concurrent_increment, :concurrent_create, :persist, :multiprocess, :create,
|
220
|
+
:features, :store_large, :not_each_key]
|
221
|
+
)
|
221
222
|
TRANSFORMER_SPECS = MonetaSpecs.new(
|
222
223
|
specs: [:null, :store, :returndifferent,
|
223
|
-
|
224
|
-
|
224
|
+
:transform_value, :increment, :create, :features, :store_large,
|
225
|
+
:not_each_key]
|
226
|
+
)
|
225
227
|
|
226
228
|
module MonetaHelpers
|
227
229
|
module ClassMethods
|
228
|
-
|
229
|
-
|
230
|
-
name = self.description
|
230
|
+
def moneta_store(store_name, options = {}, &block)
|
231
|
+
name = description
|
231
232
|
builder = proc do
|
232
233
|
if block
|
233
234
|
options = instance_exec(&block)
|
234
235
|
end
|
235
236
|
|
236
|
-
Moneta.new(store_name, options.merge(logger: {file: File.join(tempdir, "#{name}.log")}))
|
237
|
+
Moneta.new(store_name, options.merge(logger: { file: File.join(tempdir, "#{name}.log") }))
|
237
238
|
end
|
238
239
|
|
239
240
|
include_context :setup_moneta_store, builder
|
240
241
|
end
|
241
242
|
|
242
|
-
def moneta_build
|
243
|
+
def moneta_build(&block)
|
243
244
|
include_context :setup_moneta_store, block
|
244
245
|
end
|
245
246
|
|
246
|
-
def moneta_loader
|
247
|
+
def moneta_loader(&block)
|
247
248
|
before do
|
248
249
|
@moneta_value_loader = block
|
249
250
|
end
|
250
251
|
end
|
251
252
|
|
252
|
-
def moneta_specs
|
253
|
-
let(:features){ specs.features }
|
253
|
+
def moneta_specs(specs)
|
254
|
+
let(:features) { specs.features }
|
254
255
|
let(:keys_meta) do
|
255
|
-
[:branch, *specs.key.map{ |k| MonetaSpecs::KEYS[k] }.compact]
|
256
|
+
[:branch, *specs.key.map { |k| MonetaSpecs::KEYS[k] }.compact]
|
256
257
|
end
|
257
258
|
let(:values_meta) do
|
258
|
-
[:branch, *specs.value.map{ |k| MonetaSpecs::VALUES[k] }.compact]
|
259
|
+
[:branch, *specs.value.map { |k| MonetaSpecs::VALUES[k] }.compact]
|
259
260
|
end
|
260
261
|
|
261
262
|
# Used by tests that rely on MySQL. These env vars can be used if you
|
@@ -298,7 +299,7 @@ module MonetaHelpers
|
|
298
299
|
end
|
299
300
|
|
300
301
|
def use_timecop
|
301
|
-
before{ @timecop = true }
|
302
|
+
before { @timecop = true }
|
302
303
|
end
|
303
304
|
end
|
304
305
|
|
@@ -315,7 +316,7 @@ module MonetaHelpers
|
|
315
316
|
@store ||= new_store
|
316
317
|
end
|
317
318
|
|
318
|
-
def load_value
|
319
|
+
def load_value(value)
|
319
320
|
if @moneta_value_loader
|
320
321
|
@moneta_value_loader.call value
|
321
322
|
else
|
@@ -341,9 +342,9 @@ module MonetaHelpers
|
|
341
342
|
value_values = values.times.map { call(values_meta) }
|
342
343
|
guard value_values.uniq.length == value_values.length
|
343
344
|
|
344
|
-
[[:keys, key_values], [:values, value_values]]
|
345
|
-
reject { |
|
346
|
-
to_h
|
345
|
+
[[:keys, key_values], [:values, value_values]]
|
346
|
+
.reject { |_key, value| value.empty? }
|
347
|
+
.to_h
|
347
348
|
end
|
348
349
|
end
|
349
350
|
|
@@ -361,8 +362,8 @@ end
|
|
361
362
|
RSpec.configure do |config|
|
362
363
|
config.verbose_retry = true
|
363
364
|
config.color = true
|
364
|
-
#config.tty = true
|
365
|
-
#config.formatter = ENV['PARALLEL_TESTS'] ? MonetaParallelFormatter : :progress
|
365
|
+
# config.tty = true
|
366
|
+
# config.formatter = ENV['PARALLEL_TESTS'] ? MonetaParallelFormatter : :progress
|
366
367
|
config.silence_filter_announcements = true if ENV['PARALLEL_TESTS']
|
367
368
|
|
368
369
|
# Allow "should" syntax as well as "expect"
|
@@ -379,9 +380,9 @@ RSpec::Expectations.configuration.on_potential_false_positives = :nothing
|
|
379
380
|
# Disable jruby stdout pollution by memcached
|
380
381
|
if defined?(JRUBY_VERSION)
|
381
382
|
require 'java'
|
382
|
-
properties = java.lang.System.getProperties
|
383
|
-
properties.put('net.spy.log.LoggerImpl', 'net.spy.memcached.compat.log.SunLogger')
|
384
|
-
java.lang.System.setProperties(properties)
|
383
|
+
properties = java.lang.System.getProperties
|
384
|
+
properties.put('net.spy.log.LoggerImpl', 'net.spy.memcached.compat.log.SunLogger')
|
385
|
+
java.lang.System.setProperties(properties)
|
385
386
|
java.util.logging.Logger.getLogger('').setLevel(java.util.logging.Level::OFF)
|
386
387
|
end
|
387
388
|
|
@@ -404,7 +405,6 @@ class Value
|
|
404
405
|
end
|
405
406
|
end
|
406
407
|
|
407
|
-
|
408
408
|
def marshal_error
|
409
409
|
# HACK: Marshalling structs in rubinius without class name throws
|
410
410
|
# NoMethodError (to_sym). TODO: Create an issue for rubinius!
|
@@ -415,7 +415,6 @@ def marshal_error
|
|
415
415
|
end
|
416
416
|
end
|
417
417
|
|
418
|
-
|
419
418
|
RSpec.shared_context :setup_moneta_store do |builder|
|
420
419
|
before do
|
421
420
|
@moneta_store_builder = builder
|
@@ -451,4 +450,4 @@ RSpec.shared_examples :at_usec do |usec|
|
|
451
450
|
end
|
452
451
|
end
|
453
452
|
|
454
|
-
Dir['./spec/features/*.rb'].each{ |rb| require rb }
|
453
|
+
Dir['./spec/features/*.rb'].each { |rb| require rb }
|
@@ -1,15 +1,19 @@
|
|
1
1
|
describe 'transformer_marshal_escape', proxy: :Transformer do
|
2
2
|
moneta_build do
|
3
3
|
Moneta.build do
|
4
|
-
use :Transformer, key: [:marshal, :escape], value: :marshal
|
4
|
+
use :Transformer, key: [:marshal, :escape], value: [:marshal, :escape]
|
5
5
|
adapter :Memory
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
|
+
moneta_loader do |value|
|
10
|
+
::Marshal.load(::URI.decode_www_form_component(value))
|
11
|
+
end
|
12
|
+
|
9
13
|
moneta_specs STANDARD_SPECS.without_persist
|
10
14
|
|
11
|
-
it '
|
15
|
+
it 'compiles the transformer class' do
|
12
16
|
store.should_not be_nil
|
13
|
-
Moneta::Transformer::
|
17
|
+
Moneta::Transformer::MarshalEscapeKeyMarshalEscapeValue.should_not be_nil
|
14
18
|
end
|
15
19
|
end
|
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.2.
|
4
|
+
version: 1.2.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: 2019-
|
14
|
+
date: 2019-11-08 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rspec
|
@@ -438,10 +438,14 @@ files:
|
|
438
438
|
- spec/restserver.rb
|
439
439
|
- test/action_dispatch/fixtures/session_autoload_test/foo.rb
|
440
440
|
- test/action_dispatch/session_moneta_store_test.rb
|
441
|
-
homepage:
|
441
|
+
homepage: https://github.com/moneta-rb/moneta
|
442
442
|
licenses:
|
443
443
|
- MIT
|
444
|
-
metadata:
|
444
|
+
metadata:
|
445
|
+
bug_tracker_uri: https://github.com/moneta-rb/moneta/issues
|
446
|
+
changelog_uri: https://github.com/moneta-rb/moneta/blob/v1.2.1/CHANGES
|
447
|
+
documentation_uri: https://www.rubydoc.info/gems/moneta/1.2.1
|
448
|
+
source_code_uri: https://github.com/moneta-rb/moneta/tree/v1.2.1
|
445
449
|
post_install_message:
|
446
450
|
rdoc_options: []
|
447
451
|
require_paths:
|