wallet 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +4 -1
- data/lib/wallet.rb +0 -1
- data/lib/wallet/wallet.rb +10 -4
- metadata +20 -9
data/README.rdoc
CHANGED
@@ -13,12 +13,15 @@ that could allow site administrators of your app to manage the TTL's from anywhe
|
|
13
13
|
|
14
14
|
To add wallet to your RAILS app, add a config.gem line like the following to the Rails::Initializer section of your environment.rb:
|
15
15
|
|
16
|
-
config.gem "wallet", :lib => 'wallet', :version => '>=0.0.
|
16
|
+
config.gem "wallet", :lib => 'wallet', :version => '>=0.0.3', :source => "http://gemcutter.org"
|
17
17
|
|
18
18
|
Then install the missing gem:
|
19
19
|
|
20
20
|
bash$ sudo rake gems:install
|
21
21
|
|
22
|
+
Lastly, create an initializer that conditionally loads wallet (e.g., RAILS_ROOT/initializers/wallet.rb)
|
23
|
+
|
24
|
+
Wallet.load_from_config # will load from RAILS_ROOT/config/wallet.yml by default.
|
22
25
|
|
23
26
|
==Usage
|
24
27
|
|
data/lib/wallet.rb
CHANGED
data/lib/wallet/wallet.rb
CHANGED
@@ -3,6 +3,14 @@
|
|
3
3
|
|
4
4
|
class Wallet
|
5
5
|
|
6
|
+
class << self
|
7
|
+
# Attempts to read and load the configuration file (RAILS_ROOT/config/wallet.yml by default)
|
8
|
+
def load_from_config(config_file=nil)
|
9
|
+
config_file = RAILS_ROOT + "/config/wallet.yml" unless config_file
|
10
|
+
new((File.open(config_file) rescue ""))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
6
14
|
# This error gets thrown whenever you attempt to retreive a TTL
|
7
15
|
# for an action that's not in the wallet.
|
8
16
|
class ActionNotCached < StandardError
|
@@ -108,13 +116,11 @@ class Wallet
|
|
108
116
|
|
109
117
|
def setup_action_caching
|
110
118
|
@config.each do |controller, actions|
|
111
|
-
|
112
|
-
|
119
|
+
controller_class = (controller + "_controller").camelize.constantize rescue nil
|
120
|
+
if controller_class
|
113
121
|
cached_actions(controller).each do |action|
|
114
122
|
controller_class.send :caches_action, action.to_sym, :expires_in => ttl(controller, action)
|
115
123
|
end
|
116
|
-
rescue Exception => e
|
117
|
-
#raise UnknownController.new("We're sorry, but the controller '#{(controller + "_controller").camelize}' does not exist in app/controllers/")
|
118
124
|
end
|
119
125
|
end
|
120
126
|
end
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wallet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 4
|
9
|
+
version: 0.0.4
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Matt Parker
|
@@ -9,19 +14,23 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-04-05 00:00:00 -04:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: rails
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 2
|
29
|
+
- 3
|
30
|
+
- 3
|
23
31
|
version: 2.3.3
|
24
|
-
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
25
34
|
description: Wallet is a rails gem that allows you to manage all of your action caching configuration in a single yaml file. Supports TTLs.
|
26
35
|
email: moonmaster9000@gmail.com
|
27
36
|
executables: []
|
@@ -47,18 +56,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
47
56
|
requirements:
|
48
57
|
- - ">="
|
49
58
|
- !ruby/object:Gem::Version
|
59
|
+
segments:
|
60
|
+
- 0
|
50
61
|
version: "0"
|
51
|
-
version:
|
52
62
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
63
|
requirements:
|
54
64
|
- - ">="
|
55
65
|
- !ruby/object:Gem::Version
|
66
|
+
segments:
|
67
|
+
- 0
|
56
68
|
version: "0"
|
57
|
-
version:
|
58
69
|
requirements: []
|
59
70
|
|
60
71
|
rubyforge_project:
|
61
|
-
rubygems_version: 1.3.
|
72
|
+
rubygems_version: 1.3.6
|
62
73
|
signing_key:
|
63
74
|
specification_version: 3
|
64
75
|
summary: Centralized YAML configuration for action caching.
|