pinboard_rb 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
1
1
  module Pinboard
2
2
  class InvalidCredentialsError < StandardError; end
3
+ class TooManyRequestsError < StandardError; end
3
4
  end
@@ -16,13 +16,11 @@ module Pinboard
16
16
  @calls = []
17
17
 
18
18
  response = self.class.get("https://api.pinboard.in/v1/#{path}", :query => @params)
19
- parsed_response = response.parsed_response
20
19
 
21
- if parsed_response.kind_of?(String) && parsed_response.index('401 Forbidden')
22
- raise InvalidCredentialsError
23
- end
20
+ error = process_response_code(response.response.code)
21
+ raise error if error != nil
24
22
 
25
- parsed_response
23
+ response.parsed_response
26
24
  end
27
25
 
28
26
  def clear
@@ -44,5 +42,16 @@ module Pinboard
44
42
 
45
43
  self
46
44
  end
45
+
46
+ def process_response_code(response_code)
47
+ case response_code
48
+ when '401'
49
+ InvalidCredentialsError
50
+ when '429'
51
+ TooManyRequestsError
52
+ else
53
+ nil
54
+ end
55
+ end
47
56
  end
48
57
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pinboard_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
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: 2012-06-23 00:00:00.000000000 Z
12
+ date: 2012-06-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec