garner 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -10,6 +10,8 @@ Usage
10
10
 
11
11
  Add Garner to Gemfile with `gem "garner"` and run `bundle install`. Include the Garner mixin into your API. Currently Grape is supported out of the box. It's also recommended to prevent clients from caching dynamic data by default using the `Garner::Middleware::Cache::Bust` middleware. See below for a detailed explanation.
12
12
 
13
+ Note that if you are using Grape, `gem "garner"` must be listed AFTER `gem "grape"` in the Gemfile (see [#6](https://github.com/artsy/garner/issues/6)).
14
+
13
15
  ```ruby
14
16
  class API < Grape::API
15
17
  use Garner::Middleware::Cache::Bust
@@ -136,7 +138,7 @@ This method of registration does need improvement, please contribute.
136
138
  Available Key Strategies
137
139
  ------------------------
138
140
 
139
- * `Garner::Strategies::Keys::Caller` inserts the calling file and line number, allowing multiple calls from the same function to generate different keys.
141
+ * `Garner::Strategies::Keys::Caller` inserts the calling file and line number, allowing multiple calls from the same function to generate different keys. The caller can be specified explicitly by passing a value for `:caller` in the requesting context.
140
142
  * `Garner::Strategies::Keys::Version` inserts the output of a `version` method, when available, primarily targeted at API implementations.
141
143
  * `Garner::Strategies::Keys::Key` inserts the value of `:key` within the requested context, useful to explicitly declare an element of a cache key.
142
144
  * `Garner::Strategies::Keys::RequestGet` inserts the value of HTTP request's GET parameters into the cache key when `:request` is present in the context.
@@ -99,12 +99,8 @@ module Garner
99
99
  end
100
100
 
101
101
  def reset_key_prefix_for(klass, object = nil)
102
- Garner.config.cache.write(
103
- index_string_for(klass, object),
104
- new_key_prefix_for(klass, object),
105
- {}
106
- )
107
- end
102
+ Garner.config.cache.delete(index_string_for(klass, object))
103
+ end
108
104
 
109
105
  def reset_cache_metadata(key, object)
110
106
  return unless object
@@ -11,11 +11,16 @@ module Garner
11
11
 
12
12
  def apply(key, context = {})
13
13
  rc = key ? key.dup : {}
14
+ if context.keys.include?(field)
15
+ rc[field] = context[field]
16
+ return rc
17
+ end
18
+
14
19
  caller.each do |line|
15
20
  split = line.split(":")
16
21
  next unless split.length >= 2
17
- path = Pathname.new(split[0]).realpath.to_s
18
- next if path.include?("lib/garner")
22
+ path = (Pathname.new(split[0]).realpath.to_s rescue nil)
23
+ next if path.blank? || path.include?("lib/garner")
19
24
  next unless path.include?("/app/") || path.include?("/spec/")
20
25
  rc[field] = "#{path}:#{split[1]}"
21
26
  break
@@ -1,3 +1,3 @@
1
1
  module Garner
2
- VERSION = '0.1.3'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: garner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-07-18 00:00:00.000000000Z
13
+ date: 2013-01-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
17
- requirement: &70261714866040 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,15 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70261714866040
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
26
31
  - !ruby/object:Gem::Dependency
27
32
  name: json
28
- requirement: &70261714865560 !ruby/object:Gem::Requirement
33
+ requirement: !ruby/object:Gem::Requirement
29
34
  none: false
30
35
  requirements:
31
36
  - - ! '>='
@@ -33,10 +38,15 @@ dependencies:
33
38
  version: '0'
34
39
  type: :runtime
35
40
  prerelease: false
36
- version_requirements: *70261714865560
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
37
47
  - !ruby/object:Gem::Dependency
38
48
  name: multi_json
39
- requirement: &70261714865080 !ruby/object:Gem::Requirement
49
+ requirement: !ruby/object:Gem::Requirement
40
50
  none: false
41
51
  requirements:
42
52
  - - ! '>='
@@ -44,10 +54,15 @@ dependencies:
44
54
  version: 1.3.0
45
55
  type: :runtime
46
56
  prerelease: false
47
- version_requirements: *70261714865080
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: 1.3.0
48
63
  - !ruby/object:Gem::Dependency
49
64
  name: activesupport
50
- requirement: &70261714864600 !ruby/object:Gem::Requirement
65
+ requirement: !ruby/object:Gem::Requirement
51
66
  none: false
52
67
  requirements:
53
68
  - - ! '>='
@@ -55,10 +70,15 @@ dependencies:
55
70
  version: '0'
56
71
  type: :runtime
57
72
  prerelease: false
58
- version_requirements: *70261714864600
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
59
79
  - !ruby/object:Gem::Dependency
60
80
  name: bundler
61
- requirement: &70261714864120 !ruby/object:Gem::Requirement
81
+ requirement: !ruby/object:Gem::Requirement
62
82
  none: false
63
83
  requirements:
64
84
  - - ! '>='
@@ -66,32 +86,47 @@ dependencies:
66
86
  version: '0'
67
87
  type: :development
68
88
  prerelease: false
69
- version_requirements: *70261714864120
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
70
95
  - !ruby/object:Gem::Dependency
71
96
  name: grape
72
- requirement: &70261714863640 !ruby/object:Gem::Requirement
97
+ requirement: !ruby/object:Gem::Requirement
73
98
  none: false
74
99
  requirements:
75
- - - =
100
+ - - '='
76
101
  - !ruby/object:Gem::Version
77
102
  version: 0.2.0
78
103
  type: :development
79
104
  prerelease: false
80
- version_requirements: *70261714863640
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 0.2.0
81
111
  - !ruby/object:Gem::Dependency
82
112
  name: rack-test
83
- requirement: &70261714863160 !ruby/object:Gem::Requirement
113
+ requirement: !ruby/object:Gem::Requirement
84
114
  none: false
85
115
  requirements:
86
- - - =
116
+ - - '='
87
117
  - !ruby/object:Gem::Version
88
118
  version: 0.6.1
89
119
  type: :development
90
120
  prerelease: false
91
- version_requirements: *70261714863160
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - '='
125
+ - !ruby/object:Gem::Version
126
+ version: 0.6.1
92
127
  - !ruby/object:Gem::Dependency
93
128
  name: rspec
94
- requirement: &70261714862680 !ruby/object:Gem::Requirement
129
+ requirement: !ruby/object:Gem::Requirement
95
130
  none: false
96
131
  requirements:
97
132
  - - ~>
@@ -99,43 +134,47 @@ dependencies:
99
134
  version: '2.10'
100
135
  type: :development
101
136
  prerelease: false
102
- version_requirements: *70261714862680
137
+ version_requirements: !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ~>
141
+ - !ruby/object:Gem::Version
142
+ version: '2.10'
103
143
  - !ruby/object:Gem::Dependency
104
144
  name: jeweler
105
- requirement: &70261714878560 !ruby/object:Gem::Requirement
145
+ requirement: !ruby/object:Gem::Requirement
106
146
  none: false
107
147
  requirements:
108
- - - =
148
+ - - '='
109
149
  - !ruby/object:Gem::Version
110
150
  version: 1.8.3
111
151
  type: :development
112
152
  prerelease: false
113
- version_requirements: *70261714878560
153
+ version_requirements: !ruby/object:Gem::Requirement
154
+ none: false
155
+ requirements:
156
+ - - '='
157
+ - !ruby/object:Gem::Version
158
+ version: 1.8.3
114
159
  - !ruby/object:Gem::Dependency
115
160
  name: mongoid
116
- requirement: &70261714878080 !ruby/object:Gem::Requirement
161
+ requirement: !ruby/object:Gem::Requirement
117
162
  none: false
118
163
  requirements:
119
164
  - - ~>
120
165
  - !ruby/object:Gem::Version
121
- version: '2.4'
166
+ version: '3.0'
122
167
  type: :development
123
168
  prerelease: false
124
- version_requirements: *70261714878080
125
- - !ruby/object:Gem::Dependency
126
- name: bson_ext
127
- requirement: &70261714877600 !ruby/object:Gem::Requirement
169
+ version_requirements: !ruby/object:Gem::Requirement
128
170
  none: false
129
171
  requirements:
130
172
  - - ~>
131
173
  - !ruby/object:Gem::Version
132
- version: '1.6'
133
- type: :development
134
- prerelease: false
135
- version_requirements: *70261714877600
174
+ version: '3.0'
136
175
  - !ruby/object:Gem::Dependency
137
176
  name: yard
138
- requirement: &70261714877120 !ruby/object:Gem::Requirement
177
+ requirement: !ruby/object:Gem::Requirement
139
178
  none: false
140
179
  requirements:
141
180
  - - ! '>='
@@ -143,10 +182,15 @@ dependencies:
143
182
  version: '0'
144
183
  type: :development
145
184
  prerelease: false
146
- version_requirements: *70261714877120
185
+ version_requirements: !ruby/object:Gem::Requirement
186
+ none: false
187
+ requirements:
188
+ - - ! '>='
189
+ - !ruby/object:Gem::Version
190
+ version: '0'
147
191
  - !ruby/object:Gem::Dependency
148
192
  name: redcarpet
149
- requirement: &70261714876640 !ruby/object:Gem::Requirement
193
+ requirement: !ruby/object:Gem::Requirement
150
194
  none: false
151
195
  requirements:
152
196
  - - ! '>='
@@ -154,10 +198,15 @@ dependencies:
154
198
  version: '0'
155
199
  type: :development
156
200
  prerelease: false
157
- version_requirements: *70261714876640
201
+ version_requirements: !ruby/object:Gem::Requirement
202
+ none: false
203
+ requirements:
204
+ - - ! '>='
205
+ - !ruby/object:Gem::Version
206
+ version: '0'
158
207
  - !ruby/object:Gem::Dependency
159
208
  name: github-markup
160
- requirement: &70261714876160 !ruby/object:Gem::Requirement
209
+ requirement: !ruby/object:Gem::Requirement
161
210
  none: false
162
211
  requirements:
163
212
  - - ! '>='
@@ -165,7 +214,12 @@ dependencies:
165
214
  version: '0'
166
215
  type: :development
167
216
  prerelease: false
168
- version_requirements: *70261714876160
217
+ version_requirements: !ruby/object:Gem::Requirement
218
+ none: false
219
+ requirements:
220
+ - - ! '>='
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
169
223
  description: Garner is a set of Rack middleware and cache helpers that implement various
170
224
  strategies.
171
225
  email: dblock@dblock.org
@@ -209,7 +263,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
209
263
  version: '0'
210
264
  segments:
211
265
  - 0
212
- hash: -3554335930431109647
266
+ hash: 840498015168322473
213
267
  required_rubygems_version: !ruby/object:Gem::Requirement
214
268
  none: false
215
269
  requirements:
@@ -218,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
272
  version: '0'
219
273
  requirements: []
220
274
  rubyforge_project:
221
- rubygems_version: 1.8.10
275
+ rubygems_version: 1.8.24
222
276
  signing_key:
223
277
  specification_version: 3
224
278
  summary: Garner is a set of Rack middleware and cache helpers that implement various