undo-storage-redis 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 173eb280da9bbc07fd337b47d72de837c0549c0b
4
+ data.tar.gz: fc7db2f6c1a21f6a12a64533eaba77f83a5d5a36
5
+ SHA512:
6
+ metadata.gz: b00749a1fac3db944a75a8c41bb5d3afe04aa2d5385827141b18daf8baac72846b19abd8a5dee972fdaa71862eefdc87d8fd77bccfdc869e0ad710ccfdb47bb0
7
+ data.tar.gz: 7d51f298405c4cd8c74b4ee9c972b685dfa59d8ae54014c48fc26bdce03c39551a21a70eded4c2bb9b6b4bc2f9c26b8c044ba01126d116aa8a8a10ba052829f9
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ /tags
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --format documentation
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ undo-storage-redis
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.0-p0
data/.travis.yml ADDED
@@ -0,0 +1,19 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1
4
+ - 2.0
5
+ - 1.9.3
6
+ - ruby-head
7
+ - rbx
8
+ - jruby-19mode
9
+ - jruby-head
10
+
11
+ matrix:
12
+ allow_failures:
13
+ - rvm: ruby-head
14
+ - rvm: rbx
15
+ - rvm: jruby-19mode
16
+ - rvm: jruby-head
17
+
18
+ script:
19
+ - "bundle exec rake ci:all"
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in undo.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Alexander Paramonov
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ Undo
2
+ ==========
3
+ [![Build Status](https://travis-ci.org/AlexParamonov/undo-storage-redis.png?branch=master)](https://travis-ci.org/AlexParamonov/undo-storage-redis)
4
+ [![Gemnasium Build Status](https://gemnasium.com/AlexParamonov/undo-storage-redis.png)](http://gemnasium.com/AlexParamonov/undo-storage-redis)
5
+ [![Coverage Status](https://coveralls.io/repos/AlexParamonov/undo-storage-redis/badge.png?branch=master)](https://coveralls.io/r/AlexParamonov/undo-storage-redis?branch=master)
6
+ [![Gem Version](https://badge.fury.io/rb/undo-storage-redis.png)](http://badge.fury.io/rb/undo-storage-redis)
7
+
8
+ Redis storage adapter for Undo gem.
9
+
10
+ Contents
11
+ ---------
12
+ 1. Installation
13
+ 1. Requirements
14
+ 1. Contacts
15
+ 1. Compatibility
16
+ 1. Contributing
17
+ 1. Copyright
18
+
19
+ Installation
20
+ ------------
21
+
22
+ Add this line to your application's Gemfile:
23
+
24
+ gem 'undo-storage-redis'
25
+
26
+ And then execute:
27
+
28
+ $ bundle
29
+
30
+ Or install it yourself as:
31
+
32
+ $ gem install undo-storage-redis
33
+
34
+ Requirements
35
+ ------------
36
+ 1. Ruby 1.9 or above
37
+ 1. undo-serializer-null gem
38
+
39
+ Contacts
40
+ -------------
41
+ Have questions or recommendations? Contact me via `alexander.n.paramonov@gmail.com`
42
+ Found a bug or have enhancement request? You are welcome at [Github bugtracker](https://github.com/AlexParamonov/undo-storage-redis/issues)
43
+
44
+
45
+ Compatibility
46
+ -------------
47
+ tested with Ruby
48
+
49
+ * 2.1
50
+ * 2.0
51
+ * 1.9.3
52
+ * ruby-head
53
+ * rbx
54
+ * jruby-19mode
55
+ * jruby-head
56
+
57
+ See [build history](http://travis-ci.org/#!/AlexParamonov/undo-storage-redis/builds)
58
+
59
+
60
+ ## Contributing
61
+
62
+ 1. Fork repository ( http://github.com/AlexParamonov/undo-storage-redis/fork )
63
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
64
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
65
+ 4. Push to the branch (`git push origin my-new-feature`)
66
+ 5. Create new Pull Request
67
+
68
+ Copyright
69
+ ---------
70
+ Copyright © 2014 Alexander Paramonov.
71
+ Released under the MIT License. See the LICENSE file for further details.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+ namespace :ci do
5
+ desc "Run tests on CI"
6
+ RSpec::Core::RakeTask.new('all') do |t|
7
+ t.rspec_opts = '-fprogress'
8
+ t.verbose = true
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Undo
2
+ module Storage
3
+ class Redis
4
+ module Gemspec
5
+ VERSION = "0.0.1"
6
+ RUNNING_ON_CI = !!ENV['CI']
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,31 @@
1
+ require 'undo/serializer/null'
2
+
3
+ module Undo
4
+ module Storage
5
+ class Redis
6
+ def initialize(redis, options = {})
7
+ @redis = redis
8
+ @serializer = options[:serializer] || Undo::Serializer::Null.new
9
+ end
10
+
11
+ def put(uuid, object)
12
+ redis.set uuid, serialize(object)
13
+ end
14
+
15
+ def fetch(uuid)
16
+ deserialize redis.get(uuid)
17
+ end
18
+
19
+ private
20
+ attr_reader :redis, :serializer
21
+
22
+ def serialize(object)
23
+ serializer.to_json object
24
+ end
25
+
26
+ def deserialize(data)
27
+ serializer.from_json data
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,12 @@
1
+ if Undo::Storage::Redis::Gemspec::RUNNING_ON_CI
2
+ require 'coveralls'
3
+ Coveralls.wear!
4
+ else
5
+ require 'pry'
6
+ end
7
+
8
+ ENV['RAILS_ENV'] ||= 'test'
9
+ require 'rspec'
10
+ require 'undo/storage/redis'
11
+
12
+ $: << File.expand_path('../lib', File.dirname(__FILE__))
@@ -0,0 +1,35 @@
1
+ require "spec_helper_lite"
2
+
3
+ describe Undo::Storage::Redis do
4
+ let(:adapter) { described_class.new redis }
5
+ let(:redis) { double :redis }
6
+
7
+ it "writes string to redis" do
8
+ expect(redis).to receive(:set).with("hello", "world")
9
+ adapter.put "hello", "world"
10
+ end
11
+
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
34
+ end
35
+ end
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'undo/storage/redis/gemspec'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "undo-storage-redis"
8
+ spec.version = Undo::Storage::Redis::Gemspec::VERSION
9
+ spec.authors = ["Alexander Paramonov"]
10
+ spec.email = ["alexander.n.paramonov@gmail.com"]
11
+ spec.summary = %q{Redis storage adapter for Undo}
12
+ spec.description = %q{Redis storage adapter for Undo}
13
+ spec.homepage = "http://github.com/AlexParamonov/undo-storage-redis"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "undo-serializer-null", "~> 0.0.1"
22
+ spec.add_development_dependency "bundler", "~> 1.5"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "rspec", ">= 3.0.0.beta1"
25
+
26
+ if Undo::Storage::Redis::Gemspec::RUNNING_ON_CI
27
+ spec.add_development_dependency "coveralls"
28
+ else
29
+ spec.add_development_dependency "pry"
30
+ spec.add_development_dependency "pry-plus" if "ruby" == RUBY_ENGINE
31
+ end
32
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: undo-storage-redis
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Paramonov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-15 00:00:00.000000000 Z
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
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.0.beta1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 3.0.0.beta1
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry-plus
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Redis storage adapter for Undo
98
+ email:
99
+ - alexander.n.paramonov@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".coveralls.yml"
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - ".ruby-gemset"
108
+ - ".ruby-version"
109
+ - ".travis.yml"
110
+ - Gemfile
111
+ - LICENSE.txt
112
+ - README.md
113
+ - Rakefile
114
+ - lib/undo/storage/redis.rb
115
+ - lib/undo/storage/redis/gemspec.rb
116
+ - spec/spec_helper_lite.rb
117
+ - spec/undo/storage/redis_spec.rb
118
+ - undo-storage-redis.gemspec
119
+ homepage: http://github.com/AlexParamonov/undo-storage-redis
120
+ licenses:
121
+ - MIT
122
+ metadata: {}
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 2.2.2
140
+ signing_key:
141
+ specification_version: 4
142
+ summary: Redis storage adapter for Undo
143
+ test_files:
144
+ - spec/spec_helper_lite.rb
145
+ - spec/undo/storage/redis_spec.rb
146
+ has_rdoc: