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 +4 -4
- data/lib/popit/version.rb +1 -1
- data/lib/popit.rb +12 -6
- data/spec/popit_spec.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 288679ecd99d837bbce6221def9efc09ed239df6
|
4
|
+
data.tar.gz: 4ebff4b12ee6e79ce02635c66b5a27578c5bc315
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 742c8c9428d52ad353afef5e377c365022e5f003b3967ea2862df55b3e23fcc985b2911da387f1ba81663fe4e75103c00c6adc3cf23e9f59e4de7b90aa8bf1bd
|
7
|
+
data.tar.gz: 62e57d47b2e26309385a539dd2fee7b8184b3fa1a3947a5cb6e4d9296cc966e423b1103783daacb661ae32cd91066c8f72db46caff4c7c59be391bccc5ef850f
|
data/lib/popit/version.rb
CHANGED
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.
|
116
|
-
|
117
|
-
|
118
|
-
response.parsed_response['
|
119
|
-
|
120
|
-
|
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
|
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
|