erector_cache 0.0.6 → 0.0.7

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
@@ -0,0 +1,67 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{erector_cache}
8
+ s.version = "0.0.7"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Grockit"]
12
+ s.date = %q{2011-01-27}
13
+ s.description = %q{Caching for your Erector}
14
+ s.email = %q{mmol@grockit.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ "LICENSE",
23
+ "README",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "erector_cache.gemspec",
28
+ "lib/erector_cache.rb",
29
+ "lib/erector_cache/fragment.rb",
30
+ "lib/erector_cache/widget.rb",
31
+ "spec/erector_cache/fragment_spec.rb",
32
+ "spec/erector_cache/widget_spec.rb",
33
+ "spec/erector_cache_spec.rb",
34
+ "spec/spec.opts",
35
+ "spec/spec_helper.rb"
36
+ ]
37
+ s.homepage = %q{http://github.com/grockit/erector_cache}
38
+ s.require_paths = ["lib"]
39
+ s.rubygems_version = %q{1.3.7}
40
+ s.summary = %q{Caching for your Erector}
41
+ s.test_files = [
42
+ "spec/erector_cache/fragment_spec.rb",
43
+ "spec/erector_cache/widget_spec.rb",
44
+ "spec/erector_cache_spec.rb",
45
+ "spec/spec_helper.rb"
46
+ ]
47
+
48
+ if s.respond_to? :specification_version then
49
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
50
+ s.specification_version = 3
51
+
52
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
+ s.add_development_dependency(%q<rspec>, [">= 1.2.6"])
54
+ s.add_runtime_dependency(%q<lawnchair>, [">= 0.6.8"])
55
+ s.add_runtime_dependency(%q<erector>, ["= 0.8.1"])
56
+ else
57
+ s.add_dependency(%q<rspec>, [">= 1.2.6"])
58
+ s.add_dependency(%q<lawnchair>, [">= 0.6.8"])
59
+ s.add_dependency(%q<erector>, ["= 0.8.1"])
60
+ end
61
+ else
62
+ s.add_dependency(%q<rspec>, [">= 1.2.6"])
63
+ s.add_dependency(%q<lawnchair>, [">= 0.6.8"])
64
+ s.add_dependency(%q<erector>, ["= 0.8.1"])
65
+ end
66
+ end
67
+
@@ -26,25 +26,18 @@ module ErectorCache
26
26
 
27
27
  def expire!(hash={})
28
28
  hash = Hash.new("*").merge(hash)
29
- search_key = self.key_components.inject(["Lawnchair", self.to_s]) do |collection, part|
30
- p_prime = (part.is_a?(Hash) ? part.keys.first : part)
31
- collection << p_prime
32
- collection << if part.is_a?(Hash) && hash.keys.include?(p_prime)
33
- part[p_prime].call(hash[p_prime])
34
- else
35
- hash[p_prime].to_param
36
- end
37
- end.join(":")
38
-
29
+ search_key = "Lawnchair:"+cache_key(hash, true)
39
30
  LAWNCHAIR.redis.keys(search_key).each{|key| LAWNCHAIR.redis.del(key) }
40
31
  end
41
32
 
42
- def cache_key(hash)
33
+ def cache_key(hash, wildcard=false)
43
34
  self.key_components.inject([self.to_s]) do |collection, part|
44
- object = part.is_a?(Hash) ? hash[part.keys.first] : hash[part]
35
+ key = (part.is_a?(Hash) ? part.keys.first : part)
36
+ object = hash[key]
45
37
 
46
- if part.is_a?(Hash)
47
- key = part.keys.first
38
+ if wildcard && object == "*"
39
+ value = "*"
40
+ elsif part.is_a?(Hash)
48
41
  value = Array(part[key]).map do |p|
49
42
  if p.is_a?(Proc)
50
43
  p.call(object)
@@ -53,7 +46,6 @@ module ErectorCache
53
46
  end
54
47
  end.join("-")
55
48
  else
56
- key = part
57
49
  value = object.to_param
58
50
  end
59
51
  collection << [key, value]
@@ -38,7 +38,7 @@ class Weapon
38
38
  end
39
39
 
40
40
  class NinjaTurtle < Turtle
41
- cache_with :weapon, :master => lambda {|m| m.name }
41
+ cache_with :weapon, :master => [:to_param, lambda {|m| m.name }]
42
42
  cache_for 25.years
43
43
 
44
44
  def content
@@ -164,7 +164,7 @@ describe ErectorCache::Widget do
164
164
 
165
165
  it "builds a complex cache key" do
166
166
  widget = NinjaTurtle.new(:name => "Leonardo", :master => @splinter, :weapon => "Dual Katanas")
167
- widget.cache_key.should == "NinjaTurtle:name:Leonardo:weapon:Dual Katanas:master:Splinter"
167
+ widget.cache_key.should == "NinjaTurtle:name:Leonardo:weapon:Dual Katanas:master:Splinter-Splinter"
168
168
  end
169
169
  end
170
170
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erector_cache
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Grockit
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-18 00:00:00 -08:00
18
+ date: 2011-01-27 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -78,12 +78,12 @@ extra_rdoc_files:
78
78
  - README.rdoc
79
79
  files:
80
80
  - .document
81
- - .gitignore
82
81
  - LICENSE
83
82
  - README
84
83
  - README.rdoc
85
84
  - Rakefile
86
85
  - VERSION
86
+ - erector_cache.gemspec
87
87
  - lib/erector_cache.rb
88
88
  - lib/erector_cache/fragment.rb
89
89
  - lib/erector_cache/widget.rb
@@ -97,8 +97,8 @@ homepage: http://github.com/grockit/erector_cache
97
97
  licenses: []
98
98
 
99
99
  post_install_message:
100
- rdoc_options:
101
- - --charset=UTF-8
100
+ rdoc_options: []
101
+
102
102
  require_paths:
103
103
  - lib
104
104
  required_ruby_version: !ruby/object:Gem::Requirement
data/.gitignore DELETED
@@ -1,21 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC