clientele 0.3.16 → 0.4.0
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/clientele/configuration.rb +8 -6
- data/lib/clientele/request.rb +4 -15
- data/lib/clientele/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8883fe8e83325ba29feba69b372db4059172982c
|
4
|
+
data.tar.gz: ae9551c35f4af01e6ad7fcb55c9549f5de79a08a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6626b0ba7562c975a10910a354225aee14e91780dbc716be6c012e4cb49846252437e121d9ac5afe2b1652ee21f7add922316e85bb5dd0cb1248b52b41cdb6f3
|
7
|
+
data.tar.gz: 11e8b331d8066b620199b6ef2d2e63bb99acf32e73177ec6809b37b6c991faa67380fcc27992a47d9dd8799a3126b9815693b4ddecccabe092f87c7451c0ecac
|
@@ -6,7 +6,7 @@ require 'faraday_middleware'
|
|
6
6
|
module Clientele
|
7
7
|
class Configuration < BlockParty::Configuration
|
8
8
|
|
9
|
-
attr_accessor :logger, :adapter, :headers, :hashify_content_type, :root_url, :follow_redirects, :redirect_limit, :ensure_trailing_slash, :
|
9
|
+
attr_accessor :logger, :adapter, :headers, :hashify_content_type, :root_url, :follow_redirects, :redirect_limit, :ensure_trailing_slash, :connection
|
10
10
|
|
11
11
|
def initialize
|
12
12
|
self.logger = Logger.new($stdout)
|
@@ -17,11 +17,11 @@ module Clientele
|
|
17
17
|
self.redirect_limit = 5
|
18
18
|
self.ensure_trailing_slash = true
|
19
19
|
|
20
|
-
self.
|
20
|
+
self.connection = default_connection
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
24
|
-
|
23
|
+
def default_connection
|
24
|
+
Proc.new do |conn, options|
|
25
25
|
|
26
26
|
conn.use FaradayMiddleware::FollowRedirects, limit: options[:redirect_limit] if options[:follow_redirects]
|
27
27
|
|
@@ -31,10 +31,12 @@ module Clientele
|
|
31
31
|
conn.response :logger, options[:logger], bodies: true
|
32
32
|
conn.response :json, content_type: options[:hashify_content_type], preserve_raw: true
|
33
33
|
|
34
|
-
conn.adapter options[:adapter] if options[:adapter]
|
35
|
-
|
36
34
|
conn.options.params_encoder = options[:params_encoder] if options[:params_encoder]
|
37
35
|
|
36
|
+
yield(conn, options) if block_given?
|
37
|
+
|
38
|
+
conn.adapter options[:adapter] if options[:adapter]
|
39
|
+
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
data/lib/clientele/request.rb
CHANGED
@@ -90,21 +90,10 @@ module Clientele
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def faraday_client
|
93
|
-
Faraday.new(options[:root_url]) do |
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
conn.request :url_encoded
|
98
|
-
|
99
|
-
conn.response :rashify
|
100
|
-
conn.response :logger, options[:logger], bodies: true
|
101
|
-
conn.response :json, content_type: options[:hashify_content_type], preserve_raw: true
|
102
|
-
|
103
|
-
conn.adapter options[:adapter] if options[:adapter]
|
104
|
-
|
105
|
-
conn.options.params_encoder = options[:params_encoder] if options[:params_encoder]
|
106
|
-
|
107
|
-
options[:faraday_configuration].call conn, options
|
93
|
+
Faraday.new(options[:root_url]) do |connection|
|
94
|
+
if options[:connection]
|
95
|
+
options[:connection].call connection, options
|
96
|
+
end
|
108
97
|
end
|
109
98
|
end
|
110
99
|
|
data/lib/clientele/version.rb
CHANGED