popit 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e0f5c6b92de48b6576028e879ce2ae23b648cbb
4
- data.tar.gz: a178baf6cc337d0c44be75e73cff15aabafbf9e3
3
+ metadata.gz: 288679ecd99d837bbce6221def9efc09ed239df6
4
+ data.tar.gz: 4ebff4b12ee6e79ce02635c66b5a27578c5bc315
5
5
  SHA512:
6
- metadata.gz: 91081f9cd938df6f9672cf45770e53007bea1067152d9e243d4e1ce5907840579dd68a092ada1cc6e32a7ef58fa03c0f1e8a6238bc9a18f14385f04a4b575274
7
- data.tar.gz: 72ed49a72f1890dbc10bfd1cbd03a8197376e1dda7b85d7305d033cde8416b01b3a886fdfdad88262061ff5986ae692d018ed1f33d70151ca4a2f5f542ade131
6
+ metadata.gz: 742c8c9428d52ad353afef5e377c365022e5f003b3967ea2862df55b3e23fcc985b2911da387f1ba81663fe4e75103c00c6adc3cf23e9f59e4de7b90aa8bf1bd
7
+ data.tar.gz: 62e57d47b2e26309385a539dd2fee7b8184b3fa1a3947a5cb6e4d9296cc966e423b1103783daacb661ae32cd91066c8f72db46caff4c7c59be391bccc5ef850f
data/lib/popit/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class PopIt
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/lib/popit.rb CHANGED
@@ -22,6 +22,7 @@ require 'httparty'
22
22
  class PopIt
23
23
  class Error < StandardError; end
24
24
  class PageNotFound < Error; end
25
+ class ServiceUnavailable < Error; end
25
26
  class NotAuthenticated < Error; end
26
27
 
27
28
  include HTTParty
@@ -112,16 +113,21 @@ private
112
113
  end
113
114
 
114
115
  unless ['200', '201', '204'].include?(response.response.code)
115
- message = if response.response.content_type == 'text/html'
116
- "HTTP #{response.response.code}"
117
- elsif response.parsed_response['error']
118
- response.parsed_response['error']
119
- elsif response.parsed_response['errors']
120
- response.parsed_response['errors'].join(', ')
116
+ message = if Hash === response.parsed_response
117
+ if response.parsed_response['error']
118
+ response.parsed_response['error']
119
+ elsif response.parsed_response['errors']
120
+ response.parsed_response['errors'].join(', ')
121
+ else
122
+ response.parsed_response
123
+ end
121
124
  else
122
125
  response.parsed_response
123
126
  end
127
+
124
128
  case response.response.code
129
+ when '503'
130
+ raise PopIt::ServiceUnavailable, message
125
131
  when '404'
126
132
  raise PopIt::PageNotFound, message
127
133
  when '401'
data/spec/popit_spec.rb CHANGED
@@ -20,7 +20,7 @@ describe PopIt do
20
20
 
21
21
  it 'should fail to send a request to a bad instance' do
22
22
  api = PopIt.new :instance_name => '47cc67093475061e3d95369d'
23
- expect { api.persons.get }.to raise_error(PopIt::PageNotFound, '404')
23
+ expect { api.persons.get }.to raise_error(PopIt::PageNotFound)
24
24
  end
25
25
 
26
26
  it 'should fail to send a request to a bad version' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: popit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Open North