clientele 0.3.15 → 0.3.16

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: 4f9e0e9125363497dd5c9f0f0475642960fa275a
4
- data.tar.gz: 40339a1376a5893704c029ca4e7a6eea43955ce7
3
+ metadata.gz: 8e00adee7beb377011ab43eb243b79d8d41a3416
4
+ data.tar.gz: 1ab8f9447b8a70ba9103c0d30089105a99192d10
5
5
  SHA512:
6
- metadata.gz: 96ecb8896fae84638bb81a452138c9cec3bcda18723b14488d7d586fbac132c43d039ff7ccbe862cd9dabab449d461d1726dce98e91e20b06cf6959418bab305
7
- data.tar.gz: 32f452c4efcfd76085b6e3161a5552903a308789b734dc2d668b2901c05fda62653be92b648df332d1451af615d92a8a408d954a092eb9acab74a21325849b19
6
+ metadata.gz: ef06a52d69b52013569dd4c265d4c95b95ad9e2afb1950fc1372bd43064a94ba5c858305e136c8d6ad1cde028e6b631055bf466b0a331ab79b1d10f7796557f3
7
+ data.tar.gz: 0bc3f5d3d8e658639cf28f979c744998bd5f8df4f58b185719c7058ae2a99b9f745ed000db1d0d3c1fa9f2acaeae3871e54da4b8aeeb27197ddc04dafe42e11e
@@ -1,20 +1,41 @@
1
1
  require 'logger'
2
2
 
3
3
  require 'faraday'
4
+ require 'faraday_middleware'
4
5
 
5
6
  module Clientele
6
7
  class Configuration < BlockParty::Configuration
7
8
 
8
- attr_accessor :logger, :adapter, :headers, :hashify_content_type, :root_url, :follow_redirects, :redirect_limit
9
+ attr_accessor :logger, :adapter, :headers, :hashify_content_type, :root_url, :follow_redirects, :redirect_limit, :ensure_trailing_slash, :faraday_configuration
9
10
 
10
11
  def initialize
11
- self.logger = Logger.new($stdout)
12
- self.adapter = Faraday.default_adapter
13
- self.headers = {}
12
+ self.logger = Logger.new($stdout)
13
+ self.adapter = Faraday.default_adapter
14
+ self.headers = {}
14
15
  self.hashify_content_type = /\bjson$/
15
16
  self.follow_redirects = true
16
17
  self.redirect_limit = 5
17
18
  self.ensure_trailing_slash = true
19
+
20
+ self.faraday_configuration = default_faraday_configuration
21
+ end
22
+
23
+ def default_faraday_configuration
24
+ @default_faraday_configuration ||= Proc.new do |conn, options|
25
+
26
+ conn.use FaradayMiddleware::FollowRedirects, limit: options[:redirect_limit] if options[:follow_redirects]
27
+
28
+ conn.request :url_encoded
29
+
30
+ conn.response :rashify
31
+ conn.response :logger, options[:logger], bodies: true
32
+ conn.response :json, content_type: options[:hashify_content_type], preserve_raw: true
33
+
34
+ conn.adapter options[:adapter] if options[:adapter]
35
+
36
+ conn.options.params_encoder = options[:params_encoder] if options[:params_encoder]
37
+
38
+ end
18
39
  end
19
40
 
20
41
  end
@@ -103,6 +103,8 @@ module Clientele
103
103
  conn.adapter options[:adapter] if options[:adapter]
104
104
 
105
105
  conn.options.params_encoder = options[:params_encoder] if options[:params_encoder]
106
+
107
+ options[:faraday_configuration].call conn, options
106
108
  end
107
109
  end
108
110
 
@@ -1,3 +1,3 @@
1
1
  module Clientele
2
- VERSION = "0.3.15"
2
+ VERSION = "0.3.16"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clientele
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.15
4
+ version: 0.3.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Keele
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-05 00:00:00.000000000 Z
11
+ date: 2015-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday