faraday 2.0.0 → 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: 367d509be94da297eac6ece76f5561772218a5982696eba047ef8599d0ff05e1
4
- data.tar.gz: 779c66227b778b17661428c17ab65567e23f13ea2824b92251eba67cd32c6280
3
+ metadata.gz: 2123a105dd09a93bec6fe115277fd7c58afa269bc1036524a422a3e45df2b40c
4
+ data.tar.gz: bdd311dabe80e2ecd28f7bf941ea0e551840b2bc783dd781b56999842086a31f
5
5
  SHA512:
6
- metadata.gz: 73d405ce87ac4a0917806b16ab11693b68966334656689a95bc06764501c44965832b08fa7bf36beeb71c2144a6661775df4f22b18e8281f664a0605fc2ece49
7
- data.tar.gz: 22701db3eb1bb1668aaf6429e711acad05099577b39ccc792d32c42a82043f628483973a993c5ce91acd4207a9f0a01f47a51d6bffc4212047e4150fbb63e1e1
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.0'
4
+ VERSION = '2.1.0'
5
5
  end
data/lib/faraday.rb CHANGED
@@ -17,7 +17,7 @@ require 'faraday/middleware'
17
17
  require 'faraday/adapter'
18
18
  require 'faraday/request'
19
19
  require 'faraday/response'
20
-
20
+ require 'faraday/net_http'
21
21
  # This is the main namespace for Faraday.
22
22
  #
23
23
  # It provides methods to create {Connection} objects, and HTTP-related
@@ -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
 
@@ -148,4 +152,6 @@ module Faraday
148
152
  self.ignore_env_proxy = false
149
153
  self.root_path = File.expand_path __dir__
150
154
  self.lib_path = File.expand_path 'faraday', __dir__
155
+ self.default_adapter = :net_http
156
+ self.default_adapter_options = {}
151
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.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "@technoweenie"
@@ -10,8 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-01-04 00:00:00.000000000 Z
13
+ date: 2022-01-15 00:00:00.000000000 Z
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: faraday-net_http
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '2.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '2.0'
15
29
  - !ruby/object:Gem::Dependency
16
30
  name: ruby2_keywords
17
31
  requirement: !ruby/object:Gem::Requirement
@@ -110,7 +124,7 @@ licenses:
110
124
  - MIT
111
125
  metadata:
112
126
  homepage_uri: https://lostisland.github.io/faraday
113
- changelog_uri: https://github.com/lostisland/faraday/releases/tag/v2.0.0
127
+ changelog_uri: https://github.com/lostisland/faraday/releases/tag/v2.1.0
114
128
  source_code_uri: https://github.com/lostisland/faraday
115
129
  bug_tracker_uri: https://github.com/lostisland/faraday/issues
116
130
  post_install_message: