partigi-partigirb 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -4,9 +4,8 @@ module Partigirb
4
4
  attr_accessor :id
5
5
  end
6
6
 
7
- #Raised by methods which call the API if a non-200 response status is received
7
+ # Raised by methods which call the API if a non-200 response status is received
8
8
  class PartigiError < StandardError
9
- attr_accessor :response_object
10
9
  end
11
10
 
12
11
  class Client
@@ -129,7 +128,7 @@ module Partigirb
129
128
 
130
129
  begin
131
130
  if res.code.to_i != 200
132
- handle_error_response(res, Partigirb::Handlers::XMLHandler)
131
+ handle_error_response(res, Partigirb::Handlers::XMLHandler.new)
133
132
  else
134
133
  fmt_handler.decode_response(res.body)
135
134
  end
@@ -138,9 +137,10 @@ module Partigirb
138
137
 
139
138
  # TODO: Test for errors
140
139
  def handle_error_response(res, handler)
141
- err = Partigirb::PartigiError.new
142
- err.response_object = handler.decode_response(res.body)
143
- raise err
140
+ # Response for errors is an XML document containing an error tag as a root,
141
+ # having a text node with error name. As XMLHandler starts building the Struct
142
+ # on root node the returned value from the handler will always be the error name text.
143
+ raise PartigiError.new(handler.decode_response(res.body))
144
144
  end
145
145
 
146
146
  def format_invocation?(name)
data/partigirb.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{partigirb}
5
- s.version = "0.2.1"
5
+ s.version = "0.2.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Alvaro Bautista", "Fernando Blat"]
9
- s.date = %q{2009-07-24}
9
+ s.date = %q{2009-07-27}
10
10
  s.email = ["alvarobp@gmail.com", "ferblape@gmail.com"]
11
11
  s.extra_rdoc_files = [
12
12
  "LICENSE",
data/test/client_test.rb CHANGED
@@ -174,6 +174,17 @@ class ClientTest < Test::Unit::TestCase
174
174
  @client.items.json
175
175
  end
176
176
 
177
+ should "raise a PartigiError with response error text as the message when http response codes are other than 200" do
178
+ client = new_client(400, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<error>Partigi::BadAPIRequestRequiredParams</error>\n")
179
+
180
+ begin
181
+ client.items.show.xml :id => 'madeup'
182
+ rescue Exception => e
183
+ assert e.is_a?(Partigirb::PartigiError)
184
+ assert_equal 'Partigi::BadAPIRequestRequiredParams', e.message
185
+ end
186
+ end
187
+
177
188
  # Copied from Grackle
178
189
  should "clear the request path on clear" do
179
190
  client = new_client(200,'[{"id":1,"text":"test 1"}]')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: partigi-partigirb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alvaro Bautista
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-07-24 00:00:00 -07:00
13
+ date: 2009-07-27 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
@@ -53,6 +53,7 @@ files:
53
53
  - test/xml_handler_test.rb
54
54
  has_rdoc: true
55
55
  homepage: http://github.com/partigi/partigirb
56
+ licenses:
56
57
  post_install_message:
57
58
  rdoc_options:
58
59
  - --charset=UTF-8
@@ -73,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
74
  requirements: []
74
75
 
75
76
  rubyforge_project:
76
- rubygems_version: 1.2.0
77
+ rubygems_version: 1.3.5
77
78
  signing_key:
78
79
  specification_version: 2
79
80
  summary: TODO