undo-storage-redis 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 173eb280da9bbc07fd337b47d72de837c0549c0b
4
- data.tar.gz: fc7db2f6c1a21f6a12a64533eaba77f83a5d5a36
3
+ metadata.gz: 549a0450ed4ca059a8144453c6855aa148cb321a
4
+ data.tar.gz: 79d19a9e20f6ae4bca2346aae5ec48523074398a
5
5
  SHA512:
6
- metadata.gz: b00749a1fac3db944a75a8c41bb5d3afe04aa2d5385827141b18daf8baac72846b19abd8a5dee972fdaa71862eefdc87d8fd77bccfdc869e0ad710ccfdb47bb0
7
- data.tar.gz: 7d51f298405c4cd8c74b4ee9c972b685dfa59d8ae54014c48fc26bdce03c39551a21a70eded4c2bb9b6b4bc2f9c26b8c044ba01126d116aa8a8a10ba052829f9
6
+ metadata.gz: 3aa53ca7d0367071a980460ac8623dcfc93c3154b7a6b836aa2ceb3af1c6135fea9fb786a86c34facd991e037140144a566755d094e366764d37ad9a4ee9e4ab
7
+ data.tar.gz: 3fb24319908f8958888c23bd595c45674d851121e19a2110039eabdd1549c6bd555632f6065184f422ee73eecac4bcb8de2b11f4a7dafd5a615cffb21c169c2e
@@ -1,11 +1,10 @@
1
- require 'undo/serializer/null'
1
+ require 'json'
2
2
 
3
3
  module Undo
4
4
  module Storage
5
5
  class Redis
6
6
  def initialize(redis, options = {})
7
7
  @redis = redis
8
- @serializer = options[:serializer] || Undo::Serializer::Null.new
9
8
  end
10
9
 
11
10
  def put(uuid, object)
@@ -17,14 +16,14 @@ module Undo
17
16
  end
18
17
 
19
18
  private
20
- attr_reader :redis, :serializer
19
+ attr_reader :redis
21
20
 
22
21
  def serialize(object)
23
- serializer.to_json object
22
+ object.to_json
24
23
  end
25
24
 
26
25
  def deserialize(data)
27
- serializer.from_json data
26
+ JSON.parse data
28
27
  end
29
28
  end
30
29
  end
@@ -2,7 +2,7 @@ module Undo
2
2
  module Storage
3
3
  class Redis
4
4
  module Gemspec
5
- VERSION = "0.0.1"
5
+ VERSION = "0.0.2"
6
6
  RUNNING_ON_CI = !!ENV['CI']
7
7
  end
8
8
  end
@@ -7,6 +7,5 @@ end
7
7
 
8
8
  ENV['RAILS_ENV'] ||= 'test'
9
9
  require 'rspec'
10
- require 'undo/storage/redis'
11
10
 
12
11
  $: << File.expand_path('../lib', File.dirname(__FILE__))
@@ -1,35 +1,17 @@
1
1
  require "spec_helper_lite"
2
+ require 'undo/storage/redis'
2
3
 
3
4
  describe Undo::Storage::Redis do
4
5
  let(:adapter) { described_class.new redis }
5
6
  let(:redis) { double :redis }
6
7
 
7
- it "writes string to redis" do
8
- expect(redis).to receive(:set).with("hello", "world")
9
- adapter.put "hello", "world"
8
+ it "writes hash to redis" do
9
+ expect(redis).to receive(:set).with("123", '{"hello":"world"}')
10
+ adapter.put "123", "hello" => "world"
10
11
  end
11
12
 
12
- it "reads string from redis" do
13
- expect(redis).to receive(:get).with("hello") { "world" }
14
- expect(adapter.fetch "hello").to eq "world"
15
- end
16
-
17
- describe "use json serializer" do
18
- let(:adapter) { described_class.new redis, serializer: serializer }
19
- let(:serializer) do
20
- double :serializer,
21
- to_json: '{"hello":"world"}',
22
- from_json: { "hello" => "world" }
23
- end
24
-
25
- it "writes object to redis" do
26
- expect(redis).to receive(:set).with("123", '{"hello":"world"}')
27
- adapter.put "123", "hello" => "world"
28
- end
29
-
30
- it "reads object from redis" do
31
- expect(redis).to receive(:get).with("123") { '{"hello":"world"}' }
32
- expect(adapter.fetch "123").to eq "hello" => "world"
33
- end
13
+ it "reads hash from redis" do
14
+ expect(redis).to receive(:get).with("123") { '{"hello":"world"}' }
15
+ expect(adapter.fetch "123").to eq "hello" => "world"
34
16
  end
35
17
  end
@@ -18,7 +18,6 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "undo-serializer-null", "~> 0.0.1"
22
21
  spec.add_development_dependency "bundler", "~> 1.5"
23
22
  spec.add_development_dependency "rake"
24
23
  spec.add_development_dependency "rspec", ">= 3.0.0.beta1"
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: undo-storage-redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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-15 00:00:00.000000000 Z
11
+ date: 2014-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: undo-serializer-null
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 0.0.1
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 0.0.1
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: bundler
29
15
  requirement: !ruby/object:Gem::Requirement