faraday 2.12.1 → 2.12.2

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: 728fc5d53c11677c4b0e09fbdcd5b9bb78a96d500589b7f2d9cdf3513f73d736
4
- data.tar.gz: 9a735994de6694d72fbe11810ac3ae8b633d4b16244749a4e6604e295ff433e1
3
+ metadata.gz: bfb424c45e703a33fd819b31c8ee41c9e4e30874b280530a19ce8ae320570ef9
4
+ data.tar.gz: c1a1a5b7aab4f393908958701959f7b41fd303ca4da906c1b4c0581a13c590db
5
5
  SHA512:
6
- metadata.gz: 8523f225eaaeadfed42a6455d7b8f8b57a8e3f76994efda83064cd48e95fbac1bd9b5113d3575c7200a575bad520db2d19cbb4c13a06384149c4bdd343edadf8
7
- data.tar.gz: 92807b6ca5c51d273aa19cf1aa2572eb39edd0c2e49c474211fed0da677e6fa4be9ca726e33556858ccf3daea7dfa5bde173345fc94efde363a58a7b3cc9ed4c
6
+ metadata.gz: 6d4d18e2006ac83dfd22aff834b4fe3c983bfbf578b6850944d35cfbb1ca40ba58ce07414821bc3e604ca3310c85500d5d2b8de7c33b0e6147f24484fcae688f
7
+ data.tar.gz: 9cc8057d003f09a02bbdb9a29b920003beff58391c3bf86838ae61b2e9aaac4782d5764286f824b24d486e8dee202cc2d892ec3f658db6b710d5088d5836be3c
@@ -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
@@ -88,22 +88,22 @@ module Faraday
88
88
  @handlers.frozen?
89
89
  end
90
90
 
91
- ruby2_keywords def use(klass, *args, &block)
91
+ def use(klass, ...)
92
92
  if klass.is_a? Symbol
93
- use_symbol(Faraday::Middleware, klass, *args, &block)
93
+ use_symbol(Faraday::Middleware, klass, ...)
94
94
  else
95
95
  raise_if_locked
96
96
  raise_if_adapter(klass)
97
- @handlers << self.class::Handler.new(klass, *args, &block)
97
+ @handlers << self.class::Handler.new(klass, ...)
98
98
  end
99
99
  end
100
100
 
101
- ruby2_keywords def request(key, *args, &block)
102
- use_symbol(Faraday::Request, key, *args, &block)
101
+ def request(key, ...)
102
+ use_symbol(Faraday::Request, key, ...)
103
103
  end
104
104
 
105
- ruby2_keywords def response(key, *args, &block)
106
- use_symbol(Faraday::Response, key, *args, &block)
105
+ def response(...)
106
+ use_symbol(Faraday::Response, ...)
107
107
  end
108
108
 
109
109
  ruby2_keywords def adapter(klass = NO_ARGUMENT, *args, &block)
@@ -115,25 +115,25 @@ module Faraday
115
115
 
116
116
  ## methods to push onto the various positions in the stack:
117
117
 
118
- ruby2_keywords def insert(index, *args, &block)
118
+ def insert(index, ...)
119
119
  raise_if_locked
120
120
  index = assert_index(index)
121
- handler = self.class::Handler.new(*args, &block)
121
+ handler = self.class::Handler.new(...)
122
122
  @handlers.insert(index, handler)
123
123
  end
124
124
 
125
125
  alias insert_before insert
126
126
 
127
- ruby2_keywords def insert_after(index, *args, &block)
127
+ def insert_after(index, ...)
128
128
  index = assert_index(index)
129
- insert(index + 1, *args, &block)
129
+ insert(index + 1, ...)
130
130
  end
131
131
 
132
- ruby2_keywords def swap(index, *args, &block)
132
+ def swap(index, ...)
133
133
  raise_if_locked
134
134
  index = assert_index(index)
135
135
  @handlers.delete_at(index)
136
- insert(index, *args, &block)
136
+ insert(index, ...)
137
137
  end
138
138
 
139
139
  def delete(handler)
@@ -237,8 +237,8 @@ module Faraday
237
237
  klass <= Faraday::Adapter
238
238
  end
239
239
 
240
- ruby2_keywords def use_symbol(mod, key, *args, &block)
241
- use(mod.lookup_middleware(key), *args, &block)
240
+ def use_symbol(mod, key, ...)
241
+ use(mod.lookup_middleware(key), ...)
242
242
  end
243
243
 
244
244
  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.2'
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 }
@@ -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,16 @@
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.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - "@technoweenie"
8
8
  - "@iMacTia"
9
9
  - "@olleolleolle"
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-11-14 00:00:00.000000000 Z
13
+ date: 2024-12-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday-net_http
@@ -60,7 +60,7 @@ dependencies:
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
- description:
63
+ description:
64
64
  email: technoweenie@gmail.com
65
65
  executables: []
66
66
  extensions: []
@@ -146,11 +146,11 @@ licenses:
146
146
  - MIT
147
147
  metadata:
148
148
  homepage_uri: https://lostisland.github.io/faraday
149
- changelog_uri: https://github.com/lostisland/faraday/releases/tag/v2.12.1
149
+ changelog_uri: https://github.com/lostisland/faraday/releases/tag/v2.12.2
150
150
  source_code_uri: https://github.com/lostisland/faraday
151
151
  bug_tracker_uri: https://github.com/lostisland/faraday/issues
152
152
  rubygems_mfa_required: 'true'
153
- post_install_message:
153
+ post_install_message:
154
154
  rdoc_options: []
155
155
  require_paths:
156
156
  - lib
@@ -167,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
167
  version: '0'
168
168
  requirements: []
169
169
  rubygems_version: 3.5.22
170
- signing_key:
170
+ signing_key:
171
171
  specification_version: 4
172
172
  summary: HTTP/REST API client library.
173
173
  test_files: []