rubygems-update 3.7.2 → 4.0.0.beta2

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.
Files changed (211) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1431 -1323
  3. data/CODE_OF_CONDUCT.md +7 -129
  4. data/Manifest.txt +5 -11
  5. data/README.md +2 -2
  6. data/bundler/CHANGELOG.md +1011 -917
  7. data/bundler/README.md +4 -4
  8. data/bundler/bundler.gemspec +3 -3
  9. data/bundler/lib/bundler/build_metadata.rb +2 -2
  10. data/bundler/lib/bundler/capistrano.rb +1 -19
  11. data/bundler/lib/bundler/cli/cache.rb +1 -11
  12. data/bundler/lib/bundler/cli/common.rb +20 -3
  13. data/bundler/lib/bundler/cli/config.rb +1 -2
  14. data/bundler/lib/bundler/cli/console.rb +5 -0
  15. data/bundler/lib/bundler/cli/exec.rb +29 -4
  16. data/bundler/lib/bundler/cli/gem.rb +19 -33
  17. data/bundler/lib/bundler/cli/install.rb +9 -82
  18. data/bundler/lib/bundler/cli/issue.rb +2 -2
  19. data/bundler/lib/bundler/cli/list.rb +33 -2
  20. data/bundler/lib/bundler/cli/plugin.rb +5 -1
  21. data/bundler/lib/bundler/cli/show.rb +1 -1
  22. data/bundler/lib/bundler/cli/update.rb +3 -3
  23. data/bundler/lib/bundler/cli.rb +91 -85
  24. data/bundler/lib/bundler/compact_index_client.rb +0 -1
  25. data/bundler/lib/bundler/current_ruby.rb +3 -15
  26. data/bundler/lib/bundler/definition.rb +65 -36
  27. data/bundler/lib/bundler/deployment.rb +1 -64
  28. data/bundler/lib/bundler/digest.rb +1 -1
  29. data/bundler/lib/bundler/dsl.rb +26 -36
  30. data/bundler/lib/bundler/endpoint_specification.rb +0 -22
  31. data/bundler/lib/bundler/environment_preserver.rb +1 -0
  32. data/bundler/lib/bundler/errors.rb +1 -5
  33. data/bundler/lib/bundler/feature_flag.rb +0 -33
  34. data/bundler/lib/bundler/fetcher/compact_index.rb +1 -1
  35. data/bundler/lib/bundler/friendly_errors.rb +2 -2
  36. data/bundler/lib/bundler/index.rb +0 -7
  37. data/bundler/lib/bundler/inline.rb +9 -1
  38. data/bundler/lib/bundler/installer/gem_installer.rb +0 -11
  39. data/bundler/lib/bundler/installer.rb +0 -6
  40. data/bundler/lib/bundler/lockfile_generator.rb +1 -1
  41. data/bundler/lib/bundler/lockfile_parser.rb +2 -12
  42. data/bundler/lib/bundler/man/bundle-add.1 +1 -1
  43. data/bundler/lib/bundler/man/bundle-binstubs.1 +3 -6
  44. data/bundler/lib/bundler/man/bundle-binstubs.1.ronn +4 -6
  45. data/bundler/lib/bundler/man/bundle-cache.1 +2 -14
  46. data/bundler/lib/bundler/man/bundle-cache.1.ronn +1 -14
  47. data/bundler/lib/bundler/man/bundle-check.1 +2 -5
  48. data/bundler/lib/bundler/man/bundle-check.1.ronn +0 -5
  49. data/bundler/lib/bundler/man/bundle-clean.1 +1 -1
  50. data/bundler/lib/bundler/man/bundle-config.1 +9 -33
  51. data/bundler/lib/bundler/man/bundle-config.1.ronn +24 -55
  52. data/bundler/lib/bundler/man/bundle-console.1 +1 -1
  53. data/bundler/lib/bundler/man/bundle-doctor.1 +1 -1
  54. data/bundler/lib/bundler/man/bundle-env.1 +1 -1
  55. data/bundler/lib/bundler/man/bundle-exec.1 +2 -5
  56. data/bundler/lib/bundler/man/bundle-exec.1.ronn +1 -5
  57. data/bundler/lib/bundler/man/bundle-fund.1 +1 -1
  58. data/bundler/lib/bundler/man/bundle-gem.1 +3 -6
  59. data/bundler/lib/bundler/man/bundle-gem.1.ronn +2 -5
  60. data/bundler/lib/bundler/man/bundle-help.1 +1 -1
  61. data/bundler/lib/bundler/man/bundle-info.1 +1 -1
  62. data/bundler/lib/bundler/man/bundle-init.1 +1 -1
  63. data/bundler/lib/bundler/man/bundle-install.1 +14 -57
  64. data/bundler/lib/bundler/man/bundle-install.1.ronn +25 -105
  65. data/bundler/lib/bundler/man/bundle-issue.1 +1 -1
  66. data/bundler/lib/bundler/man/bundle-licenses.1 +1 -1
  67. data/bundler/lib/bundler/man/bundle-list.1 +6 -1
  68. data/bundler/lib/bundler/man/bundle-list.1.ronn +5 -0
  69. data/bundler/lib/bundler/man/bundle-lock.1 +1 -1
  70. data/bundler/lib/bundler/man/bundle-open.1 +1 -1
  71. data/bundler/lib/bundler/man/bundle-outdated.1 +1 -1
  72. data/bundler/lib/bundler/man/bundle-platform.1 +1 -1
  73. data/bundler/lib/bundler/man/bundle-plugin.1 +2 -9
  74. data/bundler/lib/bundler/man/bundle-plugin.1.ronn +0 -8
  75. data/bundler/lib/bundler/man/bundle-pristine.1 +1 -1
  76. data/bundler/lib/bundler/man/bundle-remove.1 +2 -8
  77. data/bundler/lib/bundler/man/bundle-remove.1.ronn +1 -8
  78. data/bundler/lib/bundler/man/bundle-show.1 +2 -5
  79. data/bundler/lib/bundler/man/bundle-show.1.ronn +0 -4
  80. data/bundler/lib/bundler/man/bundle-update.1 +1 -1
  81. data/bundler/lib/bundler/man/bundle-version.1 +1 -1
  82. data/bundler/lib/bundler/man/bundle.1 +1 -10
  83. data/bundler/lib/bundler/man/bundle.1.ronn +0 -9
  84. data/bundler/lib/bundler/man/gemfile.5 +32 -1
  85. data/bundler/lib/bundler/man/gemfile.5.ronn +28 -0
  86. data/bundler/lib/bundler/man/index.txt +0 -2
  87. data/bundler/lib/bundler/materialization.rb +1 -1
  88. data/bundler/lib/bundler/plugin/installer.rb +0 -10
  89. data/bundler/lib/bundler/plugin/source_list.rb +1 -1
  90. data/bundler/lib/bundler/plugin.rb +1 -1
  91. data/bundler/lib/bundler/resolver.rb +1 -1
  92. data/bundler/lib/bundler/ruby_dsl.rb +2 -0
  93. data/bundler/lib/bundler/ruby_version.rb +1 -3
  94. data/bundler/lib/bundler/rubygems_ext.rb +1 -1
  95. data/bundler/lib/bundler/rubygems_gem_installer.rb +1 -1
  96. data/bundler/lib/bundler/rubygems_integration.rb +1 -5
  97. data/bundler/lib/bundler/runtime.rb +5 -1
  98. data/bundler/lib/bundler/self_manager.rb +1 -1
  99. data/bundler/lib/bundler/settings.rb +8 -26
  100. data/bundler/lib/bundler/shared_helpers.rb +12 -20
  101. data/bundler/lib/bundler/source/git/git_proxy.rb +3 -11
  102. data/bundler/lib/bundler/source/git.rb +2 -3
  103. data/bundler/lib/bundler/source/path.rb +3 -7
  104. data/bundler/lib/bundler/source/rubygems.rb +11 -17
  105. data/bundler/lib/bundler/source.rb +1 -1
  106. data/bundler/lib/bundler/source_list.rb +4 -45
  107. data/bundler/lib/bundler/source_map.rb +2 -5
  108. data/bundler/lib/bundler/spec_set.rb +6 -15
  109. data/bundler/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +7 -129
  110. data/bundler/lib/bundler/templates/newgem/Rakefile.tt +5 -0
  111. data/bundler/lib/bundler/templates/newgem/circleci/config.yml.tt +12 -0
  112. data/bundler/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +1 -1
  113. data/bundler/lib/bundler/templates/newgem/ext/newgem/extconf-go.rb.tt +11 -0
  114. data/bundler/lib/bundler/templates/newgem/ext/newgem/go.mod.tt +5 -0
  115. data/bundler/lib/bundler/templates/newgem/ext/newgem/newgem-go.c.tt +2 -0
  116. data/bundler/lib/bundler/templates/newgem/ext/newgem/newgem.go.tt +31 -0
  117. data/bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt +6 -0
  118. data/bundler/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
  119. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +4 -1
  120. data/bundler/lib/bundler/ui/shell.rb +10 -6
  121. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +26 -23
  122. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  123. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +50 -6
  124. data/bundler/lib/bundler/vendor/fileutils/lib/fileutils.rb +57 -52
  125. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +5 -2
  126. data/bundler/lib/bundler/vendor/thor/lib/thor/runner.rb +1 -1
  127. data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +57 -15
  128. data/bundler/lib/bundler/vendor/uri/lib/uri/file.rb +1 -1
  129. data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +34 -21
  130. data/bundler/lib/bundler/vendor/uri/lib/uri/http.rb +12 -0
  131. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +9 -8
  132. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +2 -2
  133. data/bundler/lib/bundler/version.rb +1 -1
  134. data/bundler/lib/bundler/vlad.rb +1 -14
  135. data/bundler/lib/bundler.rb +6 -28
  136. data/doc/MAINTAINERS.txt +0 -7
  137. data/doc/bundler/UPGRADING.md +11 -5
  138. data/doc/rubygems/CONTRIBUTING.md +1 -1
  139. data/lib/rubygems/basic_specification.rb +3 -9
  140. data/lib/rubygems/bundler_version_finder.rb +38 -3
  141. data/lib/rubygems/command.rb +1 -1
  142. data/lib/rubygems/command_manager.rb +3 -4
  143. data/lib/rubygems/commands/build_command.rb +0 -7
  144. data/lib/rubygems/commands/cert_command.rb +1 -1
  145. data/lib/rubygems/commands/install_command.rb +1 -5
  146. data/lib/rubygems/commands/setup_command.rb +5 -3
  147. data/lib/rubygems/config_file.rb +1 -1
  148. data/lib/rubygems/dependency.rb +1 -1
  149. data/lib/rubygems/dependency_installer.rb +0 -77
  150. data/lib/rubygems/dependency_list.rb +1 -2
  151. data/lib/rubygems/deprecate.rb +74 -72
  152. data/lib/rubygems/doctor.rb +1 -1
  153. data/lib/rubygems/errors.rb +1 -1
  154. data/lib/rubygems/exceptions.rb +2 -3
  155. data/lib/rubygems/ext/builder.rb +6 -2
  156. data/lib/rubygems/ext/cargo_builder.rb +2 -2
  157. data/lib/rubygems/ext/cmake_builder.rb +97 -8
  158. data/lib/rubygems/ext/configure_builder.rb +2 -2
  159. data/lib/rubygems/ext/ext_conf_builder.rb +6 -2
  160. data/lib/rubygems/ext/rake_builder.rb +2 -2
  161. data/lib/rubygems/gem_runner.rb +0 -1
  162. data/lib/rubygems/install_update_options.rb +1 -2
  163. data/lib/rubygems/installer.rb +16 -54
  164. data/lib/rubygems/name_tuple.rb +7 -1
  165. data/lib/rubygems/package/tar_header.rb +4 -4
  166. data/lib/rubygems/package/tar_reader.rb +2 -0
  167. data/lib/rubygems/package/tar_writer.rb +1 -1
  168. data/lib/rubygems/package.rb +21 -12
  169. data/lib/rubygems/platform.rb +31 -11
  170. data/lib/rubygems/remote_fetcher.rb +8 -5
  171. data/lib/rubygems/resolver/conflict.rb +1 -1
  172. data/lib/rubygems/resolver.rb +1 -1
  173. data/lib/rubygems/security/signer.rb +1 -1
  174. data/lib/rubygems/source.rb +2 -2
  175. data/lib/rubygems/spec_fetcher.rb +4 -4
  176. data/lib/rubygems/specification.rb +5 -96
  177. data/lib/rubygems/specification_policy.rb +0 -36
  178. data/lib/rubygems/specification_record.rb +1 -1
  179. data/lib/rubygems/text.rb +1 -1
  180. data/lib/rubygems/uninstaller.rb +17 -6
  181. data/lib/rubygems/user_interaction.rb +6 -9
  182. data/lib/rubygems/util.rb +0 -22
  183. data/lib/rubygems/validator.rb +1 -1
  184. data/lib/rubygems/vendor/net-http/lib/net/http/generic_request.rb +25 -9
  185. data/lib/rubygems/vendor/net-http/lib/net/http/responses.rb +2 -2
  186. data/lib/rubygems/vendor/net-http/lib/net/http.rb +14 -14
  187. data/lib/rubygems/vendor/optparse/lib/optparse.rb +82 -41
  188. data/lib/rubygems/vendor/resolv/lib/resolv.rb +1 -1
  189. data/lib/rubygems/vendor/timeout/lib/timeout.rb +4 -1
  190. data/lib/rubygems/vendor/uri/lib/uri/common.rb +57 -15
  191. data/lib/rubygems/vendor/uri/lib/uri/file.rb +1 -1
  192. data/lib/rubygems/vendor/uri/lib/uri/generic.rb +34 -21
  193. data/lib/rubygems/vendor/uri/lib/uri/http.rb +12 -0
  194. data/lib/rubygems/vendor/uri/lib/uri/rfc2396_parser.rb +9 -8
  195. data/lib/rubygems/vendor/uri/lib/uri/version.rb +2 -2
  196. data/lib/rubygems/version.rb +8 -20
  197. data/lib/rubygems/win_platform.rb +31 -0
  198. data/lib/rubygems.rb +12 -40
  199. data/rubygems-update.gemspec +6 -4
  200. metadata +10 -18
  201. data/bundler/lib/bundler/cli/inject.rb +0 -60
  202. data/bundler/lib/bundler/cli/viz.rb +0 -31
  203. data/bundler/lib/bundler/graph.rb +0 -152
  204. data/bundler/lib/bundler/man/bundle-inject.1 +0 -31
  205. data/bundler/lib/bundler/man/bundle-inject.1.ronn +0 -32
  206. data/bundler/lib/bundler/man/bundle-viz.1 +0 -30
  207. data/bundler/lib/bundler/man/bundle-viz.1.ronn +0 -36
  208. data/bundler/lib/bundler/similarity_detector.rb +0 -63
  209. data/lib/rubygems/commands/query_command.rb +0 -43
  210. data/lib/rubygems/compatibility.rb +0 -41
  211. data/lib/rubygems/install_default_message.rb +0 -13
@@ -8,7 +8,6 @@
8
8
 
9
9
  require_relative "installer_uninstaller_utils"
10
10
  require_relative "exceptions"
11
- require_relative "deprecate"
12
11
  require_relative "package"
13
12
  require_relative "ext"
14
13
  require_relative "user_interaction"
@@ -27,8 +26,6 @@ require_relative "user_interaction"
27
26
  # file. See Gem.pre_install and Gem.post_install for details.
28
27
 
29
28
  class Gem::Installer
30
- extend Gem::Deprecate
31
-
32
29
  ##
33
30
  # Paths where env(1) might live. Some systems are broken and have it in
34
31
  # /bin
@@ -67,23 +64,6 @@ class Gem::Installer
67
64
  attr_reader :package
68
65
 
69
66
  class << self
70
- #
71
- # Changes in rubygems to lazily loading `rubygems/command` (in order to
72
- # lazily load `optparse` as a side effect) affect bundler's custom installer
73
- # which uses `Gem::Command` without requiring it (up until bundler 2.2.29).
74
- # This hook is to compensate for that missing require.
75
- #
76
- # TODO: Remove when rubygems no longer supports running on bundler older
77
- # than 2.2.29.
78
-
79
- def inherited(klass)
80
- if klass.name == "Bundler::RubyGemsGemInstaller"
81
- require "rubygems/command"
82
- end
83
-
84
- super(klass)
85
- end
86
-
87
67
  ##
88
68
  # Overrides the executable format.
89
69
  #
@@ -170,7 +150,7 @@ class Gem::Installer
170
150
  # process. If not set, then Gem::Command.build_args is used
171
151
  # :post_install_message:: Print gem post install message if true
172
152
 
173
- def initialize(package, options={})
153
+ def initialize(package, options = {})
174
154
  require "fileutils"
175
155
 
176
156
  @options = options
@@ -291,11 +271,7 @@ class Gem::Installer
291
271
  run_pre_install_hooks
292
272
 
293
273
  # Set loaded_from to ensure extension_dir is correct
294
- if @options[:install_as_default]
295
- spec.loaded_from = default_spec_file
296
- else
297
- spec.loaded_from = spec_file
298
- end
274
+ spec.loaded_from = spec_file
299
275
 
300
276
  # Completely remove any previous gem files
301
277
  FileUtils.rm_rf gem_dir
@@ -304,24 +280,17 @@ class Gem::Installer
304
280
  dir_mode = options[:dir_mode]
305
281
  FileUtils.mkdir_p gem_dir, mode: dir_mode && 0o755
306
282
 
307
- if @options[:install_as_default]
308
- extract_bin
309
- write_default_spec
310
- else
311
- extract_files
283
+ extract_files
312
284
 
313
- build_extensions
314
- write_build_info_file
315
- run_post_build_hooks
316
- end
285
+ build_extensions
286
+ write_build_info_file
287
+ run_post_build_hooks
317
288
 
318
289
  generate_bin
319
290
  generate_plugins
320
291
 
321
- unless @options[:install_as_default]
322
- write_spec
323
- write_cache_file
324
- end
292
+ write_spec
293
+ write_cache_file
325
294
 
326
295
  File.chmod(dir_mode, gem_dir) if dir_mode
327
296
 
@@ -409,15 +378,6 @@ class Gem::Installer
409
378
  !dependency.matching_specs.empty?
410
379
  end
411
380
 
412
- ##
413
- # Unpacks the gem into the given directory.
414
-
415
- def unpack(directory)
416
- @gem_dir = directory
417
- extract_files
418
- end
419
- rubygems_deprecate :unpack
420
-
421
381
  ##
422
382
  # The location of the spec file that is installed.
423
383
  #
@@ -426,12 +386,18 @@ class Gem::Installer
426
386
  File.join gem_home, "specifications", "#{spec.full_name}.gemspec"
427
387
  end
428
388
 
389
+ def default_spec_dir
390
+ dir = File.join(gem_home, "specifications", "default")
391
+ FileUtils.mkdir_p dir
392
+ dir
393
+ end
394
+
429
395
  ##
430
396
  # The location of the default spec file for default gems.
431
397
  #
432
398
 
433
399
  def default_spec_file
434
- File.join gem_home, "specifications", "default", "#{spec.full_name}.gemspec"
400
+ File.join default_spec_dir, "#{spec.full_name}.gemspec"
435
401
  end
436
402
 
437
403
  ##
@@ -906,11 +872,7 @@ class Gem::Installer
906
872
 
907
873
  ensure_loadable_spec
908
874
 
909
- if options[:install_as_default]
910
- Gem.ensure_default_gem_subdirectories gem_home
911
- else
912
- Gem.ensure_gem_subdirectories gem_home
913
- end
875
+ Gem.ensure_gem_subdirectories gem_home
914
876
 
915
877
  return true if @force
916
878
 
@@ -6,7 +6,7 @@
6
6
  # wrap the data returned from the indexes.
7
7
 
8
8
  class Gem::NameTuple
9
- def initialize(name, version, platform=Gem::Platform::RUBY)
9
+ def initialize(name, version, platform = Gem::Platform::RUBY)
10
10
  @name = name
11
11
  @version = version
12
12
 
@@ -81,6 +81,12 @@ class Gem::NameTuple
81
81
  [@name, @version, @platform]
82
82
  end
83
83
 
84
+ alias_method :deconstruct, :to_a
85
+
86
+ def deconstruct_keys(keys)
87
+ { name: @name, version: @version, platform: @platform }
88
+ end
89
+
84
90
  def inspect # :nodoc:
85
91
  "#<Gem::NameTuple #{@name}, #{@version}, #{@platform}>"
86
92
  end
@@ -56,7 +56,7 @@ class Gem::Package::TarHeader
56
56
  ##
57
57
  # Pack format for a tar header
58
58
 
59
- PACK_FORMAT = "a100" + # name
59
+ PACK_FORMAT = ("a100" + # name
60
60
  "a8" + # mode
61
61
  "a8" + # uid
62
62
  "a8" + # gid
@@ -71,12 +71,12 @@ class Gem::Package::TarHeader
71
71
  "a32" + # gname
72
72
  "a8" + # devmajor
73
73
  "a8" + # devminor
74
- "a155" # prefix
74
+ "a155").freeze # prefix
75
75
 
76
76
  ##
77
77
  # Unpack format for a tar header
78
78
 
79
- UNPACK_FORMAT = "A100" + # name
79
+ UNPACK_FORMAT = ("A100" + # name
80
80
  "A8" + # mode
81
81
  "A8" + # uid
82
82
  "A8" + # gid
@@ -91,7 +91,7 @@ class Gem::Package::TarHeader
91
91
  "A32" + # gname
92
92
  "A8" + # devmajor
93
93
  "A8" + # devminor
94
- "A155" # prefix
94
+ "A155").freeze # prefix
95
95
 
96
96
  attr_reader(*FIELDS)
97
97
 
@@ -30,6 +30,8 @@ class Gem::Package::TarReader
30
30
  nil
31
31
  end
32
32
 
33
+ attr_reader :io # :nodoc:
34
+
33
35
  ##
34
36
  # Creates a new tar file reader on +io+ which needs to respond to #pos,
35
37
  # #eof?, #read, #getc and #pos=
@@ -99,7 +99,7 @@ class Gem::Package::TarWriter
99
99
  # Gem.source_date_epoch if not specified), and yields an IO for
100
100
  # writing the file to
101
101
 
102
- def add_file(name, mode, mtime=nil) # :yields: io
102
+ def add_file(name, mode, mtime = nil) # :yields: io
103
103
  check_closed
104
104
 
105
105
  name, prefix = split_name name
@@ -7,6 +7,7 @@
7
7
 
8
8
  # rubocop:enable Style/AsciiComments
9
9
 
10
+ require_relative "win_platform"
10
11
  require_relative "security"
11
12
  require_relative "user_interaction"
12
13
 
@@ -267,7 +268,7 @@ class Gem::Package
267
268
 
268
269
  tar.add_file_simple file, stat.mode, stat.size do |dst_io|
269
270
  File.open file, "rb" do |src_io|
270
- copy_stream(src_io, dst_io)
271
+ copy_stream(src_io, dst_io, stat.size)
271
272
  end
272
273
  end
273
274
  end
@@ -436,8 +437,6 @@ EOM
436
437
  symlinks << [full_name, link_target, destination, real_destination]
437
438
  end
438
439
 
439
- FileUtils.rm_rf destination
440
-
441
440
  mkdir =
442
441
  if entry.directory?
443
442
  destination
@@ -451,8 +450,14 @@ EOM
451
450
  end
452
451
 
453
452
  if entry.file?
454
- File.open(destination, "wb") {|out| copy_stream(entry, out) }
455
- FileUtils.chmod file_mode(entry.header.mode) & ~File.umask, destination
453
+ File.open(destination, "wb") do |out|
454
+ copy_stream(tar.io, out, entry.size)
455
+ # Flush needs to happen before chmod because there could be data
456
+ # in the IO buffer that needs to be written, and that could be
457
+ # written after the chmod (on close) which would mess up the perms
458
+ out.flush
459
+ out.chmod file_mode(entry.header.mode) & ~File.umask
460
+ end
456
461
  end
457
462
 
458
463
  verbose destination
@@ -514,10 +519,12 @@ EOM
514
519
  destination
515
520
  end
516
521
 
517
- def normalize_path(pathname)
518
- if Gem.win_platform?
522
+ if Gem.win_platform?
523
+ def normalize_path(pathname) # :nodoc:
519
524
  pathname.downcase
520
- else
525
+ end
526
+ else
527
+ def normalize_path(pathname) # :nodoc:
521
528
  pathname
522
529
  end
523
530
  end
@@ -635,6 +642,8 @@ EOM
635
642
  raise Gem::Package::FormatError.new e.message, @gem
636
643
  end
637
644
 
645
+ private
646
+
638
647
  ##
639
648
  # Verifies the +checksums+ against the +digests+. This check is not
640
649
  # cryptographically secure. Missing checksums are ignored.
@@ -715,12 +724,12 @@ EOM
715
724
  end
716
725
 
717
726
  if RUBY_ENGINE == "truffleruby"
718
- def copy_stream(src, dst) # :nodoc:
719
- dst.write src.read
727
+ def copy_stream(src, dst, size) # :nodoc:
728
+ dst.write src.read(size)
720
729
  end
721
730
  else
722
- def copy_stream(src, dst) # :nodoc:
723
- IO.copy_stream(src, dst)
731
+ def copy_stream(src, dst, size) # :nodoc:
732
+ IO.copy_stream(src, dst, size)
724
733
  end
725
734
  end
726
735
 
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "deprecate"
4
-
5
3
  ##
6
4
  # Available list of platforms for targeting Gem installations.
7
5
  #
@@ -21,15 +19,6 @@ class Gem::Platform
21
19
  end
22
20
  end
23
21
 
24
- def self.match(platform)
25
- match_platforms?(platform, Gem.platforms)
26
- end
27
-
28
- class << self
29
- extend Gem::Deprecate
30
- rubygems_deprecate :match, "Gem::Platform.match_spec? or match_gem?"
31
- end
32
-
33
22
  def self.match_platforms?(platform, platforms)
34
23
  platform = Gem::Platform.new(platform) unless platform.is_a?(Gem::Platform)
35
24
  platforms.any? do |local_platform|
@@ -146,6 +135,37 @@ class Gem::Platform
146
135
  to_a.compact.join(@cpu.nil? ? "" : "-")
147
136
  end
148
137
 
138
+ ##
139
+ # Deconstructs the platform into an array for pattern matching.
140
+ # Returns [cpu, os, version].
141
+ #
142
+ # Gem::Platform.new("x86_64-linux").deconstruct #=> ["x86_64", "linux", nil]
143
+ #
144
+ # This enables array pattern matching:
145
+ #
146
+ # case Gem::Platform.new("arm64-darwin-21")
147
+ # in ["arm64", "darwin", version]
148
+ # # version => "21"
149
+ # end
150
+ alias_method :deconstruct, :to_a
151
+
152
+ ##
153
+ # Deconstructs the platform into a hash for pattern matching.
154
+ # Returns a hash with keys +:cpu+, +:os+, and +:version+.
155
+ #
156
+ # Gem::Platform.new("x86_64-darwin-20").deconstruct_keys(nil)
157
+ # #=> { cpu: "x86_64", os: "darwin", version: "20" }
158
+ #
159
+ # This enables hash pattern matching:
160
+ #
161
+ # case Gem::Platform.new("x86_64-linux")
162
+ # in cpu: "x86_64", os: "linux"
163
+ # # Matches Linux on x86_64
164
+ # end
165
+ def deconstruct_keys(keys)
166
+ { cpu: @cpu, os: @os, version: @version }
167
+ end
168
+
149
169
  ##
150
170
  # Is +other+ equal to this platform? Two platforms are equal if they have
151
171
  # the same CPU, OS and version.
@@ -72,7 +72,7 @@ class Gem::RemoteFetcher
72
72
  # +headers+: A set of additional HTTP headers to be sent to the server when
73
73
  # fetching the gem.
74
74
 
75
- def initialize(proxy=nil, dns=nil, headers={})
75
+ def initialize(proxy = nil, dns = nil, headers = {})
76
76
  require_relative "core_ext/tcpsocket_init" if Gem.configuration.ipv4_fallback_enabled
77
77
  require_relative "vendored_net_http"
78
78
  require_relative "vendor/uri/lib/uri"
@@ -245,11 +245,14 @@ class Gem::RemoteFetcher
245
245
  def fetch_path(uri, mtime = nil, head = false)
246
246
  uri = Gem::Uri.new uri
247
247
 
248
- unless uri.scheme
249
- raise ArgumentError, "uri scheme is invalid: #{uri.scheme.inspect}"
250
- end
248
+ method = {
249
+ "http" => "fetch_http",
250
+ "https" => "fetch_http",
251
+ "s3" => "fetch_s3",
252
+ "file" => "fetch_file",
253
+ }.fetch(uri.scheme) { raise ArgumentError, "uri scheme is invalid: #{uri.scheme.inspect}" }
251
254
 
252
- data = send "fetch_#{uri.scheme}", uri, mtime, head
255
+ data = send method, uri, mtime, head
253
256
 
254
257
  if data && !head && uri.to_s.end_with?(".gz")
255
258
  begin
@@ -21,7 +21,7 @@ class Gem::Resolver::Conflict
21
21
  # Creates a new resolver conflict when +dependency+ is in conflict with an
22
22
  # already +activated+ specification.
23
23
 
24
- def initialize(dependency, activated, failed_dep=dependency)
24
+ def initialize(dependency, activated, failed_dep = dependency)
25
25
  @dependency = dependency
26
26
  @activated = activated
27
27
  @failed_dep = failed_dep
@@ -144,7 +144,7 @@ class Gem::Resolver
144
144
  [spec, activation_request]
145
145
  end
146
146
 
147
- def requests(s, act, reqs=[]) # :nodoc:
147
+ def requests(s, act, reqs = []) # :nodoc:
148
148
  return reqs if @ignore_dependencies
149
149
 
150
150
  s.fetch_development_dependencies if @development
@@ -52,7 +52,7 @@ class Gem::Security::Signer
52
52
  re_signed_cert = Gem::Security.re_sign(
53
53
  expired_cert,
54
54
  private_key,
55
- (Gem::Security::ONE_DAY * Gem.configuration.cert_expiration_length_days)
55
+ Gem::Security::ONE_DAY * Gem.configuration.cert_expiration_length_days
56
56
  )
57
57
 
58
58
  Gem::Security.write(re_signed_cert, expired_cert_path)
@@ -190,7 +190,7 @@ class Gem::Source
190
190
  # Downloads +spec+ and writes it to +dir+. See also
191
191
  # Gem::RemoteFetcher#download.
192
192
 
193
- def download(spec, dir=Dir.pwd)
193
+ def download(spec, dir = Dir.pwd)
194
194
  fetcher = Gem::RemoteFetcher.fetcher
195
195
  fetcher.download spec, uri.to_s, dir
196
196
  end
@@ -210,7 +210,7 @@ class Gem::Source
210
210
  end
211
211
  end
212
212
 
213
- def typo_squatting?(host, distance_threshold=4)
213
+ def typo_squatting?(host, distance_threshold = 4)
214
214
  return if @uri.host.nil?
215
215
  levenshtein_distance(@uri.host, host).between? 1, distance_threshold
216
216
  end
@@ -83,7 +83,7 @@ class Gem::SpecFetcher
83
83
  #
84
84
  # If +matching_platform+ is false, gems for all platforms are returned.
85
85
 
86
- def search_for_dependency(dependency, matching_platform=true)
86
+ def search_for_dependency(dependency, matching_platform = true)
87
87
  found = {}
88
88
 
89
89
  rejected_specs = {}
@@ -130,7 +130,7 @@ class Gem::SpecFetcher
130
130
  ##
131
131
  # Return all gem name tuples who's names match +obj+
132
132
 
133
- def detect(type=:complete)
133
+ def detect(type = :complete)
134
134
  tuples = []
135
135
 
136
136
  list, _ = available_specs(type)
@@ -150,7 +150,7 @@ class Gem::SpecFetcher
150
150
  #
151
151
  # If +matching_platform+ is false, gems for all platforms are returned.
152
152
 
153
- def spec_for_dependency(dependency, matching_platform=true)
153
+ def spec_for_dependency(dependency, matching_platform = true)
154
154
  tuples, errors = search_for_dependency(dependency, matching_platform)
155
155
 
156
156
  specs = []
@@ -280,7 +280,7 @@ class Gem::SpecFetcher
280
280
  # Retrieves NameTuples from +source+ of the given +type+ (:prerelease,
281
281
  # etc.). If +gracefully_ignore+ is true, errors are ignored.
282
282
 
283
- def tuples_for(source, type, gracefully_ignore=false) # :nodoc:
283
+ def tuples_for(source, type, gracefully_ignore = false) # :nodoc:
284
284
  @caches[type][source.uri] ||=
285
285
  source.load_specs(type).sort_by(&:name)
286
286
  rescue Gem::RemoteFetcher::FetchError
@@ -7,7 +7,6 @@
7
7
  # See LICENSE.txt for permissions.
8
8
  #++
9
9
 
10
- require_relative "deprecate"
11
10
  require_relative "basic_specification"
12
11
  require_relative "stub_specification"
13
12
  require_relative "platform"
@@ -38,8 +37,6 @@ require "rbconfig"
38
37
  # items you may add to a specification.
39
38
 
40
39
  class Gem::Specification < Gem::BasicSpecification
41
- extend Gem::Deprecate
42
-
43
40
  # REFACTOR: Consider breaking out this version stuff into a separate
44
41
  # module. There's enough special stuff around it that it may justify
45
42
  # a separate class.
@@ -488,8 +485,6 @@ class Gem::Specification < Gem::BasicSpecification
488
485
  end
489
486
 
490
487
  @platform = @new_platform.to_s
491
-
492
- invalidate_memoized_attributes
493
488
  end
494
489
 
495
490
  ##
@@ -737,14 +732,6 @@ class Gem::Specification < Gem::BasicSpecification
737
732
 
738
733
  attr_accessor :autorequire # :nodoc:
739
734
 
740
- ##
741
- # Sets the default executable for this gem.
742
- #
743
- # Deprecated: You must now specify the executable name to Gem.bin_path.
744
-
745
- attr_writer :default_executable
746
- rubygems_deprecate :default_executable=
747
-
748
735
  ##
749
736
  # Allows deinstallation of gems with legacy platforms.
750
737
 
@@ -1321,7 +1308,7 @@ class Gem::Specification < Gem::BasicSpecification
1321
1308
  spec.instance_variable_set :@authors, array[12]
1322
1309
  spec.instance_variable_set :@description, array[13]
1323
1310
  spec.instance_variable_set :@homepage, array[14]
1324
- spec.instance_variable_set :@has_rdoc, array[15]
1311
+ # offset due to has_rdoc removal
1325
1312
  spec.instance_variable_set :@licenses, array[17]
1326
1313
  spec.instance_variable_set :@metadata, array[18]
1327
1314
  spec.instance_variable_set :@loaded, false
@@ -1620,14 +1607,14 @@ class Gem::Specification < Gem::BasicSpecification
1620
1607
  # spec's cached gem.
1621
1608
 
1622
1609
  def cache_dir
1623
- @cache_dir ||= File.join base_dir, "cache"
1610
+ File.join base_dir, "cache"
1624
1611
  end
1625
1612
 
1626
1613
  ##
1627
1614
  # Returns the full path to the cached gem for this spec.
1628
1615
 
1629
1616
  def cache_file
1630
- @cache_file ||= File.join cache_dir, "#{full_name}.gem"
1617
+ File.join cache_dir, "#{full_name}.gem"
1631
1618
  end
1632
1619
 
1633
1620
  ##
@@ -1716,24 +1703,6 @@ class Gem::Specification < Gem::BasicSpecification
1716
1703
  end
1717
1704
  end
1718
1705
 
1719
- ##
1720
- # The default executable for this gem.
1721
- #
1722
- # Deprecated: The name of the gem is assumed to be the name of the
1723
- # executable now. See Gem.bin_path.
1724
-
1725
- def default_executable # :nodoc:
1726
- if defined?(@default_executable) && @default_executable
1727
- result = @default_executable
1728
- elsif @executables && @executables.size == 1
1729
- result = Array(@executables).first
1730
- else
1731
- result = nil
1732
- end
1733
- result
1734
- end
1735
- rubygems_deprecate :default_executable
1736
-
1737
1706
  ##
1738
1707
  # The default value for specification attribute +name+
1739
1708
 
@@ -1757,7 +1726,7 @@ class Gem::Specification < Gem::BasicSpecification
1757
1726
  #
1758
1727
  # [depending_gem, dependency, [list_of_gems_that_satisfy_dependency]]
1759
1728
 
1760
- def dependent_gems(check_dev=true)
1729
+ def dependent_gems(check_dev = true)
1761
1730
  out = []
1762
1731
  Gem::Specification.each do |spec|
1763
1732
  deps = check_dev ? spec.dependencies : spec.runtime_dependencies
@@ -1903,10 +1872,6 @@ class Gem::Specification < Gem::BasicSpecification
1903
1872
  spec
1904
1873
  end
1905
1874
 
1906
- def full_name
1907
- @full_name ||= super
1908
- end
1909
-
1910
1875
  ##
1911
1876
  # Work around old bundler versions removing my methods
1912
1877
  # Can be removed once RubyGems can no longer install Bundler 2.5
@@ -1919,29 +1884,6 @@ class Gem::Specification < Gem::BasicSpecification
1919
1884
  @gems_dir ||= File.join(base_dir, "gems")
1920
1885
  end
1921
1886
 
1922
- ##
1923
- # Deprecated and ignored, defaults to true.
1924
- #
1925
- # Formerly used to indicate this gem was RDoc-capable.
1926
-
1927
- def has_rdoc # :nodoc:
1928
- true
1929
- end
1930
- rubygems_deprecate :has_rdoc
1931
-
1932
- ##
1933
- # Deprecated and ignored.
1934
- #
1935
- # Formerly used to indicate this gem was RDoc-capable.
1936
-
1937
- def has_rdoc=(ignored) # :nodoc:
1938
- @has_rdoc = true
1939
- end
1940
- rubygems_deprecate :has_rdoc=
1941
-
1942
- alias_method :has_rdoc?, :has_rdoc # :nodoc:
1943
- rubygems_deprecate :has_rdoc?
1944
-
1945
1887
  ##
1946
1888
  # True if this gem has files in test_files
1947
1889
 
@@ -2044,17 +1986,6 @@ class Gem::Specification < Gem::BasicSpecification
2044
1986
  end
2045
1987
  end
2046
1988
 
2047
- ##
2048
- # Expire memoized instance variables that can incorrectly generate, replace
2049
- # or miss files due changes in certain attributes used to compute them.
2050
-
2051
- def invalidate_memoized_attributes
2052
- @full_name = nil
2053
- @cache_file = nil
2054
- end
2055
-
2056
- private :invalidate_memoized_attributes
2057
-
2058
1989
  def inspect # :nodoc:
2059
1990
  if $DEBUG
2060
1991
  super
@@ -2093,8 +2024,6 @@ class Gem::Specification < Gem::BasicSpecification
2093
2024
  def internal_init # :nodoc:
2094
2025
  super
2095
2026
  @bin_dir = nil
2096
- @cache_dir = nil
2097
- @cache_file = nil
2098
2027
  @doc_dir = nil
2099
2028
  @ri_dir = nil
2100
2029
  @spec_dir = nil
@@ -2447,8 +2376,6 @@ class Gem::Specification < Gem::BasicSpecification
2447
2376
  :required_rubygems_version,
2448
2377
  :specification_version,
2449
2378
  :version,
2450
- :has_rdoc,
2451
- :default_executable,
2452
2379
  :metadata,
2453
2380
  :signing_key,
2454
2381
  ]
@@ -2586,29 +2513,11 @@ class Gem::Specification < Gem::BasicSpecification
2586
2513
  Gem::SpecificationPolicy.new(self).validate_for_resolution
2587
2514
  end
2588
2515
 
2589
- def validate_metadata
2590
- Gem::SpecificationPolicy.new(self).validate_metadata
2591
- end
2592
- rubygems_deprecate :validate_metadata
2593
-
2594
- def validate_dependencies
2595
- Gem::SpecificationPolicy.new(self).validate_dependencies
2596
- end
2597
- rubygems_deprecate :validate_dependencies
2598
-
2599
- def validate_permissions
2600
- Gem::SpecificationPolicy.new(self).validate_permissions
2601
- end
2602
- rubygems_deprecate :validate_permissions
2603
-
2604
2516
  ##
2605
2517
  # Set the version to +version+.
2606
2518
 
2607
2519
  def version=(version)
2608
- @version = Gem::Version.create(version)
2609
- return if @version.nil?
2610
-
2611
- invalidate_memoized_attributes
2520
+ @version = version.nil? ? version : Gem::Version.create(version)
2612
2521
  end
2613
2522
 
2614
2523
  def stubbed?