gorilla-io 0.0.2 → 0.0.3

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: d81f3b00b56a0f598d6215b89eddde2e88ca53ff
4
- data.tar.gz: 4fdc39d52f36138d93c54e80781209e915348b67
3
+ metadata.gz: fe2b87763f37c0a5fdc8a90b7ccb83872134293c
4
+ data.tar.gz: 0df35fecf40ef70e23d91062509a297ead6057d1
5
5
  SHA512:
6
- metadata.gz: aade1e963137241b0491817d995fb51bb9dc8f5be68879b5539d5961ab7d65c6014f839664d857cfb3e5191db863b1ff101beae16f6579944a8f24fe5be46700
7
- data.tar.gz: fcfd40443e79fa8de248ba20a81350e7cbd2fe4a69827c3bec6c836b7fadccdc64f1d9c0c8cf31931174b96995777074c23299054f6869affb86f7adee27d949
6
+ metadata.gz: 71b73dee0f6550b9484ae677bad4179b19430339b659415e3e03fc492c1b8f27d9da655b53e57a0b501000904fb56fc0ec1614f79045c9b4db43d10f83abb630
7
+ data.tar.gz: 1681a19780b5ea4da359f2445c497bde2105e8221505c342c70492aeb9098a231b47d9e7d4db5c1435b1ba4cd3afe6b9d562a51940abb223ee61e6cea09c63bc
data/lib/gorilla/error.rb CHANGED
@@ -2,7 +2,7 @@ module Gorilla
2
2
  # Top-level error for rescuing all Gorilla Client errors
3
3
  class Error < StandardError
4
4
  def initialize(response)
5
- @response = response
5
+ @response = Gorilla::Response.new(response)
6
6
  end
7
7
  end
8
8
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Gorilla
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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
- c.client_adapter = Faraday::Adapter::Test::Stubs.new
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.2
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