faraday 2.12.1 → 2.12.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 728fc5d53c11677c4b0e09fbdcd5b9bb78a96d500589b7f2d9cdf3513f73d736
4
- data.tar.gz: 9a735994de6694d72fbe11810ac3ae8b633d4b16244749a4e6604e295ff433e1
3
+ metadata.gz: 1434b95a4b157a48f4279e2341946ed2d2ca0fd5547e88cae6b531c6be1e3bb0
4
+ data.tar.gz: 947e3e3751d9e2a717d4b28278285cc825eb292a93273d97571d3cde4f77f923
5
5
  SHA512:
6
- metadata.gz: 8523f225eaaeadfed42a6455d7b8f8b57a8e3f76994efda83064cd48e95fbac1bd9b5113d3575c7200a575bad520db2d19cbb4c13a06384149c4bdd343edadf8
7
- data.tar.gz: 92807b6ca5c51d273aa19cf1aa2572eb39edd0c2e49c474211fed0da677e6fa4be9ca726e33556858ccf3daea7dfa5bde173345fc94efde363a58a7b3cc9ed4c
6
+ metadata.gz: 5e5d06c952784a9bd7f0b6a610188a0e00a8415fd5ccb35bc07fe4c9426fc5de10f8975bc069d85a13f5cc6f48ab291433d9565ab1f17112fac595e4aef50660
7
+ data.tar.gz: 58b30aa3c0aa2d635839019358931fec2be300a8a59078240aea4541696e9aa5445106783d8281de0a1ec0e67c81ac9c3d1a08d2c4594caf14099753eb0b3d9d
@@ -23,8 +23,8 @@ module Faraday
23
23
  def_delegators :@logger, :debug, :info, :warn, :error, :fatal
24
24
 
25
25
  def request(env)
26
- public_send(log_level, 'request') do
27
- "#{env.method.upcase} #{apply_filters(env.url.to_s)}"
26
+ public_send(log_level) do
27
+ "request: #{env.method.upcase} #{apply_filters(env.url.to_s)}"
28
28
  end
29
29
 
30
30
  log_headers('request', env.request_headers) if log_headers?(:request)
@@ -32,7 +32,7 @@ module Faraday
32
32
  end
33
33
 
34
34
  def response(env)
35
- public_send(log_level, 'response') { "Status #{env.status}" }
35
+ public_send(log_level) { "response: Status #{env.status}" }
36
36
 
37
37
  log_headers('response', env.response_headers) if log_headers?(:response)
38
38
  log_body('response', env[:body]) if env[:body] && log_body?(:response)
@@ -41,7 +41,7 @@ module Faraday
41
41
  def exception(exc)
42
42
  return unless log_errors?
43
43
 
44
- public_send(log_level, 'error') { exc.full_message }
44
+ public_send(log_level) { "error: #{exc.full_message}" }
45
45
 
46
46
  log_headers('error', exc.response_headers) if exc.respond_to?(:response_headers) && log_headers?(:error)
47
47
  return unless exc.respond_to?(:response_body) && exc.response_body && log_body?(:error)
@@ -107,11 +107,11 @@ module Faraday
107
107
  end
108
108
 
109
109
  def log_headers(type, headers)
110
- public_send(log_level, type) { apply_filters(dump_headers(headers)) }
110
+ public_send(log_level) { "#{type}: #{apply_filters(dump_headers(headers))}" }
111
111
  end
112
112
 
113
113
  def log_body(type, body)
114
- public_send(log_level, type) { apply_filters(dump_body(body)) }
114
+ public_send(log_level) { "#{type}: #{apply_filters(dump_body(body))}" }
115
115
  end
116
116
  end
117
117
  end
@@ -22,8 +22,10 @@ module Faraday
22
22
  when URI
23
23
  value = { uri: value }
24
24
  when Hash, Options
25
- if (uri = value.delete(:uri))
26
- value[:uri] = Utils.URI(uri)
25
+ if value[:uri]
26
+ value = value.dup.tap do |duped|
27
+ duped[:uri] = Utils.URI(duped[:uri])
28
+ end
27
29
  end
28
30
  end
29
31
 
@@ -27,10 +27,11 @@ module Faraday
27
27
 
28
28
  attr_reader :name
29
29
 
30
- ruby2_keywords def initialize(klass, *args, &block)
30
+ def initialize(klass, *args, **kwargs, &block)
31
31
  @name = klass.to_s
32
32
  REGISTRY.set(klass) if klass.respond_to?(:name)
33
33
  @args = args
34
+ @kwargs = kwargs
34
35
  @block = block
35
36
  end
36
37
 
@@ -53,7 +54,7 @@ module Faraday
53
54
  end
54
55
 
55
56
  def build(app = nil)
56
- klass.new(app, *@args, &@block)
57
+ klass.new(app, *@args, **@kwargs, &@block)
57
58
  end
58
59
  end
59
60
 
@@ -88,52 +89,52 @@ module Faraday
88
89
  @handlers.frozen?
89
90
  end
90
91
 
91
- ruby2_keywords def use(klass, *args, &block)
92
+ def use(klass, ...)
92
93
  if klass.is_a? Symbol
93
- use_symbol(Faraday::Middleware, klass, *args, &block)
94
+ use_symbol(Faraday::Middleware, klass, ...)
94
95
  else
95
96
  raise_if_locked
96
97
  raise_if_adapter(klass)
97
- @handlers << self.class::Handler.new(klass, *args, &block)
98
+ @handlers << self.class::Handler.new(klass, ...)
98
99
  end
99
100
  end
100
101
 
101
- ruby2_keywords def request(key, *args, &block)
102
- use_symbol(Faraday::Request, key, *args, &block)
102
+ def request(key, ...)
103
+ use_symbol(Faraday::Request, key, ...)
103
104
  end
104
105
 
105
- ruby2_keywords def response(key, *args, &block)
106
- use_symbol(Faraday::Response, key, *args, &block)
106
+ def response(...)
107
+ use_symbol(Faraday::Response, ...)
107
108
  end
108
109
 
109
- ruby2_keywords def adapter(klass = NO_ARGUMENT, *args, &block)
110
+ def adapter(klass = NO_ARGUMENT, *args, **kwargs, &block)
110
111
  return @adapter if klass == NO_ARGUMENT || klass.nil?
111
112
 
112
113
  klass = Faraday::Adapter.lookup_middleware(klass) if klass.is_a?(Symbol)
113
- @adapter = self.class::Handler.new(klass, *args, &block)
114
+ @adapter = self.class::Handler.new(klass, *args, **kwargs, &block)
114
115
  end
115
116
 
116
117
  ## methods to push onto the various positions in the stack:
117
118
 
118
- ruby2_keywords def insert(index, *args, &block)
119
+ def insert(index, ...)
119
120
  raise_if_locked
120
121
  index = assert_index(index)
121
- handler = self.class::Handler.new(*args, &block)
122
+ handler = self.class::Handler.new(...)
122
123
  @handlers.insert(index, handler)
123
124
  end
124
125
 
125
126
  alias insert_before insert
126
127
 
127
- ruby2_keywords def insert_after(index, *args, &block)
128
+ def insert_after(index, ...)
128
129
  index = assert_index(index)
129
- insert(index + 1, *args, &block)
130
+ insert(index + 1, ...)
130
131
  end
131
132
 
132
- ruby2_keywords def swap(index, *args, &block)
133
+ def swap(index, ...)
133
134
  raise_if_locked
134
135
  index = assert_index(index)
135
136
  @handlers.delete_at(index)
136
- insert(index, *args, &block)
137
+ insert(index, ...)
137
138
  end
138
139
 
139
140
  def delete(handler)
@@ -237,8 +238,8 @@ module Faraday
237
238
  klass <= Faraday::Adapter
238
239
  end
239
240
 
240
- ruby2_keywords def use_symbol(mod, key, *args, &block)
241
- use(mod.lookup_middleware(key), *args, &block)
241
+ def use_symbol(mod, key, ...)
242
+ use(mod.lookup_middleware(key), ...)
242
243
  end
243
244
 
244
245
  def assert_index(index)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Faraday
4
- VERSION = '2.12.1'
4
+ VERSION = '2.12.3'
5
5
  end
@@ -24,7 +24,11 @@ RSpec.describe Faraday::Error do
24
24
  it { expect(subject.wrapped_exception).to be_nil }
25
25
  it { expect(subject.response).to eq(exception) }
26
26
  it { expect(subject.message).to eq('the server responded with status 400') }
27
- it { expect(subject.inspect).to eq('#<Faraday::Error response={:status=>400}>') }
27
+ if RUBY_VERSION >= '3.4'
28
+ it { expect(subject.inspect).to eq('#<Faraday::Error response={status: 400}>') }
29
+ else
30
+ it { expect(subject.inspect).to eq('#<Faraday::Error response={:status=>400}>') }
31
+ end
28
32
  it { expect(subject.response_status).to eq(400) }
29
33
  it { expect(subject.response_headers).to be_nil }
30
34
  it { expect(subject.response_body).to be_nil }
@@ -61,7 +65,11 @@ RSpec.describe Faraday::Error do
61
65
  it { expect(subject.wrapped_exception).to be_nil }
62
66
  it { expect(subject.response).to eq(response) }
63
67
  it { expect(subject.message).to eq('custom message') }
64
- it { expect(subject.inspect).to eq('#<Faraday::Error response={:status=>400}>') }
68
+ if RUBY_VERSION >= '3.4'
69
+ it { expect(subject.inspect).to eq('#<Faraday::Error response={status: 400}>') }
70
+ else
71
+ it { expect(subject.inspect).to eq('#<Faraday::Error response={:status=>400}>') }
72
+ end
65
73
  it { expect(subject.response_status).to eq(400) }
66
74
  it { expect(subject.response_headers).to be_nil }
67
75
  it { expect(subject.response_body).to be_nil }
@@ -27,6 +27,33 @@ RSpec.describe Faraday::ProxyOptions do
27
27
  expect(options.inspect).to eq('#<Faraday::ProxyOptions (empty)>')
28
28
  end
29
29
 
30
+ it 'works with hash' do
31
+ hash = { user: 'user', password: 'pass', uri: 'http://@example.org' }
32
+ options = Faraday::ProxyOptions.from(hash)
33
+ expect(options.user).to eq('user')
34
+ expect(options.password).to eq('pass')
35
+ expect(options.uri).to be_a_kind_of(URI)
36
+ expect(options.path).to eq('')
37
+ expect(options.port).to eq(80)
38
+ expect(options.host).to eq('example.org')
39
+ expect(options.scheme).to eq('http')
40
+ expect(options.inspect).to match('#<Faraday::ProxyOptions uri=')
41
+ end
42
+
43
+ it 'works with option' do
44
+ opt_arg = { user: 'user', password: 'pass', uri: 'http://@example.org' }
45
+ option = Faraday::ConnectionOptions.from(proxy: opt_arg)
46
+ options = Faraday::ProxyOptions.from(option.proxy)
47
+ expect(options.user).to eq('user')
48
+ expect(options.password).to eq('pass')
49
+ expect(options.uri).to be_a_kind_of(URI)
50
+ expect(options.path).to eq('')
51
+ expect(options.port).to eq(80)
52
+ expect(options.host).to eq('example.org')
53
+ expect(options.scheme).to eq('http')
54
+ expect(options.inspect).to match('#<Faraday::ProxyOptions uri=')
55
+ end
56
+
30
57
  it 'works with no auth' do
31
58
  proxy = Faraday::ProxyOptions.from 'http://example.org'
32
59
  expect(proxy.user).to be_nil
@@ -55,6 +55,26 @@ RSpec.describe Faraday::Response::Logger do
55
55
  end
56
56
  end
57
57
 
58
+ context 'when logger with program name' do
59
+ let(:logger) { Logger.new(string_io, progname: 'my_best_program') }
60
+
61
+ it 'logs with program name' do
62
+ conn.get '/hello'
63
+
64
+ expect(string_io.string).to match('-- my_best_program: request:')
65
+ expect(string_io.string).to match('-- my_best_program: response:')
66
+ end
67
+ end
68
+
69
+ context 'when logger without program name' do
70
+ it 'logs without program name' do
71
+ conn.get '/hello'
72
+
73
+ expect(string_io.string).to match('-- : request:')
74
+ expect(string_io.string).to match('-- : response:')
75
+ end
76
+ end
77
+
58
78
  context 'with default formatter' do
59
79
  let(:formatter) { instance_double(Faraday::Logging::Formatter, request: true, response: true, filter: []) }
60
80
 
metadata CHANGED
@@ -1,16 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faraday
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.12.1
4
+ version: 2.12.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - "@technoweenie"
8
8
  - "@iMacTia"
9
9
  - "@olleolleolle"
10
- autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2024-11-14 00:00:00.000000000 Z
12
+ date: 2025-04-08 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: faraday-net_http
@@ -60,7 +59,6 @@ dependencies:
60
59
  - - ">="
61
60
  - !ruby/object:Gem::Version
62
61
  version: '0'
63
- description:
64
62
  email: technoweenie@gmail.com
65
63
  executables: []
66
64
  extensions: []
@@ -146,11 +144,10 @@ licenses:
146
144
  - MIT
147
145
  metadata:
148
146
  homepage_uri: https://lostisland.github.io/faraday
149
- changelog_uri: https://github.com/lostisland/faraday/releases/tag/v2.12.1
147
+ changelog_uri: https://github.com/lostisland/faraday/releases/tag/v2.12.3
150
148
  source_code_uri: https://github.com/lostisland/faraday
151
149
  bug_tracker_uri: https://github.com/lostisland/faraday/issues
152
150
  rubygems_mfa_required: 'true'
153
- post_install_message:
154
151
  rdoc_options: []
155
152
  require_paths:
156
153
  - lib
@@ -166,8 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
163
  - !ruby/object:Gem::Version
167
164
  version: '0'
168
165
  requirements: []
169
- rubygems_version: 3.5.22
170
- signing_key:
166
+ rubygems_version: 3.6.2
171
167
  specification_version: 4
172
168
  summary: HTTP/REST API client library.
173
169
  test_files: []