gorilla-io 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/lib/gorilla/error.rb +1 -1
- data/lib/gorilla/response.rb +30 -0
- data/lib/gorilla/vanilla_client.rb +9 -5
- data/lib/gorilla/version.rb +1 -1
- data/lib/gorilla.rb +7 -2
- data/spec/lib/gorilla/vanilla_client_spec.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe2b87763f37c0a5fdc8a90b7ccb83872134293c
|
4
|
+
data.tar.gz: 0df35fecf40ef70e23d91062509a297ead6057d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71b73dee0f6550b9484ae677bad4179b19430339b659415e3e03fc492c1b8f27d9da655b53e57a0b501000904fb56fc0ec1614f79045c9b4db43d10f83abb630
|
7
|
+
data.tar.gz: 1681a19780b5ea4da359f2445c497bde2105e8221505c342c70492aeb9098a231b47d9e7d4db5c1435b1ba4cd3afe6b9d562a51940abb223ee61e6cea09c63bc
|
data/lib/gorilla/error.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
module Gorilla
|
2
|
+
class Response
|
3
|
+
|
4
|
+
attr_reader :response
|
5
|
+
|
6
|
+
def initialize(response)
|
7
|
+
@response = response
|
8
|
+
end
|
9
|
+
|
10
|
+
def body
|
11
|
+
response.body
|
12
|
+
end
|
13
|
+
|
14
|
+
def status
|
15
|
+
response.status
|
16
|
+
end
|
17
|
+
|
18
|
+
def success?
|
19
|
+
!error?
|
20
|
+
end
|
21
|
+
|
22
|
+
def error?
|
23
|
+
body[:error] != nil
|
24
|
+
end
|
25
|
+
|
26
|
+
def error
|
27
|
+
body[:error]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -11,24 +11,28 @@ module Gorilla
|
|
11
11
|
conn.request :json
|
12
12
|
yield(conn, options) if block_given?
|
13
13
|
conn.response :json, content_type: /\bjson$/
|
14
|
-
conn.adapter config.client_adapter
|
14
|
+
conn.adapter *config.client_adapter
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
def get(path, params={})
|
19
|
-
connection.get(path, params)
|
19
|
+
response = connection.get(path, params)
|
20
|
+
Response.new(response)
|
20
21
|
end
|
21
22
|
|
22
23
|
def post(path, params={})
|
23
|
-
connection.post(path, params)
|
24
|
+
response = connection.post(path, params)
|
25
|
+
Response.new(response)
|
24
26
|
end
|
25
27
|
|
26
28
|
def put(path, params={})
|
27
|
-
connection.put(path, params)
|
29
|
+
response = connection.put(path, params)
|
30
|
+
Response.new(response)
|
28
31
|
end
|
29
32
|
|
30
33
|
def delete(path, params={})
|
31
|
-
connection.delete(path, params)
|
34
|
+
response = connection.delete(path, params)
|
35
|
+
Response.new(response)
|
32
36
|
end
|
33
37
|
|
34
38
|
def config
|
data/lib/gorilla/version.rb
CHANGED
data/lib/gorilla.rb
CHANGED
@@ -5,6 +5,8 @@ require 'jwt'
|
|
5
5
|
|
6
6
|
require 'gorilla/version'
|
7
7
|
|
8
|
+
require 'gorilla/response'
|
9
|
+
|
8
10
|
require 'gorilla/error'
|
9
11
|
require 'gorilla/middleware/api_version'
|
10
12
|
require 'gorilla/middleware/user_agent'
|
@@ -19,7 +21,9 @@ module Gorilla
|
|
19
21
|
|
20
22
|
configurable api: %i{url version key secret token_duration}
|
21
23
|
configurable :user_agent
|
22
|
-
configurable :client_adapter
|
24
|
+
configurable :client_adapter do |value|
|
25
|
+
value.is_a?(Array) ? value : [value]
|
26
|
+
end
|
23
27
|
|
24
28
|
configuration_defaults do |c|
|
25
29
|
c.api.url = 'https://api.gorilla.io/'
|
@@ -34,7 +38,8 @@ module Gorilla
|
|
34
38
|
|
35
39
|
def self.testing!
|
36
40
|
configure do |c|
|
37
|
-
|
41
|
+
stubs = Faraday::Adapter::Test::Stubs.new
|
42
|
+
c.client_adapter = [:test, stubs]
|
38
43
|
end
|
39
44
|
end
|
40
45
|
|
@@ -41,7 +41,7 @@ RSpec.describe Gorilla::VanillaClient do
|
|
41
41
|
[:request, :user_agent, Gorilla.configuration.user_agent],
|
42
42
|
[:request, :json],
|
43
43
|
[:response, :json, content_type: /\bjson$/],
|
44
|
-
[:adapter, Gorilla.configuration.client_adapter]
|
44
|
+
[:adapter, *Gorilla.configuration.client_adapter].flatten
|
45
45
|
|
46
46
|
Gorilla::VanillaClient.new
|
47
47
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gorilla-io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gorilla.io
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- lib/gorilla/middleware/http_exceptions.rb
|
134
134
|
- lib/gorilla/middleware/signature_auth.rb
|
135
135
|
- lib/gorilla/middleware/user_agent.rb
|
136
|
+
- lib/gorilla/response.rb
|
136
137
|
- lib/gorilla/vanilla_client.rb
|
137
138
|
- lib/gorilla/version.rb
|
138
139
|
- spec/lib/gorilla/middleware/api_version_spec.rb
|