frenchy 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/frenchy/client.rb +14 -6
- data/lib/frenchy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1768f3f28fd292c1de91511b9d09e94a046a1ed
|
4
|
+
data.tar.gz: 3d4b3e33415b224e45ed8096d09f110c1fa7c8b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b6689a784c9d5c31679be44ffd0a38fc1998c943d83b3f095935340f855300469e0187b16bffba3e614222761dae8d836d2c53fc158653a262daaff813eaa53
|
7
|
+
data.tar.gz: b6dd11c48e61bae3ce1ecd9821863f1c56bf15246ea49b9b8bdb6738cfb80b86920ff4fe90228d4e1387e92ad0452032bf1a8070d3501e17b76414cfe5372e9f
|
data/lib/frenchy/client.rb
CHANGED
@@ -40,23 +40,31 @@ module Frenchy
|
|
40
40
|
def perform(method, path, params)
|
41
41
|
url = "#{@host}#{path}"
|
42
42
|
|
43
|
+
request = {
|
44
|
+
method: method.to_s.upcase,
|
45
|
+
url: url,
|
46
|
+
params: params
|
47
|
+
}
|
48
|
+
|
43
49
|
response = begin
|
44
50
|
HTTP.accept(:json).send(method, url, params: params).response
|
45
|
-
rescue
|
46
|
-
raise Frenchy::ServerError
|
51
|
+
rescue => exception
|
52
|
+
raise Frenchy::ServerError, {request: request, error: exception}
|
47
53
|
end
|
48
54
|
|
49
55
|
case response.code
|
50
56
|
when 200
|
51
57
|
begin
|
52
58
|
JSON.parse(response.body)
|
53
|
-
rescue
|
54
|
-
raise Frenchy::InvalidResponse
|
59
|
+
rescue => e
|
60
|
+
raise Frenchy::InvalidResponse, {request: request, error: exception, status: response.status, body: response.body}
|
55
61
|
end
|
56
62
|
when 404
|
57
|
-
|
63
|
+
body = JSON.parse(response.body) rescue response.body
|
64
|
+
raise Frenchy::NotFound, {request: request, status: response.status, body: body}
|
58
65
|
else
|
59
|
-
|
66
|
+
body = JSON.parse(response.body) rescue response.body
|
67
|
+
raise Frenchy::ServerError, {request: request, status: response.status, body: body}
|
60
68
|
end
|
61
69
|
end
|
62
70
|
|
data/lib/frenchy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frenchy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Coene
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|