vertebrae 1.0.2 → 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: 6553709d307b6343edc5ba9f95d9746bc7011d2b766cfa71f004ac058aa31df3
4
- data.tar.gz: c3e633375938b93ebe9ea4fd5471f132cefe424ddf8f414bf56b21d6be05d040
3
+ metadata.gz: 30786cc1ab2fa6f4d9f8e268f4815de51f7d5054a98cdae1989070e1804946aa
4
+ data.tar.gz: 03a1316928f1a52ce36163207b9170f79340edda31c63fcaca030bb6aa89d029
5
5
  SHA512:
6
- metadata.gz: 875b777a7944ac034d03d1222d1adc32c611eff136772a6f22a1d4d60824ced6d57b93e7ab1dd2411cdf231bf1fcebbe2569aae8ea808f49c093c4058f0e0438
7
- data.tar.gz: 98a03fd19a9a5407c40185c3216bda550d2fd118e67bbb9ee7f16c37080337db3d42a7b494ef18ef15ea1088ced62f01ad8f5c8998c0221318a146cf0d5a87e1
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
@@ -34,45 +34,23 @@ module Vertebrae
34
34
  @configuration = Vertebrae::Configuration.new(options)
35
35
  end
36
36
 
37
- # Default middleware stack that uses default adapter as specified at
38
- # configuration stage.
37
+ # Returns a Faraday::Connection object
39
38
  #
40
- def default_middleware
41
- Proc.new do |builder|
42
- builder.use Faraday::Multipart::Middleware
43
- builder.use Faraday::Request::UrlEncoded
39
+ def connection
40
+ self.faraday_connection ||= Faraday.new(configuration.faraday_options) do |f|
44
41
  if configuration.authenticated?
45
- builder.use Faraday::Request::Authorization, :basic, configuration.username, configuration.password
42
+ f.request :authorization, :basic, configuration.username, configuration.password
46
43
  end
47
-
48
- builder.use Faraday::Response::Logger if ENV['DEBUG']
49
-
44
+ f.request :multipart
45
+ f.request :url_encoded
50
46
  unless options[:raw]
51
- builder.use Faraday::Mashify::Middleware
52
- builder.use Faraday::Response::Json
47
+ f.response :mashify
48
+ f.response :json
53
49
  end
54
- builder.use Vertebrae::Response::RaiseError
55
- builder.adapter configuration.adapter
56
- end
57
- end
58
50
 
59
- # Exposes middleware builder to facilitate custom stacks and easy
60
- # addition of new extensions such as cache adapter.
61
- #
62
- def stack(&block)
63
- @stack ||= begin
64
- if block_given?
65
- Faraday::RackBuilder.new(&block)
66
- else
67
- Faraday::RackBuilder.new(&default_middleware)
68
- end
51
+ f.response :raise_error
52
+ f.adapter configuration.adapter
69
53
  end
70
54
  end
71
-
72
- # Returns a Faraday::Connection object
73
- #
74
- def connection
75
- self.faraday_connection ||= Faraday.new(configuration.faraday_options.merge(:builder => stack))
76
- end
77
55
  end
78
56
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Vertebrae
4
- VERSION = '1.0.2'
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.2
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Woodhull