activerecord_cashier 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +17 -0
- data/Gemfile +20 -0
- data/LICENSE.txt +22 -0
- data/README.md +51 -0
- data/Rakefile +14 -0
- data/activerecord_cashier.gemspec +36 -0
- data/config.ru +7 -0
- data/lib/activerecord_cashier.rb +51 -0
- data/lib/activerecord_cashier/active_record_extension.rb +40 -0
- data/lib/activerecord_cashier/cashier_extension.rb +24 -0
- data/lib/activerecord_cashier/version.rb +3 -0
- data/spec/internal/app/controllers/application_controller.rb +3 -0
- data/spec/internal/app/models/page.rb +2 -0
- data/spec/internal/app/models/user.rb +2 -0
- data/spec/internal/config/database.yml +3 -0
- data/spec/internal/config/routes.rb +3 -0
- data/spec/internal/db/schema.rb +12 -0
- data/spec/internal/log/.gitignore +1 -0
- data/spec/internal/public/favicon.ico +0 -0
- data/spec/lib/activerecord_cashier/active_record_extension_spec.rb +118 -0
- data/spec/lib/activerecord_cashier/cashier_extension_spec.rb +42 -0
- data/spec/lib/activerecord_cashier_spec.rb +17 -0
- data/spec/spec_helper.rb +44 -0
- metadata +293 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: acf8585053c083898ea2b4962d0ba2440e7b933c
|
4
|
+
data.tar.gz: df3e77df0ec4cf4e9d5ce1c42155e343844c9793
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8b0d849db7eae49cefcc1264d72f18856a934a11fe9c5c275b5501b148fc95a275e9ad09988f9c0feaa8764d31a78279a73ea43f1483324ece4afec8f2fdd8b9
|
7
|
+
data.tar.gz: 2f0b726ee1170ae20513b9ca705cdee49a8f39b449677ef4c9a78f273be67a181f0c5d0b78fee1b0dcda7a51c7d8754114f97fbc17c9ca5ce854b3b617d54a64
|
data/.gitignore
ADDED
@@ -0,0 +1,20 @@
|
|
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
|
+
|
19
|
+
/spec/upstream_spec
|
20
|
+
/spec/internal/db/combustion_test.sqlite
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
cashier
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.0
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in activerecord_cashier.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
|
7
|
+
rails_version = ENV["RAILS_VERSION"] || "default"
|
8
|
+
|
9
|
+
rails = case rails_version
|
10
|
+
when "master"
|
11
|
+
{github: "rails/rails"}
|
12
|
+
when "default"
|
13
|
+
"~> 4.0.0"
|
14
|
+
when "pre"
|
15
|
+
'~> 4.1.0.beta1'
|
16
|
+
else
|
17
|
+
"~> #{rails_version}"
|
18
|
+
end
|
19
|
+
|
20
|
+
gem "rails", rails
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Alex Rozumey
|
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,51 @@
|
|
1
|
+
# ActiverecordCashier
|
2
|
+
|
3
|
+
[![Build Status](https://secure.travis-ci.org/brain-geek/activerecord_cashier.png?branch=master)][travis]
|
4
|
+
|
5
|
+
[gem]: https://rubygems.org/gems/activerecord_cashier
|
6
|
+
[travis]: http://travis-ci.org/brain-geek/activerecord_cashier
|
7
|
+
|
8
|
+
Automaticaly expires your cache entries triggered by ActiveRecord events.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
gem 'activerecord_cashier'
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install activerecord_cashier
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
After installation, you can specify strings, AR objects and classes as keys to trigger cache entry expiry.
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
cache 'newstand', :tag => [Article]
|
30
|
+
|
31
|
+
And then when you trigger save/create/destroy on any article, the cache expires.
|
32
|
+
|
33
|
+
You can also specify records as tags:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
cache 'newstand', :tag => [@article]
|
37
|
+
|
38
|
+
After any action on this article this cache entry then expire.
|
39
|
+
|
40
|
+
You can also trigger expiry on all article caches:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
Article.expire_all_cache
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
1. Fork it
|
48
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
50
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
51
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new('spec')
|
5
|
+
|
6
|
+
task :copy_upstream_spec do
|
7
|
+
source_dir = Gem.loaded_specs['cashier'].full_gem_path + '/spec/lib'
|
8
|
+
dst_dir = './spec/upstream_spec'
|
9
|
+
|
10
|
+
FileUtils.ln_s source_dir, dst_dir, :force => true
|
11
|
+
end
|
12
|
+
|
13
|
+
task :spec => :copy_upstream_spec
|
14
|
+
task :default => :spec
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'activerecord_cashier/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "activerecord_cashier"
|
8
|
+
spec.version = ActiverecordCashier::VERSION
|
9
|
+
spec.authors = ["Alex Rozumey"]
|
10
|
+
spec.email = ["brain-geek@yandex.ua"]
|
11
|
+
spec.description = %q{This gem extends cashier with possibility to add AR objects and classes as keys and automaticaly hook with AR to clean up this keys on object change/deletion}
|
12
|
+
spec.summary = %q{This gem extends cashier with AR integration}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
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 "cashier", "~> 0.4.1"
|
22
|
+
spec.add_dependency "activesupport", ">= 3.2.0"
|
23
|
+
spec.add_dependency "activerecord", ">= 3.2.0"
|
24
|
+
spec.add_dependency 'railties', '>= 3.2.0'
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency 'combustion', '~> 0.5.1'
|
28
|
+
spec.add_development_dependency "database_cleaner"
|
29
|
+
spec.add_development_dependency 'rspec-rails'
|
30
|
+
spec.add_development_dependency "pry"
|
31
|
+
spec.add_development_dependency "pry-nav"
|
32
|
+
spec.add_development_dependency "rails", ">= 3.2.0"
|
33
|
+
spec.add_development_dependency "sqlite3"
|
34
|
+
spec.add_development_dependency 'dalli'
|
35
|
+
spec.add_development_dependency 'redis', '~> 2.2.0'
|
36
|
+
end
|
data/config.ru
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require "activerecord_cashier/version"
|
2
|
+
|
3
|
+
module ActiverecordCashier
|
4
|
+
PREFIX = 'ar-cachier-'
|
5
|
+
DELIMITER = '+-'
|
6
|
+
|
7
|
+
class Railtie < ::Rails::Railtie
|
8
|
+
initializer "activerecord_cashier" do |app|
|
9
|
+
ActiveSupport.on_load(:active_record) do
|
10
|
+
::ActiveRecord::Base.send :include, ActiverecordCashier::ActiveRecordExtension
|
11
|
+
::Cashier.send :include, ActiverecordCashier::CashierExtension
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class << self
|
17
|
+
def morph(*tags)
|
18
|
+
tags.flatten!
|
19
|
+
|
20
|
+
tags.map do |tag|
|
21
|
+
if tag.is_a? String
|
22
|
+
tag
|
23
|
+
elsif tag.is_a? Class
|
24
|
+
PREFIX + tag.to_s
|
25
|
+
elsif tag.is_a?(ActiveRecord::Base)
|
26
|
+
"#{PREFIX}#{tag.class.to_s}#{DELIMITER}#{tag.try :id}"
|
27
|
+
end
|
28
|
+
end.flatten
|
29
|
+
end
|
30
|
+
|
31
|
+
def demorph(*tags)
|
32
|
+
tags.flatten!
|
33
|
+
|
34
|
+
tags.map do |tag|
|
35
|
+
if tag.index(PREFIX) == 0
|
36
|
+
parts = tag[PREFIX.length..-1].split(DELIMITER)
|
37
|
+
if parts.length == 1
|
38
|
+
parts.first.constantize
|
39
|
+
else parts.length == 2
|
40
|
+
parts.first.constantize.find_by_id(parts.last.to_i)
|
41
|
+
end
|
42
|
+
else
|
43
|
+
tag
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
require "activerecord_cashier/cashier_extension"
|
51
|
+
require "activerecord_cashier/active_record_extension"
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module ActiverecordCashier
|
2
|
+
module ActiveRecordExtension
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
def inherited(kls)
|
7
|
+
kls.send(:include, ActiverecordCashier::ActiveRecordModelExtension) if kls.superclass == ActiveRecord::Base
|
8
|
+
super
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
included do
|
13
|
+
# Existing subclasses pick up the model extension as well
|
14
|
+
self.descendants.each do |kls|
|
15
|
+
kls.send(:include, ActiverecordCashier::ActiveRecordModelExtension) if kls.superclass == ActiveRecord::Base
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module ActiveRecordModelExtension
|
21
|
+
extend ActiveSupport::Concern
|
22
|
+
|
23
|
+
included do
|
24
|
+
after_commit do |model|
|
25
|
+
Cashier.expire(model, model.class)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
module ClassMethods
|
30
|
+
def expire_all_cache
|
31
|
+
search_string = ActiverecordCashier::PREFIX + self.to_s + ActiverecordCashier::DELIMITER
|
32
|
+
|
33
|
+
# using both 'original' functions for performance - morph-demorph with SQL queries will take lot of time
|
34
|
+
Cashier.original_expire(*Cashier.original_tags.find_all{|key| key.index(search_string) == 0 })
|
35
|
+
|
36
|
+
Cashier.expire self
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module ActiverecordCashier
|
2
|
+
module CashierExtension
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
included do
|
5
|
+
class << self
|
6
|
+
alias_method :original_store_fragment, :store_fragment
|
7
|
+
alias_method :original_expire, :expire
|
8
|
+
alias_method :original_tags, :tags
|
9
|
+
|
10
|
+
def store_fragment(fragment, *tags)
|
11
|
+
original_store_fragment(fragment, *ActiverecordCashier.morph(*tags))
|
12
|
+
end
|
13
|
+
|
14
|
+
def expire(*tags)
|
15
|
+
original_expire(*ActiverecordCashier.morph(*tags))
|
16
|
+
end
|
17
|
+
|
18
|
+
def tags
|
19
|
+
ActiverecordCashier.demorph(original_tags)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
*.log
|
File without changes
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper.rb')
|
2
|
+
|
3
|
+
describe 'AR integration' do
|
4
|
+
subject { Rails.cache }
|
5
|
+
let(:adapter) { Cashier.adapter }
|
6
|
+
|
7
|
+
let(:page) { Page.create! name: 'first page'}
|
8
|
+
let(:other_page) { Page.create! name: 'other page'}
|
9
|
+
|
10
|
+
describe "on create" do
|
11
|
+
it "expires if tagged as class" do
|
12
|
+
subject.write('lorem', 'ip', tag: Page)
|
13
|
+
subject.read('lorem').should == 'ip'
|
14
|
+
|
15
|
+
Page.create!
|
16
|
+
|
17
|
+
subject.read('lorem').should be_nil
|
18
|
+
end
|
19
|
+
|
20
|
+
it "does not expire if created" do
|
21
|
+
subject.write('lorem', 'ipsum', tag: page)
|
22
|
+
subject.read('lorem').should == 'ipsum'
|
23
|
+
|
24
|
+
Page.create! name: 'third'
|
25
|
+
|
26
|
+
subject.read('lorem').should == 'ipsum'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "on update" do
|
31
|
+
it "expires if tagged as class" do
|
32
|
+
subject.write('lorem', 'ip', tag: Page)
|
33
|
+
subject.read('lorem').should == 'ip'
|
34
|
+
|
35
|
+
page.name = 'qwewq'
|
36
|
+
page.save!
|
37
|
+
|
38
|
+
subject.read('lorem').should be_nil
|
39
|
+
end
|
40
|
+
|
41
|
+
it "does not expire if other object touched" do
|
42
|
+
subject.write('lorem', 'ipsum', tag: page)
|
43
|
+
subject.read('lorem').should == 'ipsum'
|
44
|
+
|
45
|
+
other_page.name = 'qwewq'
|
46
|
+
other_page.save!
|
47
|
+
|
48
|
+
subject.read('lorem').should == 'ipsum'
|
49
|
+
end
|
50
|
+
|
51
|
+
it "does expire if this object is touched" do
|
52
|
+
subject.write('lorem', 'ipsum', tag: page)
|
53
|
+
subject.read('lorem').should == 'ipsum'
|
54
|
+
|
55
|
+
page.name = 'qwewq'
|
56
|
+
page.save!
|
57
|
+
|
58
|
+
subject.read('lorem').should be_nil
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "on delete" do
|
63
|
+
it "expires if tagged as class" do
|
64
|
+
subject.write('lorem', 'ip', tag: Page)
|
65
|
+
subject.read('lorem').should == 'ip'
|
66
|
+
|
67
|
+
page.destroy
|
68
|
+
|
69
|
+
subject.read('lorem').should be_nil
|
70
|
+
end
|
71
|
+
|
72
|
+
it "does not expire if other object touched" do
|
73
|
+
subject.write('lorem', 'ipsum', tag: page)
|
74
|
+
subject.read('lorem').should == 'ipsum'
|
75
|
+
|
76
|
+
other_page.destroy
|
77
|
+
|
78
|
+
subject.read('lorem').should == 'ipsum'
|
79
|
+
end
|
80
|
+
|
81
|
+
it "does expire if this object is touched" do
|
82
|
+
subject.write('lorem', 'ipsum', tag: page)
|
83
|
+
subject.read('lorem').should == 'ipsum'
|
84
|
+
|
85
|
+
page.destroy
|
86
|
+
|
87
|
+
subject.read('lorem').should be_nil
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "#expire_all as class method" do
|
92
|
+
it "deletes all tags for this class instances" do
|
93
|
+
subject.write("foo", "bar", :tag => [page])
|
94
|
+
subject.read('foo').should == 'bar'
|
95
|
+
|
96
|
+
Page.expire_all_cache
|
97
|
+
subject.read('foo').should be_nil
|
98
|
+
end
|
99
|
+
|
100
|
+
it "deletes everything marked as this class" do
|
101
|
+
subject.write("foo", "bar", :tag => Page)
|
102
|
+
|
103
|
+
subject.read('foo').should == 'bar'
|
104
|
+
|
105
|
+
Page.expire_all_cache
|
106
|
+
subject.read('foo').should be_nil
|
107
|
+
end
|
108
|
+
|
109
|
+
it "does not deletes other objects, same as strings, etc." do
|
110
|
+
subject.write("foo", "b", :tag => [User, 'page', 'Page', 'stuff', User.create!])
|
111
|
+
|
112
|
+
subject.read('foo').should == 'b'
|
113
|
+
|
114
|
+
Page.expire_all_cache
|
115
|
+
subject.read('foo').should == 'b'
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper.rb')
|
2
|
+
|
3
|
+
describe 'Cashier extension' do
|
4
|
+
subject { Rails.cache }
|
5
|
+
let(:adapter) { Cashier.adapter }
|
6
|
+
let(:page) { Page.create! }
|
7
|
+
|
8
|
+
describe "#expire" do
|
9
|
+
it "should work with AR model object as argument" do
|
10
|
+
subject.write("foo", "bar", :tag => [page])
|
11
|
+
|
12
|
+
subject.read('foo').should == 'bar'
|
13
|
+
Cashier.expire(Page.find page.id)
|
14
|
+
subject.read('foo').should be_nil
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should work with AR model class as argument" do
|
18
|
+
subject.write("foo", "bar", :tag => [Page])
|
19
|
+
|
20
|
+
subject.read('foo').should == 'bar'
|
21
|
+
Cashier.expire(Page)
|
22
|
+
subject.read('foo').should be_nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#tags" do
|
27
|
+
it "returns all tags" do
|
28
|
+
page
|
29
|
+
subject.write("foo0", "bar")
|
30
|
+
Cashier.tags.should be_empty
|
31
|
+
|
32
|
+
subject.write("foo1", "bar", tag: 'asdasd')
|
33
|
+
Cashier.tags.should =~ ['asdasd']
|
34
|
+
|
35
|
+
subject.write("foo2", "bar", tag: Page)
|
36
|
+
Cashier.tags.should =~ ['asdasd', Page]
|
37
|
+
|
38
|
+
subject.write("foo3", "bar", tag: [page, 'ewq'])
|
39
|
+
Cashier.tags.should =~ ['asdasd', Page, page, 'ewq']
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb')
|
2
|
+
|
3
|
+
describe ActiverecordCashier do
|
4
|
+
describe "#morph, #demorph" do
|
5
|
+
it "should morph AR objects to strings" do
|
6
|
+
source = [Page, Page.create!, 'page', 'page1', 'asdf']
|
7
|
+
subject.morph(source).any?{|a| a.is_a? String}.should be_true
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should be able to demorph objects correctly" do
|
11
|
+
source = [Page, Page.create!, 'page', 'page1', 'asdf']
|
12
|
+
|
13
|
+
#it does not lose anything after demorph. It may have some additional stuff
|
14
|
+
subject.demorph(subject.morph(source)).should include(*source)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
require 'combustion'
|
5
|
+
require 'cashier'
|
6
|
+
require 'redis'
|
7
|
+
require 'dalli'
|
8
|
+
require 'database_cleaner'
|
9
|
+
|
10
|
+
require 'pry'
|
11
|
+
require 'pry-nav'
|
12
|
+
|
13
|
+
Combustion.initialize! :all
|
14
|
+
|
15
|
+
require 'rspec/rails'
|
16
|
+
|
17
|
+
RSpec.configure do |config|
|
18
|
+
config.use_transactional_fixtures = false
|
19
|
+
|
20
|
+
config.before(:suite) do
|
21
|
+
DatabaseCleaner.strategy = :deletion
|
22
|
+
DatabaseCleaner.clean_with(:truncation)
|
23
|
+
end
|
24
|
+
|
25
|
+
config.before(:each) do
|
26
|
+
DatabaseCleaner.start
|
27
|
+
end
|
28
|
+
|
29
|
+
config.after(:each) do
|
30
|
+
DatabaseCleaner.clean
|
31
|
+
end
|
32
|
+
|
33
|
+
config.before(:suite) do
|
34
|
+
Cashier::Adapters::RedisStore.redis = Redis.new(:host => '127.0.0.1', :port => 6379)
|
35
|
+
end
|
36
|
+
|
37
|
+
config.before(:each) do
|
38
|
+
Cashier::Adapters::RedisStore.redis.flushdb
|
39
|
+
Rails.cache.clear
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
ApplicationController.perform_caching = true
|
44
|
+
Cashier.adapter = :redis_store
|
metadata
ADDED
@@ -0,0 +1,293 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: activerecord_cashier
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Rozumey
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: cashier
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.4.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.4.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.2.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.2.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activerecord
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.2.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.2.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: railties
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.2.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.2.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
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
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: combustion
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.5.1
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.5.1
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: database_cleaner
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rspec-rails
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: pry
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: pry-nav
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rails
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 3.2.0
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 3.2.0
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: sqlite3
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: dalli
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: redis
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - "~>"
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: 2.2.0
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - "~>"
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: 2.2.0
|
223
|
+
description: This gem extends cashier with possibility to add AR objects and classes
|
224
|
+
as keys and automaticaly hook with AR to clean up this keys on object change/deletion
|
225
|
+
email:
|
226
|
+
- brain-geek@yandex.ua
|
227
|
+
executables: []
|
228
|
+
extensions: []
|
229
|
+
extra_rdoc_files: []
|
230
|
+
files:
|
231
|
+
- ".gitignore"
|
232
|
+
- ".ruby-gemset"
|
233
|
+
- ".ruby-version"
|
234
|
+
- ".travis.yml"
|
235
|
+
- Gemfile
|
236
|
+
- LICENSE.txt
|
237
|
+
- README.md
|
238
|
+
- Rakefile
|
239
|
+
- activerecord_cashier.gemspec
|
240
|
+
- config.ru
|
241
|
+
- lib/activerecord_cashier.rb
|
242
|
+
- lib/activerecord_cashier/active_record_extension.rb
|
243
|
+
- lib/activerecord_cashier/cashier_extension.rb
|
244
|
+
- lib/activerecord_cashier/version.rb
|
245
|
+
- spec/internal/app/controllers/application_controller.rb
|
246
|
+
- spec/internal/app/models/page.rb
|
247
|
+
- spec/internal/app/models/user.rb
|
248
|
+
- spec/internal/config/database.yml
|
249
|
+
- spec/internal/config/routes.rb
|
250
|
+
- spec/internal/db/schema.rb
|
251
|
+
- spec/internal/log/.gitignore
|
252
|
+
- spec/internal/public/favicon.ico
|
253
|
+
- spec/lib/activerecord_cashier/active_record_extension_spec.rb
|
254
|
+
- spec/lib/activerecord_cashier/cashier_extension_spec.rb
|
255
|
+
- spec/lib/activerecord_cashier_spec.rb
|
256
|
+
- spec/spec_helper.rb
|
257
|
+
homepage: ''
|
258
|
+
licenses:
|
259
|
+
- MIT
|
260
|
+
metadata: {}
|
261
|
+
post_install_message:
|
262
|
+
rdoc_options: []
|
263
|
+
require_paths:
|
264
|
+
- lib
|
265
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
266
|
+
requirements:
|
267
|
+
- - ">="
|
268
|
+
- !ruby/object:Gem::Version
|
269
|
+
version: '0'
|
270
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
271
|
+
requirements:
|
272
|
+
- - ">="
|
273
|
+
- !ruby/object:Gem::Version
|
274
|
+
version: '0'
|
275
|
+
requirements: []
|
276
|
+
rubyforge_project:
|
277
|
+
rubygems_version: 2.1.11
|
278
|
+
signing_key:
|
279
|
+
specification_version: 4
|
280
|
+
summary: This gem extends cashier with AR integration
|
281
|
+
test_files:
|
282
|
+
- spec/internal/app/controllers/application_controller.rb
|
283
|
+
- spec/internal/app/models/page.rb
|
284
|
+
- spec/internal/app/models/user.rb
|
285
|
+
- spec/internal/config/database.yml
|
286
|
+
- spec/internal/config/routes.rb
|
287
|
+
- spec/internal/db/schema.rb
|
288
|
+
- spec/internal/log/.gitignore
|
289
|
+
- spec/internal/public/favicon.ico
|
290
|
+
- spec/lib/activerecord_cashier/active_record_extension_spec.rb
|
291
|
+
- spec/lib/activerecord_cashier/cashier_extension_spec.rb
|
292
|
+
- spec/lib/activerecord_cashier_spec.rb
|
293
|
+
- spec/spec_helper.rb
|