erector_cache 0.0.7 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -18,29 +18,3 @@ begin
18
18
  rescue LoadError
19
19
  puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
20
  end
21
-
22
- require 'spec/rake/spectask'
23
- Spec::Rake::SpecTask.new(:spec) do |spec|
24
- spec.libs << 'lib' << 'spec'
25
- spec.spec_files = FileList['spec/**/*_spec.rb']
26
- end
27
-
28
- Spec::Rake::SpecTask.new(:rcov) do |spec|
29
- spec.libs << 'lib' << 'spec'
30
- spec.pattern = 'spec/**/*_spec.rb'
31
- spec.rcov = true
32
- end
33
-
34
- task :spec => :check_dependencies
35
-
36
- task :default => :spec
37
-
38
- require 'rake/rdoctask'
39
- Rake::RDocTask.new do |rdoc|
40
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
41
-
42
- rdoc.rdoc_dir = 'rdoc'
43
- rdoc.title = "erector_cache #{version}"
44
- rdoc.rdoc_files.include('README*')
45
- rdoc.rdoc_files.include('lib/**/*.rb')
46
- end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.7
1
+ 0.1.0
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{erector_cache}
8
- s.version = "0.0.7"
7
+ s.name = "erector_cache"
8
+ s.version = "0.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
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}
12
+ s.date = "2012-01-10"
13
+ s.description = "Caching for your Erector"
14
+ s.email = "mmol@grockit.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
17
  "README",
@@ -26,27 +26,20 @@ Gem::Specification.new do |s|
26
26
  "VERSION",
27
27
  "erector_cache.gemspec",
28
28
  "lib/erector_cache.rb",
29
+ "lib/erector_cache/abstract_widget.rb",
29
30
  "lib/erector_cache/fragment.rb",
30
- "lib/erector_cache/widget.rb",
31
31
  "spec/erector_cache/fragment_spec.rb",
32
32
  "spec/erector_cache/widget_spec.rb",
33
33
  "spec/erector_cache_spec.rb",
34
34
  "spec/spec.opts",
35
35
  "spec/spec_helper.rb"
36
36
  ]
37
- s.homepage = %q{http://github.com/grockit/erector_cache}
37
+ s.homepage = "http://github.com/grockit/erector_cache"
38
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
- ]
39
+ s.rubygems_version = "1.8.10"
40
+ s.summary = "Caching for your Erector"
47
41
 
48
42
  if s.respond_to? :specification_version then
49
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
50
43
  s.specification_version = 3
51
44
 
52
45
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
@@ -1,19 +1,21 @@
1
1
  module ErectorCache
2
- module Widget
2
+ module AbstractWidget
3
3
  def self.included(base)
4
4
  base.module_eval do
5
5
  cattr_accessor :expire_in
6
6
  extend ClassMethods
7
- class_inheritable_array :key_components
8
- class_inheritable_hash :interpolations
7
+ class_attribute :key_components
8
+ class_attribute :interpolations
9
9
  include InstanceMethods
10
- alias_method_chain :_render_via, :caching
10
+ alias_method_chain :_emit_via, :caching
11
11
  end
12
12
  end
13
13
 
14
14
  module ClassMethods
15
15
  def cache_with(*components)
16
16
  self.key_components = components
17
+ puts "Set key components: #{self.key_components.inspect}"
18
+ puts "Self: #{self.inspect}"
17
19
  end
18
20
 
19
21
  def interpolate(interpolations)
@@ -63,10 +65,14 @@ module ErectorCache
63
65
  return self.class.cache_key(key_data)
64
66
  end
65
67
 
66
- def _render_via_with_caching(parent, options={})
68
+ def _emit_via_with_caching(parent, options={})
69
+ puts "emit with key components: #{self.class.key_components.inspect}"
70
+ puts "Self.class: #{self.class.inspect}"
67
71
  if self.class.key_components.blank?
68
- _render_via_without_caching(parent, options)
72
+ puts "Erector#emit without caching"
73
+ _emit_via_without_caching(parent, options)
69
74
  else
75
+ puts "Erector#emit with caching"
70
76
  options = {:expire_in => @expire_in || 1.hour, :raw => true}
71
77
  unless self.class.interpolations.blank?
72
78
  options[:interpolate] = self.class.interpolations.inject({}) do |collection, interpolation|
@@ -76,13 +82,14 @@ module ErectorCache
76
82
  end
77
83
 
78
84
  cached_fragment = LAWNCHAIR.cache(cache_key, options) do
79
- parent.capture { _render_via_without_caching(parent, options) }
85
+ parent.capture { _emit_via_without_caching(parent, options) }
80
86
  end
81
- parent.output << cached_fragment
87
+ parent.output << cached_fragment.html_safe
82
88
  end
83
89
  end
84
90
  end
91
+
85
92
  end
86
93
  end
87
94
 
88
- Erector::Widget.send(:include, ErectorCache::Widget)
95
+ Erector::AbstractWidget.send(:include, ErectorCache::AbstractWidget)
data/lib/erector_cache.rb CHANGED
@@ -3,4 +3,4 @@ require 'action_controller'
3
3
  require 'erector'
4
4
  require 'erector/rails'
5
5
  require 'erector_cache/fragment'
6
- require 'erector_cache/widget'
6
+ require 'erector_cache/abstract_widget'
metadata CHANGED
@@ -1,82 +1,58 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: erector_cache
3
- version: !ruby/object:Gem::Version
4
- hash: 17
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 0
9
- - 7
10
- version: 0.0.7
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Grockit
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-01-27 00:00:00 -08:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2012-01-10 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: rspec
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2153457820 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 19
30
- segments:
31
- - 1
32
- - 2
33
- - 6
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
34
21
  version: 1.2.6
35
22
  type: :development
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: lawnchair
39
23
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *2153457820
25
+ - !ruby/object:Gem::Dependency
26
+ name: lawnchair
27
+ requirement: &2153457280 !ruby/object:Gem::Requirement
41
28
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 23
46
- segments:
47
- - 0
48
- - 6
49
- - 8
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
50
32
  version: 0.6.8
51
33
  type: :runtime
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: erector
55
34
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *2153457280
36
+ - !ruby/object:Gem::Dependency
37
+ name: erector
38
+ requirement: &2153456680 !ruby/object:Gem::Requirement
57
39
  none: false
58
- requirements:
59
- - - "="
60
- - !ruby/object:Gem::Version
61
- hash: 61
62
- segments:
63
- - 0
64
- - 8
65
- - 1
40
+ requirements:
41
+ - - =
42
+ - !ruby/object:Gem::Version
66
43
  version: 0.8.1
67
44
  type: :runtime
68
- version_requirements: *id003
45
+ prerelease: false
46
+ version_requirements: *2153456680
69
47
  description: Caching for your Erector
70
48
  email: mmol@grockit.com
71
49
  executables: []
72
-
73
50
  extensions: []
74
-
75
- extra_rdoc_files:
51
+ extra_rdoc_files:
76
52
  - LICENSE
77
53
  - README
78
54
  - README.rdoc
79
- files:
55
+ files:
80
56
  - .document
81
57
  - LICENSE
82
58
  - README
@@ -85,49 +61,35 @@ files:
85
61
  - VERSION
86
62
  - erector_cache.gemspec
87
63
  - lib/erector_cache.rb
64
+ - lib/erector_cache/abstract_widget.rb
88
65
  - lib/erector_cache/fragment.rb
89
- - lib/erector_cache/widget.rb
90
66
  - spec/erector_cache/fragment_spec.rb
91
67
  - spec/erector_cache/widget_spec.rb
92
68
  - spec/erector_cache_spec.rb
93
69
  - spec/spec.opts
94
70
  - spec/spec_helper.rb
95
- has_rdoc: true
96
71
  homepage: http://github.com/grockit/erector_cache
97
72
  licenses: []
98
-
99
73
  post_install_message:
100
74
  rdoc_options: []
101
-
102
- require_paths:
75
+ require_paths:
103
76
  - lib
104
- required_ruby_version: !ruby/object:Gem::Requirement
77
+ required_ruby_version: !ruby/object:Gem::Requirement
105
78
  none: false
106
- requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- hash: 3
110
- segments:
111
- - 0
112
- version: "0"
113
- required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
84
  none: false
115
- requirements:
116
- - - ">="
117
- - !ruby/object:Gem::Version
118
- hash: 3
119
- segments:
120
- - 0
121
- version: "0"
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
122
89
  requirements: []
123
-
124
90
  rubyforge_project:
125
- rubygems_version: 1.3.7
91
+ rubygems_version: 1.8.10
126
92
  signing_key:
127
93
  specification_version: 3
128
94
  summary: Caching for your Erector
129
- test_files:
130
- - spec/erector_cache/fragment_spec.rb
131
- - spec/erector_cache/widget_spec.rb
132
- - spec/erector_cache_spec.rb
133
- - spec/spec_helper.rb
95
+ test_files: []