vertebrae 1.0.2 → 1.0.5

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: b16228cd60f59bb053ae8ebbdd28301615a1f6ade77566e3b054a157d0f484ae
4
+ data.tar.gz: 7c8db822e05cdce4987aac0c36c21fd4d5f132999a2d90a54012154d39732578
5
5
  SHA512:
6
- metadata.gz: 875b777a7944ac034d03d1222d1adc32c611eff136772a6f22a1d4d60824ced6d57b93e7ab1dd2411cdf231bf1fcebbe2569aae8ea808f49c093c4058f0e0438
7
- data.tar.gz: 98a03fd19a9a5407c40185c3216bda550d2fd118e67bbb9ee7f16c37080337db3d42a7b494ef18ef15ea1088ced62f01ad8f5c8998c0221318a146cf0d5a87e1
6
+ metadata.gz: 616886b82ccababdda3957bbd06e7c42367093e63a0b371211b969755f533c38db20da868bd2f14a5bc6cf1ab34dc80f14d8137aa10c529cdd75671c5a5840ca
7
+ data.tar.gz: 3bacb516caac9af5d8d1022f5add4ea9a45b8f4b2b3fe1ea1e8a804466d2b3e4bc1124c17039d64333398fdea9d6a10308befb9dab64338e7d85f861eb39ceb2
@@ -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.5'
5
5
  end
data/lib/vertebrae.rb CHANGED
@@ -13,7 +13,7 @@ require 'vertebrae/base'
13
13
  require 'vertebrae/model'
14
14
  require 'vertebrae/version'
15
15
 
16
- require 'railties' if defined? Rails
16
+ require 'vertebrae/railties' if defined? Rails
17
17
 
18
18
  module Vertebrae
19
19
 
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.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Woodhull