api-client 1.8.2 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v1.9.0
4
+
5
+ * Added Requested Url to NotFound Exception message
6
+
3
7
  ## v1.8.2
4
8
 
5
9
  * Fixed Query String Bug (It was been sent empty)
@@ -4,7 +4,7 @@ class ApiClient::Exceptions::NotFound < ApiClient::Exceptions::Generic
4
4
  # Initialize a new exception.
5
5
  #
6
6
  # @return [NotFound] a new exception.
7
- def self.initialize
8
- super("The required url could not be found!")
7
+ def self.initialize(url)
8
+ super("The requested url (#{url}) could not be found!")
9
9
  end
10
- end
10
+ end
@@ -5,9 +5,9 @@ module ApiClient::Parser
5
5
  # Parse the JSON response.
6
6
  #
7
7
  # @param [HTTP] response HTTP object for the request.
8
- # @return [Array] the code and the body parsed.
8
+ # @return [Hash] the body parsed.
9
9
  def self.response(response)
10
- raise_exception(response.code)
10
+ raise_exception(response)
11
11
  begin
12
12
  object = ::JSON.parse(response.body)
13
13
  rescue ::JSON::ParserError, TypeError
@@ -18,11 +18,11 @@ module ApiClient::Parser
18
18
 
19
19
  protected
20
20
 
21
- def self.raise_exception(code)
22
- case code.to_i
21
+ def self.raise_exception(response)
22
+ case response.code.to_i
23
23
  when 401 then raise ApiClient::Exceptions::Unauthorized
24
24
  when 403 then raise ApiClient::Exceptions::Forbidden
25
- when 404 then raise ApiClient::Exceptions::NotFound
25
+ when 404 then raise ApiClient::Exceptions::NotFound.new(response.request.url)
26
26
  when 500 then raise ApiClient::Exceptions::InternalServerError
27
27
  when 502 then raise ApiClient::Exceptions::BadGateway
28
28
  when 503 then raise ApiClient::Exceptions::ServiceUnavailable
@@ -1,5 +1,5 @@
1
1
  # High Level Namespace of the library ApiClient.
2
2
  module ApiClient
3
3
  # Version of the library.
4
- VERSION = "1.8.2"
4
+ VERSION = "1.9.0"
5
5
  end
@@ -54,7 +54,7 @@ describe ApiClient::Parser do
54
54
  end
55
55
 
56
56
  it "should return a NotFound exception" do
57
- lambda { ApiClient::Parser.response(@response) }.should raise_error(ApiClient::Exceptions::NotFound)
57
+ lambda { ApiClient::Parser.response(@response) }.should raise_error(ApiClient::Exceptions::NotFound, "http://api.example.com/user/5")
58
58
  end
59
59
  end
60
60
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.2
4
+ version: 1.9.0
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-10-18 00:00:00.000000000 Z
12
+ date: 2012-10-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -165,12 +165,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
165
165
  - - ! '>='
166
166
  - !ruby/object:Gem::Version
167
167
  version: '0'
168
+ segments:
169
+ - 0
170
+ hash: 612713952861449012
168
171
  required_rubygems_version: !ruby/object:Gem::Requirement
169
172
  none: false
170
173
  requirements:
171
174
  - - ! '>='
172
175
  - !ruby/object:Gem::Version
173
176
  version: '0'
177
+ segments:
178
+ - 0
179
+ hash: 612713952861449012
174
180
  requirements: []
175
181
  rubyforge_project:
176
182
  rubygems_version: 1.8.24