vertebrae 1.0.1 → 1.0.4

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
  SHA256:
3
- metadata.gz: 12abd176ae617d57fb896828dc31331db3e1d0fad69afbfae446096e2347f409
4
- data.tar.gz: eef8c6ef2349430d071ba10c66797f2d1c73094a224da831a4c20fe1cf6d5b21
3
+ metadata.gz: 30786cc1ab2fa6f4d9f8e268f4815de51f7d5054a98cdae1989070e1804946aa
4
+ data.tar.gz: 03a1316928f1a52ce36163207b9170f79340edda31c63fcaca030bb6aa89d029
5
5
  SHA512:
6
- metadata.gz: 9ce84790ba0a4982e968146a50295aa97265bc160a0358127ebabb09ff0aaa21b4eb21f005435393d1637feebc26a26a3862d3dc23eb983cbd64305e1da9ffae
7
- data.tar.gz: 899944270224b32549f430c66f09ae5a30d460e0557c01148947a3273656f2b199ade90fefd7e11af292b05c39f83c0d523ebd861870f199f5e458db1e59adf5
6
+ metadata.gz: e74729c49769b94026a591f9dcc99dc0518ded6c1e24ef55bf7f987b5b2c57750c5965e8dc740c11aac7d1f1cd33c9402ca0f3734b0cccb7c48ae7f63b72b64d
7
+ data.tar.gz: 62a58a594ee8197884be5e8ee2c56b2d9e92c5a2a87d1617c3d6b7e73de8ab57962c6a7f67a9aa4e9b3456a24dc7fc43e6841857f8a9f134d65052786e77099d
@@ -71,7 +71,7 @@ module Vertebrae
71
71
  end
72
72
 
73
73
  def adapter
74
- options[:adapter] || auto_detect_adapter
74
+ options[:adapter] || ::Faraday.default_adapter
75
75
  end
76
76
 
77
77
  def adapter=(value)
@@ -90,7 +90,6 @@ module Vertebrae
90
90
  end
91
91
  end
92
92
 
93
-
94
93
  def faraday_options
95
94
  {
96
95
  :headers => {
@@ -117,33 +116,8 @@ module Vertebrae
117
116
  end
118
117
  end
119
118
 
120
-
121
119
  def endpoint
122
120
  "#{self.scheme}://#{self.host}#{self.port.present? ? ":#{self.port}" : ''}#{self.prefix}"
123
121
  end
124
-
125
- private
126
-
127
- # Auto-detect the best adapter (HTTP "driver") available, based on libraries
128
- # loaded by the user, preferring those with persistent connections
129
- # ("keep-alive") by default
130
- #
131
- # @return [Symbol]
132
- #
133
- #
134
- def auto_detect_adapter
135
- case
136
- when defined?(::Typhoeus)
137
- :typhoeus
138
- when defined?(::Patron)
139
- :patron
140
- when defined?(::HTTPClient)
141
- :httpclient
142
- when defined?(::Net::HTTP::Persistent)
143
- :net_http_persistent
144
- else
145
- ::Faraday.default_adapter
146
- end
147
- end
148
122
  end
149
123
  end
@@ -13,6 +13,7 @@ module Vertebrae
13
13
 
14
14
  attr_reader :options
15
15
  attr_accessor :configuration
16
+ attr_accessor :faraday_connection
16
17
 
17
18
  ALLOWED_OPTIONS = [
18
19
  :headers,
@@ -33,45 +34,23 @@ module Vertebrae
33
34
  @configuration = Vertebrae::Configuration.new(options)
34
35
  end
35
36
 
36
- # Default middleware stack that uses default adapter as specified at
37
- # configuration stage.
37
+ # Returns a Faraday::Connection object
38
38
  #
39
- def default_middleware
40
- Proc.new do |builder|
41
- builder.use Faraday::Multipart::Middleware
42
- builder.use Faraday::Request::UrlEncoded
39
+ def connection
40
+ self.faraday_connection ||= Faraday.new(configuration.faraday_options) do |f|
43
41
  if configuration.authenticated?
44
- builder.use Faraday::Request::Authorization, :basic, configuration.username, configuration.password
42
+ f.request :authorization, :basic, configuration.username, configuration.password
45
43
  end
46
-
47
- builder.use Faraday::Response::Logger if ENV['DEBUG']
48
-
44
+ f.request :multipart
45
+ f.request :url_encoded
49
46
  unless options[:raw]
50
- builder.use Faraday::Mashify::Middleware
51
- builder.use Faraday::Response::Json
47
+ f.response :mashify
48
+ f.response :json
52
49
  end
53
- builder.use Vertebrae::Response::RaiseError
54
- builder.adapter configuration.adapter
55
- end
56
- end
57
50
 
58
- # Exposes middleware builder to facilitate custom stacks and easy
59
- # addition of new extensions such as cache adapter.
60
- #
61
- def stack(&block)
62
- @stack ||= begin
63
- if block_given?
64
- Faraday::RackBuilder.new(&block)
65
- else
66
- Faraday::RackBuilder.new(&default_middleware)
67
- end
51
+ f.response :raise_error
52
+ f.adapter configuration.adapter
68
53
  end
69
54
  end
70
-
71
- # Returns a Faraday::Connection object
72
- #
73
- def connection
74
- Faraday.new(configuration.faraday_options.merge(:builder => stack))
75
- end
76
55
  end
77
56
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Vertebrae
4
- VERSION = '1.0.1'
4
+ VERSION = '1.0.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vertebrae
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Woodhull