railhead_cacheify 0.0.1

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/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 [name of plugin creator]
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,18 @@
1
+ = RailheadCacheify
2
+
3
+ RailheadCacheify is a Ruby on Rails plugin that helps caching model functions.
4
+
5
+ == Installation
6
+
7
+ Installation is available as gem (recommended):
8
+
9
+ config.gem 'railhead_cacheify'
10
+
11
+ Or as Rails plugin:
12
+
13
+ $ ruby script/plugin install git://github.com/nagybence/railhead_cacheify.git
14
+
15
+ == License
16
+
17
+ Copyright (c) 2010 Bence Nagy (nagybence@tipogral.hu), released under the MIT license.
18
+
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'railhead_cacheify'
@@ -0,0 +1,37 @@
1
+ require 'active_support'
2
+
3
+ module RailheadCacheify
4
+
5
+ def self.cache_store=(options)
6
+ @cache_store = ActiveSupport::Cache.lookup_store(options)
7
+ end
8
+
9
+ def self.cache
10
+ @cache_store ||= Rails.cache
11
+ end
12
+
13
+ def self.included(base)
14
+ base.extend ClassMethods
15
+ base.class_eval do
16
+ def read_cache(key, options = {}, &block)
17
+ RailheadCacheify.cache.fetch("#{key}:#{self.class.name}:#{self.id}", options) { yield }
18
+ end
19
+
20
+ def delete_cache(key)
21
+ RailheadCacheify.cache.delete("#{key}:#{self.class.name}:#{self.id}")
22
+ end
23
+ end
24
+ end
25
+
26
+ module ClassMethods
27
+ def cacheify(key, options = {})
28
+ class_eval <<-END
29
+ alias _original_#{key} #{key}
30
+ def #{key}(*args)
31
+ @#{key} ||= read_cache(:#{key}, #{options[:expires_in] ? "{:expires_in => #{options[:expires_in]}}" : '{}'}) { _original_#{key}(*args) }
32
+ end
33
+ END
34
+ end
35
+ end
36
+ end
37
+
@@ -0,0 +1,19 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "railhead_cacheify"
3
+ s.version = "0.0.1"
4
+ s.date = "2010-08-22"
5
+ s.summary = "RailheadCacheify is a Ruby on Rails plugin that helps caching model functions."
6
+ s.email = "nagybence@tipogral.hu"
7
+ s.homepage = "http://github.com/nagybence/railhead_cacheify"
8
+ s.description = "RailheadCacheify is a Ruby on Rails plugin that helps caching model functions."
9
+ s.has_rdoc = true
10
+ s.authors = ["Bence Nagy"]
11
+ s.files = ["MIT-LICENSE",
12
+ "README.rdoc",
13
+ "init.rb",
14
+ "railhead_cacheify.gemspec",
15
+ "lib/railhead_cacheify.rb"]
16
+ s.rdoc_options = ["--main", "README.rdoc"]
17
+ s.extra_rdoc_files = ["README.rdoc"]
18
+ end
19
+
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: railhead_cacheify
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Bence Nagy
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-08-22 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: RailheadCacheify is a Ruby on Rails plugin that helps caching model functions.
23
+ email: nagybence@tipogral.hu
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - README.rdoc
30
+ files:
31
+ - MIT-LICENSE
32
+ - README.rdoc
33
+ - init.rb
34
+ - railhead_cacheify.gemspec
35
+ - lib/railhead_cacheify.rb
36
+ has_rdoc: true
37
+ homepage: http://github.com/nagybence/railhead_cacheify
38
+ licenses: []
39
+
40
+ post_install_message:
41
+ rdoc_options:
42
+ - --main
43
+ - README.rdoc
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ hash: 3
52
+ segments:
53
+ - 0
54
+ version: "0"
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ requirements: []
65
+
66
+ rubyforge_project:
67
+ rubygems_version: 1.3.7
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: RailheadCacheify is a Ruby on Rails plugin that helps caching model functions.
71
+ test_files: []
72
+