vertebrae 1.0.2 → 1.0.5
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/vertebrae/configuration.rb +1 -27
- data/lib/vertebrae/connection.rb +10 -32
- data/lib/vertebrae/version.rb +1 -1
- data/lib/vertebrae.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b16228cd60f59bb053ae8ebbdd28301615a1f6ade77566e3b054a157d0f484ae
|
4
|
+
data.tar.gz: 7c8db822e05cdce4987aac0c36c21fd4d5f132999a2d90a54012154d39732578
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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] ||
|
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
|
data/lib/vertebrae/connection.rb
CHANGED
@@ -34,45 +34,23 @@ module Vertebrae
|
|
34
34
|
@configuration = Vertebrae::Configuration.new(options)
|
35
35
|
end
|
36
36
|
|
37
|
-
#
|
38
|
-
# configuration stage.
|
37
|
+
# Returns a Faraday::Connection object
|
39
38
|
#
|
40
|
-
def
|
41
|
-
|
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
|
-
|
42
|
+
f.request :authorization, :basic, configuration.username, configuration.password
|
46
43
|
end
|
47
|
-
|
48
|
-
|
49
|
-
|
44
|
+
f.request :multipart
|
45
|
+
f.request :url_encoded
|
50
46
|
unless options[:raw]
|
51
|
-
|
52
|
-
|
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
|
-
|
60
|
-
|
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
|
data/lib/vertebrae/version.rb
CHANGED
data/lib/vertebrae.rb
CHANGED