clientele 0.3.16 → 0.4.0

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
  SHA1:
3
- metadata.gz: 8e00adee7beb377011ab43eb243b79d8d41a3416
4
- data.tar.gz: 1ab8f9447b8a70ba9103c0d30089105a99192d10
3
+ metadata.gz: 8883fe8e83325ba29feba69b372db4059172982c
4
+ data.tar.gz: ae9551c35f4af01e6ad7fcb55c9549f5de79a08a
5
5
  SHA512:
6
- metadata.gz: ef06a52d69b52013569dd4c265d4c95b95ad9e2afb1950fc1372bd43064a94ba5c858305e136c8d6ad1cde028e6b631055bf466b0a331ab79b1d10f7796557f3
7
- data.tar.gz: 0bc3f5d3d8e658639cf28f979c744998bd5f8df4f58b185719c7058ae2a99b9f745ed000db1d0d3c1fa9f2acaeae3871e54da4b8aeeb27197ddc04dafe42e11e
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, :faraday_configuration
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.faraday_configuration = default_faraday_configuration
20
+ self.connection = default_connection
21
21
  end
22
22
 
23
- def default_faraday_configuration
24
- @default_faraday_configuration ||= Proc.new do |conn, options|
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
 
@@ -90,21 +90,10 @@ module Clientele
90
90
  end
91
91
 
92
92
  def faraday_client
93
- Faraday.new(options[:root_url]) do |conn|
94
-
95
- conn.use FaradayMiddleware::FollowRedirects, limit: options[:redirect_limit] if options[:follow_redirects]
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
 
@@ -1,3 +1,3 @@
1
1
  module Clientele
2
- VERSION = "0.3.16"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clientele
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.16
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Keele