cachy 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,7 +1,6 @@
1
1
  source :rubygems
2
2
  gemspec
3
3
 
4
- group :development do
5
- gem 'rake'
6
- gem 'rspec', '~>2'
7
- end
4
+ gem 'bump'
5
+ gem 'rake'
6
+ gem 'rspec', '~>2'
@@ -1,28 +1,30 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cachy (0.3.0)
4
+ cachy (0.3.1)
5
5
  mini_memory_store
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
+ bump (0.3.8)
10
11
  diff-lcs (1.1.3)
11
12
  mini_memory_store (0.1.0)
12
- rake (0.9.2.2)
13
- rspec (2.9.0)
14
- rspec-core (~> 2.9.0)
15
- rspec-expectations (~> 2.9.0)
16
- rspec-mocks (~> 2.9.0)
17
- rspec-core (2.9.0)
18
- rspec-expectations (2.9.0)
13
+ rake (10.0.3)
14
+ rspec (2.12.0)
15
+ rspec-core (~> 2.12.0)
16
+ rspec-expectations (~> 2.12.0)
17
+ rspec-mocks (~> 2.12.0)
18
+ rspec-core (2.12.2)
19
+ rspec-expectations (2.12.1)
19
20
  diff-lcs (~> 1.1.3)
20
- rspec-mocks (2.9.0)
21
+ rspec-mocks (2.12.1)
21
22
 
22
23
  PLATFORMS
23
24
  ruby
24
25
 
25
26
  DEPENDENCIES
27
+ bump
26
28
  cachy!
27
29
  rake
28
30
  rspec (~> 2)
data/Rakefile CHANGED
@@ -1,22 +1,7 @@
1
+ require 'bundler/setup'
1
2
  require 'bundler/gem_tasks'
3
+ require 'bump/tasks'
2
4
 
3
5
  task :default do
4
6
  sh "rspec spec/"
5
7
  end
6
-
7
- # extracted from https://github.com/grosser/project_template
8
- rule /^version:bump:.*/ do |t|
9
- sh "git status | grep 'nothing to commit'" # ensure we are not dirty
10
- index = ['major', 'minor','patch'].index(t.name.split(':').last)
11
- file = 'lib/cachy/version.rb'
12
-
13
- version_file = File.read(file)
14
- old_version, *version_parts = version_file.match(/(\d+)\.(\d+)\.(\d+)/).to_a
15
- version_parts[index] = version_parts[index].to_i + 1
16
- version_parts[2] = 0 if index < 2 # remove patch for minor
17
- version_parts[1] = 0 if index < 1 # remove minor for major
18
- new_version = version_parts * '.'
19
- File.open(file,'w'){|f| f.write(version_file.sub(old_version, new_version)) }
20
-
21
- sh "bundle && git add #{file} Gemfile.lock && git commit -m 'bump version to #{new_version}'"
22
- end
@@ -60,7 +60,8 @@ module Cachy
60
60
  end * "_"
61
61
 
62
62
  key = (options[:hash_key] || hash_keys) ? hash(key) : key
63
- (options[:prefix].to_s + key + options[:suffix].to_s).gsub(' ', '_')
63
+ my_prefix = (options[:prefix] || prefix).to_s
64
+ (my_prefix + key + options[:suffix].to_s).gsub(' ', '_')
64
65
  end
65
66
 
66
67
  # Expire all possible locales of a cache, use the same arguments as with cache
@@ -111,6 +112,7 @@ module Cachy
111
112
 
112
113
  class << self
113
114
  attr_accessor :hash_keys
115
+ attr_accessor :prefix
114
116
  end
115
117
 
116
118
  # Wrap non ActiveSupport style cache stores,
@@ -1,3 +1,3 @@
1
1
  module Cachy
2
- Version = VERSION = '0.3.0'
2
+ Version = VERSION = '0.3.1'
3
3
  end
@@ -1,6 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Cachy do
4
+
5
+ def reset_cachy!
6
+ Cachy.prefix = nil
7
+ Cachy.hash_keys = false
8
+ end
9
+
4
10
  before do
5
11
  @cache = TestCache.new
6
12
  Cachy.cache_store = @cache
@@ -9,6 +15,10 @@ describe Cachy do
9
15
  Cachy.send(:memory_store).clear
10
16
  end
11
17
 
18
+ after do
19
+ reset_cachy!
20
+ end
21
+
12
22
  describe :cache do
13
23
  it "caches" do
14
24
  Cachy.cache(:my_key){ "X" }.should == "X"
@@ -173,15 +183,26 @@ describe Cachy do
173
183
  key.should == "x_v1_de"
174
184
  end
175
185
 
186
+ describe :prefix do
187
+ it "uses prefix, if set with Cachy.prefix = ..." do
188
+ user = mock(:cache_key=>'XXX',:something_else=>'YYY')
189
+ Cachy.prefix = "cachy_"
190
+ Cachy.key(:my_key, 1, user, "abc").should == 'cachy_my_key_1_XXX_abc_v1'
191
+ end
192
+
193
+ it "can be overridden by :prefix => ... option" do
194
+ user = mock(:cache_key=>'XXX',:something_else=>'YYY')
195
+ Cachy.prefix = "cachy_"
196
+ Cachy.key(:my_key, 1, user, "abc", :prefix => "special_prefix_").should_not == 'cachy_my_key_1_XXX_abc_v1'
197
+ Cachy.key(:my_key, 1, user, "abc", :prefix => "special_prefix_").should == 'special_prefix_my_key_1_XXX_abc_v1'
198
+ end
199
+ end
200
+
176
201
  describe "with :hash_key" do
177
202
  before do
178
203
  @hash = '3b2b8f418849bc73071375529f8515be'
179
204
  end
180
205
 
181
- after do
182
- Cachy.hash_keys = false
183
- end
184
-
185
206
  it "hashed the key to a stable value" do
186
207
  Cachy.key(:xxx, :hash_key=>true).should == @hash
187
208
  end
metadata CHANGED
@@ -1,45 +1,38 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: cachy
3
- version: !ruby/object:Gem::Version
4
- hash: 19
3
+ version: !ruby/object:Gem::Version
5
4
  prerelease:
6
- segments:
7
- - 0
8
- - 3
9
- - 0
10
- version: 0.3.0
5
+ version: 0.3.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Michael Grosser
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-03-29 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-12-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ none: false
21
21
  prerelease: false
22
- requirement: &id001 !ruby/object:Gem::Requirement
22
+ name: mini_memory_store
23
+ requirement: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ! '>='
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
23
28
  none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- hash: 3
28
- segments:
29
- - 0
30
- version: "0"
31
29
  type: :runtime
32
- name: mini_memory_store
33
- version_requirements: *id001
34
30
  description:
35
31
  email: michael@grosser.it
36
32
  executables: []
37
-
38
33
  extensions: []
39
-
40
34
  extra_rdoc_files: []
41
-
42
- files:
35
+ files:
43
36
  - .travis.yml
44
37
  - Gemfile
45
38
  - Gemfile.lock
@@ -62,37 +55,34 @@ files:
62
55
  - spec/spec_helper.rb
63
56
  - spec/test_cache.rb
64
57
  homepage: http://github.com/grosser/cachy
65
- licenses:
58
+ licenses:
66
59
  - MIT
67
60
  post_install_message:
68
61
  rdoc_options: []
69
-
70
- require_paths:
62
+ require_paths:
71
63
  - lib
72
- required_ruby_version: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- hash: 3
78
- segments:
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ segments:
79
70
  - 0
80
- version: "0"
81
- required_rubygems_version: !ruby/object:Gem::Requirement
71
+ hash: 966047757035435948
82
72
  none: false
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- hash: 3
87
- segments:
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ segments:
88
79
  - 0
89
- version: "0"
80
+ hash: 966047757035435948
81
+ none: false
90
82
  requirements: []
91
-
92
83
  rubyforge_project:
93
- rubygems_version: 1.8.15
84
+ rubygems_version: 1.8.24
94
85
  signing_key:
95
86
  specification_version: 3
96
87
  summary: Caching library for projects that have many processes or many caches
97
88
  test_files: []
98
-