undo-storage-rails_cache 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OTc4ZDI0OWYyN2ZlMDdjZjU4NWNmYWQxOTg4MjM1MGY1YTQyMDgyZQ==
5
+ data.tar.gz: !binary |-
6
+ NzIzMTMxODY0ODA1MGU5NjM4Y2UyMGJjMTdjNGRlYWE2ZTJhNmJiOQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NTY5OTVjMDA0YWM4NzU2Zjg0MGVkZGRhZmI4MTBlYTdhOTZlMDljM2Q3NjA0
10
+ MjAzNDlmMzY1MzQ2NzFmZDAwZWZmODdmZTdhYzhhZDNkZDE3YzRjMGRlZDJi
11
+ OGExMjhhY2E0NWVhN2Y1OTQ2NTU1OGY1NTlhMjg4NzE3OGJlYjE=
12
+ data.tar.gz: !binary |-
13
+ NTVhZmNkYzNiN2RiMGU0OGFmNGY2YjE3NmJhMTRlY2M0MDA1MjE2MDlhNjM4
14
+ M2Y3ODkxNDliMjgxYThjMzg4MDEyZmY3N2YzMTdmMzlkN2EyNWUyZWZmZTAw
15
+ YmI4NDk4MDdlNmIxNTg1OGQyZjZmNDJkNDM3ZjMxOWM0YmNlNjk=
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-rails_cache
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,18 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ group :test do
5
+ gem 'rails', '4.0.2'
6
+ if !!ENV['CI']
7
+ gem "coveralls"
8
+ else
9
+ gem "pry"
10
+ gem "pry-plus" if "ruby" == RUBY_ENGINE
11
+ end
12
+ end
13
+
14
+ platforms :rbx do
15
+ gem 'racc'
16
+ gem 'rubysl', '~> 2.0'
17
+ gem 'psych'
18
+ end
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,70 @@
1
+ Undo
2
+ ==========
3
+ [![Build Status](https://travis-ci.org/AlexParamonov/undo-storage-rails_cache.png?branch=master)](https://travis-ci.org/AlexParamonov/undo-storage-rails_cache)
4
+ [![Gemnasium Build Status](https://gemnasium.com/AlexParamonov/undo-storage-rails_cache.png)](http://gemnasium.com/AlexParamonov/undo-storage-rails_cache)
5
+ [![Coverage Status](https://coveralls.io/repos/AlexParamonov/undo-storage-rails_cache/badge.png?branch=master)](https://coveralls.io/r/AlexParamonov/undo-storage-rails_cache?branch=master)
6
+ [![Gem Version](https://badge.fury.io/rb/undo-storage-rails_cache.png)](http://badge.fury.io/rb/undo-storage-rails_cache)
7
+
8
+ Rails.cache 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-rails_cache'
25
+
26
+ And then execute:
27
+
28
+ $ bundle
29
+
30
+ Or install it yourself as:
31
+
32
+ $ gem install undo-storage-rails_cache
33
+
34
+ Requirements
35
+ ------------
36
+ 1. Ruby 1.9 or above
37
+
38
+ Contacts
39
+ -------------
40
+ Have questions or recommendations? Contact me via `alexander.n.paramonov@gmail.com`
41
+ Found a bug or have enhancement request? You are welcome at [Github bugtracker](https://github.com/AlexParamonov/undo-storage-rails_cache/issues)
42
+
43
+
44
+ Compatibility
45
+ -------------
46
+ tested with Ruby
47
+
48
+ * 2.1
49
+ * 2.0
50
+ * 1.9.3
51
+ * ruby-head
52
+ * rbx
53
+ * jruby-19mode
54
+ * jruby-head
55
+
56
+ See [build history](http://travis-ci.org/#!/AlexParamonov/undo-storage-rails_cache/builds)
57
+
58
+
59
+ ## Contributing
60
+
61
+ 1. Fork repository ( http://github.com/AlexParamonov/undo-storage-rails_cache/fork )
62
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
63
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
64
+ 4. Push to the branch (`git push origin my-new-feature`)
65
+ 5. Create new Pull Request
66
+
67
+ Copyright
68
+ ---------
69
+ Copyright © 2014 Alexander Paramonov.
70
+ 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,34 @@
1
+ require 'json'
2
+
3
+ module Undo
4
+ module Storage
5
+ class RailsCache
6
+ VERSION = "0.0.1"
7
+
8
+ def initialize(cache = nil, options = {})
9
+ @cache = cache
10
+ @cache ||= Rails.cache if defined? Rails
11
+ @options = options
12
+ end
13
+
14
+ def put(uuid, object)
15
+ cache.write uuid, serialize(object), options
16
+ end
17
+
18
+ def fetch(uuid)
19
+ deserialize cache.read uuid, options
20
+ end
21
+
22
+ private
23
+ attr_reader :cache, :options
24
+
25
+ def serialize(object)
26
+ object.to_json
27
+ end
28
+
29
+ def deserialize(data)
30
+ JSON.load data
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,4 @@
1
+ .bundle
2
+ db/*.sqlite3
3
+ log/*.log
4
+ tmp/
@@ -0,0 +1,7 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+ require 'rake'
6
+
7
+ RailsApp::Application.load_tasks
@@ -0,0 +1,13 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require "rails/all"
4
+
5
+ # If you have a Gemfile, require the gems listed there, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require(:default, Rails.env) if defined?(Bundler)
8
+
9
+ module RailsApp
10
+ class Application < Rails::Application
11
+ I18n.enforce_available_locales = false
12
+ end
13
+ end
@@ -0,0 +1,6 @@
1
+ require 'rubygems'
2
+
3
+ # Set up gems listed in the Gemfile.
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
5
+
6
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ RailsApp::Application.initialize!
@@ -0,0 +1,35 @@
1
+ RailsApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_store = :memory_store
9
+ config.cache_classes = true
10
+ config.eager_load = false
11
+
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Raise exceptions instead of rendering exception templates
17
+ config.action_dispatch.show_exceptions = false
18
+
19
+ # Disable request forgery protection in test environment
20
+ config.action_controller.allow_forgery_protection = false
21
+
22
+ # Tell Action Mailer not to deliver emails to the real world.
23
+ # The :test delivery method accumulates sent emails in the
24
+ # ActionMailer::Base.deliveries array.
25
+ config.action_mailer.delivery_method = :test
26
+ config.action_mailer.default_url_options = { :host => 'www.example.com' }
27
+
28
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
29
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
30
+ # like if you have constraints or database-specific column types
31
+ # config.active_record.schema_format = :sql
32
+
33
+ # Print deprecation notices to the stderr
34
+ config.active_support.deprecation = :stderr
35
+ end
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run RailsApp::Application
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,11 @@
1
+ if !!ENV['CI']
2
+ require 'coveralls'
3
+ Coveralls.wear!
4
+ else
5
+ require 'pry'
6
+ end
7
+
8
+ ENV['RAILS_ENV'] ||= 'test'
9
+ require 'rspec'
10
+
11
+ $: << File.expand_path('../lib', File.dirname(__FILE__))
@@ -0,0 +1,11 @@
1
+ if !!ENV['CI']
2
+ require 'coveralls'
3
+ Coveralls.wear!
4
+ else
5
+ require 'pry'
6
+ end
7
+
8
+ ENV['RAILS_ENV'] ||= 'test'
9
+
10
+ require File.expand_path('../rails_app/config/environment', __FILE__)
11
+ require 'rspec'
@@ -0,0 +1,20 @@
1
+ require "spec_helper_rails"
2
+
3
+ describe Undo::Storage::RailsCache do
4
+ it "uses Rails.cache by default" do
5
+ adapter = described_class.new
6
+ expect(Rails.cache).to receive :write
7
+ adapter.put "foo", "bar"
8
+ end
9
+
10
+ it "stores object in cache" do
11
+ adapter = described_class.new
12
+ adapter.put "123", "hello" => "world"
13
+ expect(adapter.fetch "123").to eq "hello" => "world"
14
+ end
15
+
16
+ it "sends params correctly" do
17
+ adapter = described_class.new Rails.cache, expires_in: 1.second
18
+ expect { adapter.put "foo", "bar" }.not_to raise_error
19
+ end
20
+ end
@@ -0,0 +1,41 @@
1
+ require "spec_helper_lite"
2
+ require 'undo/storage/rails_cache'
3
+
4
+ describe Undo::Storage::RailsCache do
5
+ let(:adapter) { described_class.new cache }
6
+ let(:cache) { double :cache }
7
+
8
+ it "writes hash to cache as json" do
9
+ expect(cache).to receive(:write).with("123", '{"hello":"world"}', anything)
10
+ adapter.put "123", "hello" => "world"
11
+ end
12
+
13
+ it "reads hash from cache" do
14
+ expect(cache).to receive(:read).with("123", anything) { '{"hello":"world"}' }
15
+ expect(adapter.fetch "123").to eq "hello" => "world"
16
+ end
17
+
18
+ it "does not raise when created without arguments" do
19
+ expect { described_class.new }.not_to raise_error
20
+ end
21
+
22
+ describe "options" do
23
+ let(:adapter) { described_class.new cache, options }
24
+ let(:options) { Hash.new }
25
+
26
+ it "sends provided options to cache.read" do
27
+ expect(cache).to receive(:read).with any_args, options
28
+ adapter.fetch "foo"
29
+ end
30
+
31
+ it "sends provided options to cache.write" do
32
+ expect(cache).to receive(:write).with any_args, options
33
+ adapter.put "foo", "bar"
34
+ end
35
+
36
+ before do
37
+ # JSON.load behaves differently in 1.9
38
+ allow(cache).to receive(:read).with(any_args) { { :foo => :bar }.to_json }
39
+ end if RUBY_VERSION < "2.0"
40
+ end
41
+ end
@@ -0,0 +1,24 @@
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/rails_cache'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "undo-storage-rails_cache"
8
+ spec.version = Undo::Storage::RailsCache::VERSION
9
+ spec.authors = ["Alexander Paramonov"]
10
+ spec.email = ["alexander.n.paramonov@gmail.com"]
11
+ spec.summary = %q{Rails.cache storage adapter for Undo}
12
+ spec.description = %q{Rails.cache storage adapter for Undo}
13
+ spec.homepage = "http://github.com/AlexParamonov/undo-storage-rails_cache"
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_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec", ">= 3.0.0.beta1"
24
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: undo-storage-rails_cache
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-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 3.0.0.beta1
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 3.0.0.beta1
55
+ description: Rails.cache storage adapter for Undo
56
+ email:
57
+ - alexander.n.paramonov@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .coveralls.yml
63
+ - .gitignore
64
+ - .rspec
65
+ - .ruby-gemset
66
+ - .ruby-version
67
+ - .travis.yml
68
+ - Gemfile
69
+ - LICENSE.txt
70
+ - README.md
71
+ - Rakefile
72
+ - lib/undo/storage/rails_cache.rb
73
+ - spec/rails_app/.gitignore
74
+ - spec/rails_app/Rakefile
75
+ - spec/rails_app/config.ru
76
+ - spec/rails_app/config/application.rb
77
+ - spec/rails_app/config/boot.rb
78
+ - spec/rails_app/config/environment.rb
79
+ - spec/rails_app/config/environments/test.rb
80
+ - spec/rails_app/script/rails
81
+ - spec/spec_helper_lite.rb
82
+ - spec/spec_helper_rails.rb
83
+ - spec/undo/storage/rails_cache_integration_spec.rb
84
+ - spec/undo/storage/rails_cache_spec.rb
85
+ - undo-storage-rails_cache.gemspec
86
+ homepage: http://github.com/AlexParamonov/undo-storage-rails_cache
87
+ licenses:
88
+ - MIT
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.2.2
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Rails.cache storage adapter for Undo
110
+ test_files:
111
+ - spec/rails_app/.gitignore
112
+ - spec/rails_app/Rakefile
113
+ - spec/rails_app/config.ru
114
+ - spec/rails_app/config/application.rb
115
+ - spec/rails_app/config/boot.rb
116
+ - spec/rails_app/config/environment.rb
117
+ - spec/rails_app/config/environments/test.rb
118
+ - spec/rails_app/script/rails
119
+ - spec/spec_helper_lite.rb
120
+ - spec/spec_helper_rails.rb
121
+ - spec/undo/storage/rails_cache_integration_spec.rb
122
+ - spec/undo/storage/rails_cache_spec.rb
123
+ has_rdoc: