undo-storage-redis 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/undo/storage/redis.rb +6 -5
- data/spec/undo/storage/redis_spec.rb +22 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8a882c3f5c0a35076305a12e0ac865a59c69154
|
4
|
+
data.tar.gz: 75bce602064d04e209fa91b6bbdee752e020b0da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c12060ce18bae507d6559fa1ee796a4a93245fd8cb76348d865711d382810ddd10dbb000f806de21d7e5caa2a1f0d4c5fc38b68030ec19096a8172ef518e9542
|
7
|
+
data.tar.gz: baaee65da3bf978c953acf6e6431550052002fb49b88540b43737e744ff9eb5ae1286ea21b51823747a9f525be5802aa370ecf64b151e7db5f95a6ef9f310c4e
|
data/lib/undo/storage/redis.rb
CHANGED
@@ -3,29 +3,30 @@ require 'json'
|
|
3
3
|
module Undo
|
4
4
|
module Storage
|
5
5
|
class Redis
|
6
|
-
VERSION = "0.0.
|
6
|
+
VERSION = "0.0.4"
|
7
7
|
|
8
8
|
def initialize(redis, options = {})
|
9
9
|
@redis = redis
|
10
|
+
@options = options
|
10
11
|
end
|
11
12
|
|
12
13
|
def put(uuid, object)
|
13
|
-
redis.set uuid, serialize(object)
|
14
|
+
redis.set uuid, serialize(object), options
|
14
15
|
end
|
15
16
|
|
16
17
|
def fetch(uuid)
|
17
|
-
deserialize redis.get
|
18
|
+
deserialize redis.get uuid, options
|
18
19
|
end
|
19
20
|
|
20
21
|
private
|
21
|
-
attr_reader :redis
|
22
|
+
attr_reader :redis, :options
|
22
23
|
|
23
24
|
def serialize(object)
|
24
25
|
object.to_json
|
25
26
|
end
|
26
27
|
|
27
28
|
def deserialize(data)
|
28
|
-
JSON.
|
29
|
+
JSON.load data
|
29
30
|
end
|
30
31
|
end
|
31
32
|
end
|
@@ -6,12 +6,32 @@ describe Undo::Storage::Redis do
|
|
6
6
|
let(:redis) { double :redis }
|
7
7
|
|
8
8
|
it "writes hash to redis" do
|
9
|
-
expect(redis).to receive(:set).with
|
9
|
+
expect(redis).to receive(:set).with "123", '{"hello":"world"}', anything
|
10
10
|
adapter.put "123", "hello" => "world"
|
11
11
|
end
|
12
12
|
|
13
13
|
it "reads hash from redis" do
|
14
|
-
expect(redis).to receive(:get).with("123") { '{"hello":"world"}' }
|
14
|
+
expect(redis).to receive(:get).with("123", anything) { '{"hello":"world"}' }
|
15
15
|
expect(adapter.fetch "123").to eq "hello" => "world"
|
16
16
|
end
|
17
|
+
|
18
|
+
describe "options" do
|
19
|
+
let(:adapter) { described_class.new redis, options }
|
20
|
+
let(:options) { { :additional => :option } }
|
21
|
+
|
22
|
+
it "sends provided options to redis.get" do
|
23
|
+
expect(redis).to receive(:get).with anything, options
|
24
|
+
adapter.fetch "foo"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "sends provided options to redis.set" do
|
28
|
+
expect(redis).to receive(:set).with anything, anything, options
|
29
|
+
adapter.put "foo", "bar"
|
30
|
+
end
|
31
|
+
|
32
|
+
before do
|
33
|
+
# JSON.load behaves differently in 1.9
|
34
|
+
allow(redis).to receive(:get).with(any_args) { { :foo => :bar }.to_json }
|
35
|
+
end if RUBY_VERSION < "2.0"
|
36
|
+
end
|
17
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: undo-storage-redis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Paramonov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|