vcr 6.3.1 → 6.4.0

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: 5c75512238b9fd8f2774a2508b2ad27698bdf4a6b80fc01abed306602ffa6530
4
- data.tar.gz: 0ca858aeb73f9ff198ef0be4e0cdfd563758a54c75c6dcb17bdfc9d98325b21d
3
+ metadata.gz: '029f040c2799268426ac716845881b02d589948a361736e8448eac26b15da750'
4
+ data.tar.gz: 33334bf1404877fbbe62172c2f1f18ca54849c4e5b4ed8fa9e5f5ca0f1defce5
5
5
  SHA512:
6
- metadata.gz: 7d6d31a3c3c26c74602812e6c822605acaa43548af427fd62f1f6d5f9e42390b09cb5d54f78fa593851dcf9db103624309450d933bde7ae5868ac1d2b0c1e8b2
7
- data.tar.gz: a62754daf2fc0c57b950c60874870844692770e911a9ff8f8b7d770576ebc2c64f9043962192526c1d00d9c4bfa4417bc85237f2a07cb67f01eda2efbdc687b0
6
+ metadata.gz: 417c8864eb697e8009d16941ddceb796e4ebb36b8d4163ff6f8ff94be40a188f4d70a27091c1a6d4ef9972cd73baa9aed24aaa12fcc71d2abb7c8c8d50613bbb
7
+ data.tar.gz: 327d05ab66eac55749a5e455cb80e2d953277fc557bb1a47bb0d707b734c82149fb59060eafce34373586755b58a9af9aa6a591cecfa646429344b9e1a98d0dd
@@ -1,6 +1,5 @@
1
1
  require 'vcr/util/hooks'
2
2
  require 'uri'
3
- require 'cgi'
4
3
 
5
4
  module VCR
6
5
  # Stores the VCR configuration.
@@ -142,7 +141,7 @@ module VCR
142
141
  # The `#==` method must return true if both objects represent the
143
142
  # same query string.
144
143
  #
145
- # This defaults to `CGI.parse` from the ruby standard library.
144
+ # This defaults to `URI.decode_www_form` from the ruby standard library.
146
145
  #
147
146
  # @overload query_parser
148
147
  # @return [#call] the current query string parser object
@@ -502,7 +501,13 @@ module VCR
502
501
  }
503
502
 
504
503
  self.uri_parser = URI
505
- self.query_parser = CGI.method(:parse)
504
+ # Use URI.decode_www_form instead of CGI.parse for Ruby 3.5+ compatibility
505
+ # Convert the array of pairs format to CGI.parse's hash of arrays format
506
+ self.query_parser = lambda do |query_string|
507
+ result = Hash.new { |h, k| h[k] = [] }
508
+ URI.decode_www_form(query_string.to_s).each { |k, v| result[k] << v }
509
+ result
510
+ end
506
511
  self.debug_logger = nil
507
512
 
508
513
  register_built_in_hooks
data/lib/vcr/structs.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'base64'
2
1
  require 'delegate'
3
2
  require 'time'
4
3
 
@@ -18,46 +17,36 @@ module VCR
18
17
  hash = hash_or_string
19
18
 
20
19
  if hash.has_key?('base64_string')
21
- string = Base64.decode64(hash['base64_string'])
22
- force_encode_string(string, hash['encoding'])
20
+ base64_decoded = hash['base64_string'].unpack1('m')
21
+ force_encode_string(base64_decoded, hash['encoding'])
23
22
  else
24
23
  try_encode_string(hash['string'], hash['encoding'])
25
24
  end
26
25
  end
27
26
 
28
- if "".respond_to?(:encoding)
29
- def force_encode_string(string, encoding)
30
- return string unless encoding
31
- string.force_encoding(encoding)
32
- end
33
-
34
- def try_encode_string(string, encoding_name)
35
- return string if encoding_name.nil?
27
+ def force_encode_string(string, encoding)
28
+ return string unless encoding
29
+ string.force_encoding(encoding)
30
+ end
36
31
 
37
- encoding = Encoding.find(encoding_name)
38
- return string if string.encoding == encoding
32
+ def try_encode_string(string, encoding_name)
33
+ return string if encoding_name.nil? || string.nil?
39
34
 
40
- # ASCII-8BIT just means binary, so encoding to it is nonsensical
41
- # and yet "\u00f6".encode("ASCII-8BIT") raises an error.
42
- # Instead, we'll force encode it (essentially just tagging it as binary)
43
- return string.force_encoding(encoding) if encoding == Encoding::BINARY
35
+ encoding = Encoding.find(encoding_name)
36
+ return string if string.encoding == encoding
44
37
 
45
- string.encode(encoding)
46
- rescue EncodingError => e
47
- struct_type = name.split('::').last.downcase
48
- warn "VCR: got `#{e.class.name}: #{e.message}` while trying to encode the #{string.encoding.name} " +
49
- "#{struct_type} body to the original body encoding (#{encoding}). Consider using the " +
50
- "`:preserve_exact_body_bytes` option to work around this."
51
- return string
52
- end
53
- else
54
- def force_encode_string(string, encoding)
55
- string
56
- end
38
+ # ASCII-8BIT just means binary, so encoding to it is nonsensical
39
+ # and yet "\u00f6".encode("ASCII-8BIT") raises an error.
40
+ # Instead, we'll force encode it (essentially just tagging it as binary)
41
+ return string.force_encoding(encoding) if encoding == Encoding::BINARY
57
42
 
58
- def try_encode_string(string, encoding)
59
- string
60
- end
43
+ string.encode(encoding)
44
+ rescue EncodingError => e
45
+ struct_type = name.split('::').last.downcase
46
+ warn "VCR: got `#{e.class.name}: #{e.message}` while trying to encode the #{string.encoding.name} " +
47
+ "#{struct_type} body to the original body encoding (#{encoding}). Consider using the " +
48
+ "`:preserve_exact_body_bytes` option to work around this."
49
+ return string
61
50
  end
62
51
  end
63
52
 
@@ -85,20 +74,15 @@ module VCR
85
74
  body = String.new(self.body.to_s)
86
75
 
87
76
  if VCR.configuration.preserve_exact_body_bytes_for?(self)
88
- base_body_hash(body).merge('base64_string' => Base64.encode64(body))
77
+ base64_encoded = [body].pack('m')
78
+ base_body_hash(body).merge('base64_string' => base64_encoded)
89
79
  else
90
80
  base_body_hash(body).merge('string' => body)
91
81
  end
92
82
  end
93
83
 
94
- if ''.respond_to?(:encoding)
95
- def base_body_hash(body)
96
- { 'encoding' => body.encoding.name }
97
- end
98
- else
99
- def base_body_hash(body)
100
- { }
101
- end
84
+ def base_body_hash(body)
85
+ { 'encoding' => body.encoding.name }
102
86
  end
103
87
  end
104
88
 
@@ -416,9 +400,7 @@ module VCR
416
400
  case type
417
401
  when 'gzip'
418
402
  body_str = ''
419
- args = [StringIO.new(body_str)]
420
- args << { :encoding => 'ASCII-8BIT' } if ''.respond_to?(:encoding)
421
- writer = Zlib::GzipWriter.new(*args)
403
+ writer = Zlib::GzipWriter.new(StringIO.new(body_str), encoding: 'ASCII-8BIT')
422
404
  writer.write(body)
423
405
  writer.close
424
406
  body_str
@@ -457,10 +439,7 @@ module VCR
457
439
 
458
440
  case type
459
441
  when 'gzip'
460
- gzip_reader_options = {}
461
- gzip_reader_options[:encoding] = 'ASCII-8BIT' if ''.respond_to?(:encoding)
462
- yield Zlib::GzipReader.new(StringIO.new(body),
463
- **gzip_reader_options).read
442
+ yield Zlib::GzipReader.new(StringIO.new(body), encoding: 'ASCII-8BIT').read
464
443
  when 'deflate'
465
444
  yield Zlib::Inflate.inflate(body)
466
445
  when 'identity', NilClass
data/lib/vcr/version.rb CHANGED
@@ -10,7 +10,7 @@ module VCR
10
10
  # * `parts` [Array<Integer>] List of the version parts.
11
11
  def version
12
12
  @version ||= begin
13
- string = +'6.3.1'
13
+ string = +'6.4.0'
14
14
 
15
15
  def string.parts
16
16
  split('.').map { |p| p.to_i }
metadata CHANGED
@@ -1,31 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vcr
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.3.1
4
+ version: 6.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Myron Marston
8
8
  - Kurtis Rainbolt-Greene
9
9
  - Olle Jonsson
10
- autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2024-08-20 00:00:00.000000000 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: base64
17
- requirement: !ruby/object:Gem::Requirement
18
- requirements:
19
- - - ">="
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- version: '0'
12
+ date: 1980-01-02 00:00:00.000000000 Z
13
+ dependencies: []
29
14
  description: Record your test suite's HTTP interactions and replay them during future
30
15
  test runs for fast, deterministic, accurate tests.
31
16
  email:
@@ -77,8 +62,9 @@ homepage: https://benoittgt.github.io/vcr
77
62
  licenses:
78
63
  - Hippocratic-2.1
79
64
  - MIT
80
- metadata: {}
81
- post_install_message:
65
+ metadata:
66
+ changelog_uri: https://github.com/vcr/vcr/blob/v6.4.0/CHANGELOG.md
67
+ funding_uri: https://opencollective.com/vcr
82
68
  rdoc_options: []
83
69
  require_paths:
84
70
  - lib
@@ -93,8 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
79
  - !ruby/object:Gem::Version
94
80
  version: '0'
95
81
  requirements: []
96
- rubygems_version: 3.5.16
97
- signing_key:
82
+ rubygems_version: 4.0.1
98
83
  specification_version: 4
99
84
  summary: Record your test suite's HTTP interactions and replay them during future
100
85
  test runs for fast, deterministic, accurate tests.