faraday 2.0.1 → 2.1.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
  SHA256:
3
- metadata.gz: 06eb37848cd7af8f9bbca6515b5d39da8fd1b96242c02ef3e11f370102538030
4
- data.tar.gz: 28e3ae036dddef796d0bb388cff43f7aea5bcedfdb92bd410099fd303255abd6
3
+ metadata.gz: 2123a105dd09a93bec6fe115277fd7c58afa269bc1036524a422a3e45df2b40c
4
+ data.tar.gz: bdd311dabe80e2ecd28f7bf941ea0e551840b2bc783dd781b56999842086a31f
5
5
  SHA512:
6
- metadata.gz: 3b492269396e55018147763939f526fd69b34da244c94e0b055b945dc4d4c32a5b4eee25accc0dcb7d60a74e31dca46787349909a0c806fd79428a6806a627fe
7
- data.tar.gz: 7d61eaf95bcdd8206d20bb4e63575e774ecf49483623ee7f943d7e19dcfebc4c5820cac985382b4582e146540bf7438771a92a039462978c3081ef566221bab9
6
+ metadata.gz: 943a1dd4a67287874fc3724d3d9ec7e41540cd3a08b528201b1af806d5dd56bceb976f54df6d0394fb25bffeb0bcb224831700c9ef46c1daf24cb3e13fd2ad52
7
+ data.tar.gz: 3ae115b30da8ec49253888f4a81522c14667a8da6b248b0d56192252b8d9bf9a6914f703530d467c2a83415a0862b73ccc17f799d9c1d0fba8289296b7cb0faf
@@ -55,6 +55,7 @@ module Faraday
55
55
  @stack = {}
56
56
  @consumed = {}
57
57
  @strict_mode = strict_mode
58
+ @stubs_mutex = Monitor.new
58
59
  yield(self) if block_given?
59
60
  end
60
61
 
@@ -70,10 +71,13 @@ module Faraday
70
71
  stack = @stack[request_method]
71
72
  consumed = (@consumed[request_method] ||= [])
72
73
 
73
- stub, meta = matches?(stack, env)
74
- if stub
75
- consumed << stack.delete(stub)
76
- return stub, meta
74
+ @stubs_mutex.synchronize do
75
+ stub, meta = matches?(stack, env)
76
+ if stub
77
+ removed = stack.delete(stub)
78
+ consumed << removed unless removed.nil?
79
+ return stub, meta
80
+ end
77
81
  end
78
82
  matches?(consumed, env)
79
83
  end
@@ -73,7 +73,7 @@ module Faraday
73
73
  def build
74
74
  raise_if_locked
75
75
  block_given? ? yield(self) : request(:url_encoded)
76
- adapter(Faraday.default_adapter) unless @adapter
76
+ adapter(Faraday.default_adapter, **Faraday.default_adapter_options) unless @adapter
77
77
  end
78
78
 
79
79
  def [](idx)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Faraday
4
- VERSION = '2.0.1'
4
+ VERSION = '2.1.0'
5
5
  end
data/lib/faraday.rb CHANGED
@@ -54,6 +54,10 @@ module Faraday
54
54
  # @return [Symbol] the new default_adapter.
55
55
  attr_reader :default_adapter
56
56
 
57
+ # Option for the default_adapter
58
+ # @return [Hash] default_adapter options
59
+ attr_accessor :default_adapter_options
60
+
57
61
  # Documented below, see default_connection
58
62
  attr_writer :default_connection
59
63
 
@@ -149,4 +153,5 @@ module Faraday
149
153
  self.root_path = File.expand_path __dir__
150
154
  self.lib_path = File.expand_path 'faraday', __dir__
151
155
  self.default_adapter = :net_http
156
+ self.default_adapter_options = {}
152
157
  end
@@ -151,6 +151,33 @@ RSpec.describe Faraday::RackBuilder do
151
151
  end
152
152
  end
153
153
 
154
+ context 'when adapter is added with named options' do
155
+ after { Faraday.default_adapter_options = {} }
156
+ let(:conn) { Faraday::Connection.new {} }
157
+
158
+ let(:cat_adapter) do
159
+ Class.new(Faraday::Adapter) do
160
+ attr_accessor :name
161
+
162
+ def initialize(app, name:)
163
+ super(app)
164
+ @name = name
165
+ end
166
+ end
167
+ end
168
+
169
+ let(:cat) { subject.adapter.build }
170
+
171
+ it 'adds a handler to construct adapter with named options' do
172
+ Faraday.default_adapter = cat_adapter
173
+ Faraday.default_adapter_options = { name: 'Chloe' }
174
+ expect { cat }.to_not output(
175
+ /warning: Using the last argument as keyword parameters is deprecated/
176
+ ).to_stderr
177
+ expect(cat.name).to eq 'Chloe'
178
+ end
179
+ end
180
+
154
181
  context 'when middleware is added with named arguments' do
155
182
  let(:conn) { Faraday::Connection.new {} }
156
183
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faraday
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "@technoweenie"
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-01-05 00:00:00.000000000 Z
13
+ date: 2022-01-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday-net_http
@@ -124,7 +124,7 @@ licenses:
124
124
  - MIT
125
125
  metadata:
126
126
  homepage_uri: https://lostisland.github.io/faraday
127
- changelog_uri: https://github.com/lostisland/faraday/releases/tag/v2.0.1
127
+ changelog_uri: https://github.com/lostisland/faraday/releases/tag/v2.1.0
128
128
  source_code_uri: https://github.com/lostisland/faraday
129
129
  bug_tracker_uri: https://github.com/lostisland/faraday/issues
130
130
  post_install_message: