almodovar 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
1
  module Almodovar
2
- class HttpError < Exception; end
3
- end
2
+ class HttpError < Exception
3
+ def initialize(response, url)
4
+ super("Status code #{response.status} on resource #{url}")
5
+ end
6
+ end
7
+ end
@@ -3,7 +3,7 @@ module Almodovar
3
3
  def xml
4
4
  @xml ||= begin
5
5
  response = http.get(url_with_params)
6
- check_errors(response)
6
+ check_errors(response, url_with_params)
7
7
  Nokogiri::XML.parse(response.body).root
8
8
  end
9
9
  end
@@ -29,8 +29,8 @@ module Almodovar
29
29
  end
30
30
  end
31
31
 
32
- def check_errors(response)
33
- raise(Almodovar::HttpError, "Status code: #{response.status}") if response.status >= 400
32
+ def check_errors(response, url)
33
+ raise(Almodovar::HttpError.new(response, url)) if response.status >= 400
34
34
  end
35
35
  end
36
36
 
@@ -15,7 +15,7 @@ module Almodovar
15
15
  raise ArgumentError.new("You must specify one only root element which is the type of resource (e.g. `:project => { :name => 'Wadus' }` instead of just `:name => 'Wadus'`)") if attrs.size > 1
16
16
  root, body = attrs.first
17
17
  response = http.post(url_with_params, body.to_xml(:root => root, :convert_links => true, :skip_links_one_level => true), "Content-Type" => "application/xml")
18
- check_errors(response)
18
+ check_errors(response, url_with_params)
19
19
  Resource.new(nil, @auth, Nokogiri::XML.parse(response.body).root)
20
20
  end
21
21
 
@@ -16,12 +16,12 @@ module Almodovar
16
16
  raise ArgumentError.new("You must specify one only root element which is the type of resource (e.g. `:project => { :name => 'Wadus' }` instead of just `:name => 'Wadus'`)") if attrs.size > 1
17
17
  root, body = attrs.first
18
18
  response = http.put(@url, body.to_xml(:root => root), :content_type => "application/xml")
19
- check_errors(response)
19
+ check_errors(response, @url)
20
20
  @xml = Nokogiri::XML.parse(response.body).root
21
21
  end
22
22
 
23
23
  def delete
24
- check_errors(http.delete(@url))
24
+ check_errors(http.delete(@url), @url)
25
25
  end
26
26
 
27
27
  def url
@@ -1,3 +1,3 @@
1
1
  module Almodovar
2
- VERSION = '0.9.2'
2
+ VERSION = '0.9.3'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: almodovar
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
4
+ hash: 61
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 2
10
- version: 0.9.2
9
+ - 3
10
+ version: 0.9.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - BeBanjo S.L.