altmetric.rb 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/altmetric.rb +13 -12
- metadata +2 -2
data/lib/altmetric.rb
CHANGED
@@ -6,29 +6,30 @@ require 'uri_template'
|
|
6
6
|
module Altmetric
|
7
7
|
|
8
8
|
class APIException < RuntimeError
|
9
|
-
attr_reader :url, :query
|
10
|
-
def initialize(url, query,
|
11
|
-
super(
|
9
|
+
attr_reader :url, :query, :response
|
10
|
+
def initialize(url, query, response)
|
11
|
+
super(response.content)
|
12
12
|
@url = url
|
13
13
|
@query = query
|
14
|
+
@response = response
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
17
18
|
class UnknownArticleException < APIException
|
18
|
-
def initialize(url, query,
|
19
|
-
super(url, query,
|
19
|
+
def initialize(url, query, resp)
|
20
|
+
super(url, query, resp)
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
23
24
|
class UnauthorizedException < APIException
|
24
|
-
def initialize(url, query,
|
25
|
-
super(url, query,
|
25
|
+
def initialize(url, query, resp)
|
26
|
+
super(url, query, resp)
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
29
30
|
class RateLimitedException < APIException
|
30
|
-
def initialize(url, query,
|
31
|
-
super(url, query,
|
31
|
+
def initialize(url, query, resp)
|
32
|
+
super(url, query, resp)
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
@@ -155,11 +156,11 @@ module Altmetric
|
|
155
156
|
when 200
|
156
157
|
#OK
|
157
158
|
when 403
|
158
|
-
raise UnauthorizedException.new(url, query, response
|
159
|
+
raise UnauthorizedException.new(url, query, response)
|
159
160
|
when 404
|
160
|
-
raise UnknownArticleException.new(url, query, response
|
161
|
+
raise UnknownArticleException.new(url, query, response)
|
161
162
|
when 420
|
162
|
-
raise RateLimitedException.new(url, query, response
|
163
|
+
raise RateLimitedException.new(url, query, response)
|
163
164
|
else
|
164
165
|
raise APIException.new(url, query, response)
|
165
166
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: altmetric.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|