reviewed 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/faraday/cache.rb +5 -4
- data/lib/reviewed/version.rb +1 -1
- data/spec/faraday/cache_spec.rb +6 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa11a3952897f5b9ce559f830e1bfecc7e36f50d
|
4
|
+
data.tar.gz: 3eb8766f1d332ea87cf3d51432e1e990a96f0d39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa76c100e1ff5f150e03cc8a966828e7f5c13a3b675fed43aa2c71d65ef27d9baaea162c743c93b6a8186e02d889f23f7f838e193f643ecacd83bacdf9cc015b
|
7
|
+
data.tar.gz: 73ebf5077ebc656a42df42aaea07206473ce9560662514edd99dfcac291374c7e1aa9e96aa907fe7fca3b3f923b8fc0ac369a59f1368884c1f3780ab441ade9e
|
data/lib/faraday/cache.rb
CHANGED
@@ -16,11 +16,11 @@ module Faraday
|
|
16
16
|
|
17
17
|
@website_id = env[:request_headers]['x-reviewed-website']
|
18
18
|
|
19
|
-
if serve_from_cache && store.exist?(cache_key)
|
19
|
+
if serve_from_cache? && store.exist?(cache_key)
|
20
20
|
Hashie::Mash.new(Marshal.load( store.read(cache_key) ))
|
21
21
|
else
|
22
22
|
@app.call(env).on_complete do |response|
|
23
|
-
if store_response
|
23
|
+
if store_response?(response)
|
24
24
|
store.delete(cache_key)
|
25
25
|
store.write(cache_key, Marshal.dump(response), write_options)
|
26
26
|
end
|
@@ -30,11 +30,12 @@ module Faraday
|
|
30
30
|
|
31
31
|
private
|
32
32
|
|
33
|
-
def serve_from_cache
|
33
|
+
def serve_from_cache?
|
34
34
|
@url.query.blank? || !@url.query.match(/\b(skip|reset)-cache\b/)
|
35
35
|
end
|
36
36
|
|
37
|
-
def store_response
|
37
|
+
def store_response?(resp)
|
38
|
+
return false if resp[:status] != 200
|
38
39
|
@url.query.blank? || !@url.query.match(/\bskip-cache\b/)
|
39
40
|
end
|
40
41
|
|
data/lib/reviewed/version.rb
CHANGED
data/spec/faraday/cache_spec.rb
CHANGED
@@ -10,6 +10,7 @@ describe Faraday::Cache do
|
|
10
10
|
builder.adapter :test, Faraday::Adapter::Test::Stubs.new do |stub|
|
11
11
|
stub.get('/articles') { [200, {}, 'I like turtles'] }
|
12
12
|
stub.get('/products') { [200, {}, 'Weee products'] }
|
13
|
+
stub.get('/kaboom') { [500, {}, 'Kaboom'] }
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
@@ -40,6 +41,11 @@ describe Faraday::Cache do
|
|
40
41
|
resp[:body].should eq("old musty response")
|
41
42
|
end
|
42
43
|
|
44
|
+
it "does not store response when result is 500" do
|
45
|
+
Reviewed::Cache.store.should_not_receive(:write)
|
46
|
+
conn.get('/kaboom')
|
47
|
+
end
|
48
|
+
|
43
49
|
describe "cache busting and skipping" do
|
44
50
|
it "does not cache responses with skip-cache as a query param" do
|
45
51
|
Reviewed::Cache.store.should_not_receive(:read)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reviewed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Plante
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -312,7 +312,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
312
312
|
version: '0'
|
313
313
|
requirements: []
|
314
314
|
rubyforge_project:
|
315
|
-
rubygems_version: 2.0.
|
315
|
+
rubygems_version: 2.0.6
|
316
316
|
signing_key:
|
317
317
|
specification_version: 4
|
318
318
|
summary: A Ruby Gem for Accessing the Reviewed.com API
|