swd 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/lib/swd.rb +1 -1
- data/lib/swd/resource.rb +7 -4
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/lib/swd.rb
CHANGED
data/lib/swd/resource.rb
CHANGED
@@ -16,12 +16,11 @@ module SWD
|
|
16
16
|
self.send "#{key}=", attributes[key]
|
17
17
|
end
|
18
18
|
@path ||= '/.well-known/simple-web-discovery'
|
19
|
-
@cache_options = attributes[:cache] || {}
|
20
19
|
attr_missing!
|
21
20
|
end
|
22
21
|
|
23
|
-
def discover!
|
24
|
-
SWD.cache.fetch(cache_key,
|
22
|
+
def discover!(cache_options = {})
|
23
|
+
SWD.cache.fetch(cache_key, cache_options) do
|
25
24
|
handle_response do
|
26
25
|
HTTPClient.get_content endpoint.to_s
|
27
26
|
end
|
@@ -44,7 +43,7 @@ module SWD
|
|
44
43
|
if redirect = res[:SWD_service_redirect]
|
45
44
|
redirect_to redirect[:location], redirect[:expires]
|
46
45
|
else
|
47
|
-
|
46
|
+
to_response_object(res)
|
48
47
|
end
|
49
48
|
rescue HTTPClient::BadResponseError => e
|
50
49
|
case e.res.try(:status)
|
@@ -65,6 +64,10 @@ module SWD
|
|
65
64
|
raise Exception.new(e.message)
|
66
65
|
end
|
67
66
|
|
67
|
+
def to_response_object(hash)
|
68
|
+
Response.new hash
|
69
|
+
end
|
70
|
+
|
68
71
|
def redirect_to(location, expires)
|
69
72
|
uri = URI.parse(location)
|
70
73
|
@host, @path = uri.host, uri.path
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: swd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- nov matake
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-08-
|
13
|
+
date: 2011-08-20 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|