taggable_cache 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,16 @@
1
1
  language: ruby
2
2
  bundler_args: --without development
3
- before_install:
4
- - gem install bundler --pre
5
3
  rvm:
6
4
  - 1.9.3
7
5
  gemfile:
8
6
  - gemfiles/Gemfile-rails.3.1.x
9
7
  - gemfiles/Gemfile-rails.3.2.x
8
+ env:
9
+ - CACHE_STORE=redis
10
+ - CACHE_STORE=memcached
11
+ - CACHE_STORE=file_store
12
+ matrix:
13
+ exclude:
14
+ - rvm: 1.9.3
15
+ gemfile: gemfiles/Gemfile-rails.3.1.x
16
+ env: CACHE_STORE=redis
@@ -1,6 +1,10 @@
1
+ = Taggable cache 0.4.1
2
+
3
+ - Fixed support for redis cache store with rails 3.2
4
+
1
5
  = Taggable cache 0.4.0
2
6
 
3
7
  - Rewriten rails integration
4
8
  - Added README
5
9
  - Fix warnings
6
- - Redis configuration variables can be set by environment variables
10
+ - Redis configuration variables can be set by environment variables
data/Gemfile CHANGED
@@ -1,17 +1,12 @@
1
- source :rubygems
1
+ filename = File.expand_path(File.dirname(__FILE__)+"/gemfiles/Gemfile.shared")
2
+ eval(IO.read(filename), binding)
2
3
 
3
4
  gemspec
4
5
 
6
+ gem 'rails', '~> 3.2.0'
7
+ gem 'redis-rails', '~>3.2.3'
8
+
5
9
  group :development do
6
10
  gem 'pry'
7
11
  gem 'pry-nav'
8
- end
9
-
10
- gem 'rake'
11
- gem 'rspec-rails', :require => false
12
- gem 'rspec'
13
- gem 'capybara'
14
- gem 'combustion'
15
- gem 'sqlite3'
16
-
17
- gem 'rails', '~> 3.2.0'
12
+ end
@@ -1,13 +1,7 @@
1
- source :rubygems
1
+ filename = File.expand_path(File.dirname(__FILE__)+"/Gemfile.shared")
2
+ eval(IO.read(filename), binding)
2
3
 
3
4
  gem 'taggable_cache', :path => '..'
4
5
 
5
- gem 'rake'
6
- gem 'rspec-rails', :require => false
7
- gem 'rspec'
8
- gem 'capybara'
9
- gem 'combustion'
10
- gem 'sqlite3'
11
-
12
-
13
- gem 'rails', '~> 3.1.0'
6
+ gem 'rails', '~> 3.1.0'
7
+ gem 'redis-store', '~>1.1.0'
@@ -1,13 +1,7 @@
1
- source :rubygems
1
+ filename = File.expand_path(File.dirname(__FILE__)+"/Gemfile.shared")
2
+ eval(IO.read(filename), binding)
2
3
 
3
4
  gem 'taggable_cache', :path => '..'
4
5
 
5
- gem 'rake'
6
- gem 'rspec-rails', :require => false
7
- gem 'rspec'
8
- gem 'capybara'
9
- gem 'combustion'
10
- gem 'sqlite3'
11
-
12
-
13
- gem 'rails', '~> 3.2.0'
6
+ gem 'rails', '~> 3.2.0'
7
+ gem 'redis-rails', '~>3.2.3'
@@ -0,0 +1,10 @@
1
+ source :rubygems
2
+
3
+ gem 'rake'
4
+ gem 'rspec-rails', :require => false
5
+ gem 'rspec'
6
+ gem 'capybara'
7
+ gem 'combustion'
8
+ gem 'sqlite3'
9
+
10
+ gem 'memcache-client'
@@ -6,17 +6,17 @@ module TaggableCache
6
6
  def taggable
7
7
  @taggable ||= ::TaggableCache::Store.new
8
8
  end
9
-
10
- alias_method :original_write, :write
11
-
12
- def write(name, value, options = nil)
9
+
10
+ def write_with_taggable(name, value, options = nil)
13
11
  if !options.nil? && options.has_key?(:depends_on)
14
12
  add_tags(name, *options[:depends_on])
15
13
  end
16
14
 
17
- original_write(name, value, options)
15
+ write_without_taggable(name, value, options)
18
16
  end
19
17
 
18
+ alias_method_chain :write, :taggable
19
+
20
20
  def add_tags(key, *params)
21
21
  taggable.add(key, *params)
22
22
  end
@@ -5,8 +5,10 @@ module TaggableCache
5
5
  initializer "taggable_cache" do |app|
6
6
  ActiveSupport.on_load(:active_record) do
7
7
  ::ActiveRecord::Base.send :include, TaggableCache::ActiveRecordExtension
8
- ::ActiveSupport::Cache::Store.send :include, TaggableCache::CacheStoreExtension
9
8
  ::ActionController::Base.send :include, TaggableCache::ActionControllerExtension
9
+
10
+ ::ActiveSupport::Cache::Store.send :include, TaggableCache::CacheStoreExtension
11
+ ::ActiveSupport::Cache::RedisStore.send :include, TaggableCache::CacheStoreExtension if defined? ::ActiveSupport::Cache::RedisStore
10
12
  end
11
13
  end
12
14
  end
@@ -1,3 +1,3 @@
1
1
  module TaggableCache
2
- VERSION = "0.4.0" # This is for the gem and does not conflict with the rest of the functionality
2
+ VERSION = "0.4.1" # This is for the gem and does not conflict with the rest of the functionality
3
3
  end
@@ -20,7 +20,42 @@ describe 'TaggableCache::Rails::Cache' do
20
20
  it "does simple writes" do
21
21
  Rails.cache.write 'ipsum', 'lorem'
22
22
  Rails.cache.read('ipsum').should == 'lorem'
23
- end
23
+ end
24
+ end
25
+
26
+ describe "Rails.cache.fetch integration" do
27
+ it "adds key to store" do
28
+ Rails.cache.fetch('fetch_key', :depends_on => @page_object) do
29
+ 'value1'
30
+ end
31
+
32
+ @object.get(@page_object).should == ['fetch_key']
33
+ end
34
+
35
+ it "does simple expires" do
36
+ Rails.cache.fetch 'ftch_ipsum', :depends_on => @page_object do
37
+ 'lorem ipsum'
38
+ end
39
+
40
+ Rails.cache.read('ftch_ipsum').should == 'lorem ipsum'
41
+
42
+ @page_object.name = 'dfgsdgsdfgsdfg'
43
+ @page_object.save!
44
+
45
+ Rails.cache.read('ftch_ipsum').should be_nil
46
+ end
47
+
48
+ it "does class expires" do
49
+ Rails.cache.fetch 'ftch_ipsum2', :depends_on => Page do
50
+ 'lorem ipsum di'
51
+ end
52
+
53
+ Rails.cache.read('ftch_ipsum2').should == 'lorem ipsum di'
54
+
55
+ @page_object.save!
56
+
57
+ Rails.cache.read('ftch_ipsum2').should be_nil
58
+ end
24
59
  end
25
60
 
26
61
  describe "Activerecord integration" do
@@ -4,6 +4,16 @@ Bundler.require :default, :development
4
4
 
5
5
  require 'capybara/rspec'
6
6
 
7
+ class Combustion::Application
8
+ case ENV['CACHE_STORE']
9
+ when 'redis'
10
+ config.cache_store = :redis_store
11
+ when 'memcached'
12
+ config.cache_store = :mem_cache_store
13
+ when 'file_store'
14
+ end
15
+ end
16
+
7
17
  Combustion.initialize!
8
18
 
9
19
  require 'rspec/rails'
@@ -32,6 +32,6 @@ Gem::Specification.new do |s|
32
32
  s.add_dependency(%q<railties>, [">= 3.1.0"])
33
33
  s.add_dependency(%q<actionpack>, [">= 3.1.0"])
34
34
  s.add_dependency(%q<activerecord>, [">= 3.1.0"])
35
- s.add_dependency(%q<redis>, [">= 2.2.2"])
35
+ s.add_dependency(%q<redis>, [">= 2.2.0"])
36
36
  end
37
37
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taggable_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-02-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
16
- requirement: &77251570 !ruby/object:Gem::Requirement
16
+ requirement: &76511480 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.1.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *77251570
24
+ version_requirements: *76511480
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: actionpack
27
- requirement: &77251040 !ruby/object:Gem::Requirement
27
+ requirement: &76535640 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 3.1.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *77251040
35
+ version_requirements: *76535640
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: activerecord
38
- requirement: &77250480 !ruby/object:Gem::Requirement
38
+ requirement: &76533890 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,18 +43,18 @@ dependencies:
43
43
  version: 3.1.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *77250480
46
+ version_requirements: *76533890
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: redis
49
- requirement: &77249530 !ruby/object:Gem::Requirement
49
+ requirement: &76532140 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
- version: 2.2.2
54
+ version: 2.2.0
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *77249530
57
+ version_requirements: *76532140
58
58
  description: This gem simplifies cache expiration in rails
59
59
  email: brain-geek@yandex.ua
60
60
  executables: []
@@ -72,6 +72,7 @@ files:
72
72
  - Rakefile
73
73
  - gemfiles/Gemfile-rails.3.1.x
74
74
  - gemfiles/Gemfile-rails.3.2.x
75
+ - gemfiles/Gemfile.shared
75
76
  - lib/taggable_cache.rb
76
77
  - lib/taggable_cache/extensions.rb
77
78
  - lib/taggable_cache/railtie.rb
@@ -106,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
106
107
  version: '0'
107
108
  segments:
108
109
  - 0
109
- hash: 1067828559
110
+ hash: 648391631
110
111
  required_rubygems_version: !ruby/object:Gem::Requirement
111
112
  none: false
112
113
  requirements:
@@ -115,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
116
  version: '0'
116
117
  segments:
117
118
  - 0
118
- hash: 1067828559
119
+ hash: 648391631
119
120
  requirements: []
120
121
  rubyforge_project:
121
122
  rubygems_version: 1.8.10