rubygems-update 3.4.20 → 3.4.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -0
  3. data/Manifest.txt +1 -0
  4. data/bundler/CHANGELOG.md +34 -3
  5. data/bundler/lib/bundler/build_metadata.rb +3 -3
  6. data/bundler/lib/bundler/cli/check.rb +1 -1
  7. data/bundler/lib/bundler/cli/gem.rb +1 -3
  8. data/bundler/lib/bundler/cli/install.rb +2 -2
  9. data/bundler/lib/bundler/cli/lock.rb +26 -23
  10. data/bundler/lib/bundler/cli/open.rb +5 -7
  11. data/bundler/lib/bundler/definition.rb +42 -25
  12. data/bundler/lib/bundler/env.rb +2 -2
  13. data/bundler/lib/bundler/gem_version_promoter.rb +2 -2
  14. data/bundler/lib/bundler/injector.rb +1 -1
  15. data/bundler/lib/bundler/installer/parallel_installer.rb +0 -26
  16. data/bundler/lib/bundler/installer/standalone.rb +13 -6
  17. data/bundler/lib/bundler/lockfile_parser.rb +29 -24
  18. data/bundler/lib/bundler/man/bundle-add.1 +1 -1
  19. data/bundler/lib/bundler/man/bundle-binstubs.1 +1 -1
  20. data/bundler/lib/bundler/man/bundle-cache.1 +1 -1
  21. data/bundler/lib/bundler/man/bundle-check.1 +1 -1
  22. data/bundler/lib/bundler/man/bundle-clean.1 +1 -1
  23. data/bundler/lib/bundler/man/bundle-config.1 +1 -1
  24. data/bundler/lib/bundler/man/bundle-console.1 +1 -1
  25. data/bundler/lib/bundler/man/bundle-doctor.1 +1 -1
  26. data/bundler/lib/bundler/man/bundle-exec.1 +2 -2
  27. data/bundler/lib/bundler/man/bundle-exec.1.ronn +2 -3
  28. data/bundler/lib/bundler/man/bundle-gem.1 +1 -1
  29. data/bundler/lib/bundler/man/bundle-help.1 +1 -1
  30. data/bundler/lib/bundler/man/bundle-info.1 +1 -1
  31. data/bundler/lib/bundler/man/bundle-init.1 +1 -1
  32. data/bundler/lib/bundler/man/bundle-inject.1 +1 -1
  33. data/bundler/lib/bundler/man/bundle-install.1 +1 -1
  34. data/bundler/lib/bundler/man/bundle-list.1 +1 -1
  35. data/bundler/lib/bundler/man/bundle-lock.1 +1 -1
  36. data/bundler/lib/bundler/man/bundle-open.1 +1 -1
  37. data/bundler/lib/bundler/man/bundle-outdated.1 +1 -1
  38. data/bundler/lib/bundler/man/bundle-platform.1 +1 -1
  39. data/bundler/lib/bundler/man/bundle-plugin.1 +17 -17
  40. data/bundler/lib/bundler/man/bundle-plugin.1.ronn +5 -5
  41. data/bundler/lib/bundler/man/bundle-pristine.1 +1 -1
  42. data/bundler/lib/bundler/man/bundle-remove.1 +1 -1
  43. data/bundler/lib/bundler/man/bundle-show.1 +1 -1
  44. data/bundler/lib/bundler/man/bundle-update.1 +1 -1
  45. data/bundler/lib/bundler/man/bundle-version.1 +1 -1
  46. data/bundler/lib/bundler/man/bundle-viz.1 +1 -1
  47. data/bundler/lib/bundler/man/bundle.1 +1 -1
  48. data/bundler/lib/bundler/man/gemfile.5 +1 -1
  49. data/bundler/lib/bundler/resolver/package.rb +5 -0
  50. data/bundler/lib/bundler/resolver.rb +27 -7
  51. data/bundler/lib/bundler/ruby_version.rb +8 -1
  52. data/bundler/lib/bundler/settings.rb +53 -16
  53. data/bundler/lib/bundler/shared_helpers.rb +16 -1
  54. data/bundler/lib/bundler/source/git/git_proxy.rb +13 -4
  55. data/bundler/lib/bundler/spec_set.rb +2 -2
  56. data/bundler/lib/bundler/stub_specification.rb +4 -2
  57. data/bundler/lib/bundler/templates/newgem/Rakefile.tt +6 -2
  58. data/bundler/lib/bundler/version.rb +1 -1
  59. data/bundler/lib/bundler/yaml_serializer.rb +6 -7
  60. data/lib/rubygems/basic_specification.rb +1 -1
  61. data/lib/rubygems/command.rb +2 -2
  62. data/lib/rubygems/command_manager.rb +1 -1
  63. data/lib/rubygems/commands/cert_command.rb +2 -2
  64. data/lib/rubygems/commands/check_command.rb +5 -1
  65. data/lib/rubygems/commands/cleanup_command.rb +1 -1
  66. data/lib/rubygems/commands/contents_command.rb +1 -1
  67. data/lib/rubygems/commands/help_command.rb +2 -2
  68. data/lib/rubygems/commands/open_command.rb +1 -3
  69. data/lib/rubygems/commands/owner_command.rb +1 -1
  70. data/lib/rubygems/commands/setup_command.rb +8 -8
  71. data/lib/rubygems/commands/specification_command.rb +5 -1
  72. data/lib/rubygems/commands/stale_command.rb +1 -1
  73. data/lib/rubygems/commands/update_command.rb +3 -3
  74. data/lib/rubygems/commands/yank_command.rb +1 -1
  75. data/lib/rubygems/config_file.rb +60 -13
  76. data/lib/rubygems/core_ext/kernel_gem.rb +1 -1
  77. data/lib/rubygems/core_ext/kernel_require.rb +1 -1
  78. data/lib/rubygems/defaults.rb +6 -2
  79. data/lib/rubygems/deprecate.rb +2 -1
  80. data/lib/rubygems/doctor.rb +1 -1
  81. data/lib/rubygems/errors.rb +1 -1
  82. data/lib/rubygems/exceptions.rb +1 -1
  83. data/lib/rubygems/ext/builder.rb +5 -4
  84. data/lib/rubygems/ext/cargo_builder.rb +2 -2
  85. data/lib/rubygems/gem_runner.rb +5 -1
  86. data/lib/rubygems/gemcutter_utilities.rb +2 -2
  87. data/lib/rubygems/indexer.rb +1 -1
  88. data/lib/rubygems/install_update_options.rb +1 -1
  89. data/lib/rubygems/installer.rb +8 -8
  90. data/lib/rubygems/package/old.rb +1 -1
  91. data/lib/rubygems/package/tar_writer.rb +1 -1
  92. data/lib/rubygems/package.rb +8 -8
  93. data/lib/rubygems/platform.rb +6 -2
  94. data/lib/rubygems/query_utils.rb +4 -4
  95. data/lib/rubygems/remote_fetcher.rb +10 -2
  96. data/lib/rubygems/request_set.rb +2 -1
  97. data/lib/rubygems/requirement.rb +1 -1
  98. data/lib/rubygems/resolver/api_set.rb +2 -1
  99. data/lib/rubygems/resolver/api_specification.rb +1 -1
  100. data/lib/rubygems/security/signer.rb +10 -2
  101. data/lib/rubygems/security/trust_dir.rb +4 -4
  102. data/lib/rubygems/security.rb +1 -1
  103. data/lib/rubygems/security_option.rb +1 -1
  104. data/lib/rubygems/source.rb +5 -1
  105. data/lib/rubygems/specification.rb +9 -10
  106. data/lib/rubygems/specification_policy.rb +5 -5
  107. data/lib/rubygems/uninstaller.rb +1 -1
  108. data/lib/rubygems/update_suggestion.rb +1 -1
  109. data/lib/rubygems/util.rb +5 -1
  110. data/lib/rubygems/version.rb +3 -2
  111. data/lib/rubygems/yaml_serializer.rb +88 -0
  112. data/lib/rubygems.rb +4 -4
  113. data/rubygems-update.gemspec +1 -1
  114. data/setup.rb +2 -0
  115. data/test/rubygems/bundler_test_gem.rb +6 -3
  116. data/test/rubygems/helper.rb +23 -15
  117. data/test/rubygems/package/tar_test_case.rb +2 -2
  118. data/test/rubygems/test_gem.rb +51 -26
  119. data/test/rubygems/test_gem_command.rb +3 -1
  120. data/test/rubygems/test_gem_commands_cert_command.rb +22 -22
  121. data/test/rubygems/test_gem_commands_cleanup_command.rb +2 -2
  122. data/test/rubygems/test_gem_commands_environment_command.rb +2 -1
  123. data/test/rubygems/test_gem_commands_exec_command.rb +5 -1
  124. data/test/rubygems/test_gem_commands_install_command.rb +3 -3
  125. data/test/rubygems/test_gem_commands_open_command.rb +5 -2
  126. data/test/rubygems/test_gem_commands_pristine_command.rb +2 -2
  127. data/test/rubygems/test_gem_commands_push_command.rb +7 -6
  128. data/test/rubygems/test_gem_commands_signin_command.rb +8 -8
  129. data/test/rubygems/test_gem_commands_uninstall_command.rb +1 -1
  130. data/test/rubygems/test_gem_commands_unpack_command.rb +2 -2
  131. data/test/rubygems/test_gem_config_file.rb +46 -12
  132. data/test/rubygems/test_gem_ext_cargo_builder.rb +2 -2
  133. data/test/rubygems/test_gem_gemcutter_utilities.rb +8 -5
  134. data/test/rubygems/test_gem_install_update_options.rb +3 -3
  135. data/test/rubygems/test_gem_installer.rb +15 -15
  136. data/test/rubygems/test_gem_package.rb +35 -34
  137. data/test/rubygems/test_gem_package_old.rb +1 -1
  138. data/test/rubygems/test_gem_package_tar_header.rb +3 -3
  139. data/test/rubygems/test_gem_package_tar_reader.rb +4 -4
  140. data/test/rubygems/test_gem_package_tar_writer.rb +28 -28
  141. data/test/rubygems/test_gem_rdoc.rb +2 -2
  142. data/test/rubygems/test_gem_remote_fetcher.rb +13 -9
  143. data/test/rubygems/test_gem_request.rb +5 -5
  144. data/test/rubygems/test_gem_request_connection_pools.rb +2 -1
  145. data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +14 -7
  146. data/test/rubygems/test_gem_security.rb +2 -2
  147. data/test/rubygems/test_gem_security_signer.rb +2 -2
  148. data/test/rubygems/test_gem_security_trust_dir.rb +6 -6
  149. data/test/rubygems/test_gem_spec_fetcher.rb +2 -2
  150. data/test/rubygems/test_gem_specification.rb +29 -29
  151. data/test/rubygems/test_gem_update_suggestion.rb +12 -6
  152. data/test/rubygems/test_gem_util.rb +2 -2
  153. data/test/rubygems/test_gem_version.rb +4 -2
  154. data/test/rubygems/utilities.rb +2 -1
  155. metadata +4 -3
@@ -137,7 +137,11 @@ class Gem::Source
137
137
 
138
138
  if File.exist? local_spec
139
139
  spec = Gem.read_binary local_spec
140
- spec = Marshal.load(spec) rescue nil
140
+ spec = begin
141
+ Marshal.load(spec)
142
+ rescue StandardError
143
+ nil
144
+ end
141
145
  return spec if spec
142
146
  end
143
147
 
@@ -427,11 +427,11 @@ class Gem::Specification < Gem::BasicSpecification
427
427
  end
428
428
 
429
429
  ##
430
- # The path in the gem for executable scripts. Usually 'bin'
430
+ # The path in the gem for executable scripts. Usually 'exe'
431
431
  #
432
432
  # Usage:
433
433
  #
434
- # spec.bindir = 'bin'
434
+ # spec.bindir = 'exe'
435
435
 
436
436
  attr_accessor :bindir
437
437
 
@@ -1538,7 +1538,7 @@ class Gem::Specification < Gem::BasicSpecification
1538
1538
  else
1539
1539
  executables
1540
1540
  end
1541
- rescue
1541
+ rescue StandardError
1542
1542
  return nil
1543
1543
  end
1544
1544
 
@@ -2362,13 +2362,13 @@ class Gem::Specification < Gem::BasicSpecification
2362
2362
  when Array then "[" + obj.map {|x| ruby_code x }.join(", ") + "]"
2363
2363
  when Hash then
2364
2364
  seg = obj.keys.sort.map {|k| "#{k.to_s.dump} => #{obj[k].to_s.dump}" }
2365
- "{ #{seg.join(', ')} }"
2366
- when Gem::Version then obj.to_s.dump
2365
+ "{ #{seg.join(", ")} }"
2366
+ when Gem::Version then ruby_code(obj.to_s)
2367
2367
  when DateLike then obj.strftime("%Y-%m-%d").dump
2368
2368
  when Time then obj.strftime("%Y-%m-%d").dump
2369
2369
  when Numeric then obj.inspect
2370
2370
  when true, false, nil then obj.inspect
2371
- when Gem::Platform then "Gem::Platform.new(#{obj.to_a.inspect})"
2371
+ when Gem::Platform then "Gem::Platform.new(#{ruby_code obj.to_a})"
2372
2372
  when Gem::Requirement then
2373
2373
  list = obj.as_list
2374
2374
  "Gem::Requirement.new(#{ruby_code(list.size == 1 ? obj.to_s : list)})"
@@ -2533,12 +2533,12 @@ class Gem::Specification < Gem::BasicSpecification
2533
2533
  end
2534
2534
 
2535
2535
  if String === signing_key
2536
- result << " s.signing_key = #{signing_key.dump}.freeze"
2536
+ result << " s.signing_key = #{ruby_code signing_key}"
2537
2537
  end
2538
2538
 
2539
2539
  if @installed_by_version
2540
2540
  result << nil
2541
- result << " s.installed_by_version = \"#{Gem::VERSION}\" if s.respond_to? :installed_by_version"
2541
+ result << " s.installed_by_version = #{ruby_code Gem::VERSION} if s.respond_to? :installed_by_version"
2542
2542
  end
2543
2543
 
2544
2544
  unless dependencies.empty?
@@ -2547,9 +2547,8 @@ class Gem::Specification < Gem::BasicSpecification
2547
2547
  result << nil
2548
2548
 
2549
2549
  dependencies.each do |dep|
2550
- req = dep.requirements_list.inspect
2551
2550
  dep.instance_variable_set :@type, :runtime if dep.type.nil? # HACK
2552
- result << " s.add_#{dep.type}_dependency(%q<#{dep.name}>.freeze, #{req})"
2551
+ result << " s.add_#{dep.type}_dependency(%q<#{dep.name}>.freeze, #{ruby_code dep.requirements_list})"
2553
2552
  end
2554
2553
  end
2555
2554
 
@@ -214,7 +214,7 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
214
214
  end
215
215
 
216
216
  " if #{dep.name} is semantically versioned, use:\n" \
217
- " add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join '.'}'#{bugfix}"
217
+ " add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join "."}'#{bugfix}"
218
218
  end
219
219
 
220
220
  warning_messages << ["open-ended dependency on #{dep} is not recommended", recommendation].join("\n") + "\n"
@@ -234,7 +234,7 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
234
234
 
235
235
  @specification.files.each do |file|
236
236
  next unless File.file?(file)
237
- next if File.stat(file).mode & 0444 == 0444
237
+ next if File.stat(file).mode & 0o444 == 0o444
238
238
  warning "#{file} is not world-readable"
239
239
  end
240
240
 
@@ -253,7 +253,7 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
253
253
  @specification.instance_variable_get("@#{attrname}").nil?
254
254
  end
255
255
  return if nil_attributes.empty?
256
- error "#{nil_attributes.join ', '} must not be nil"
256
+ error "#{nil_attributes.join ", "} must not be nil"
257
257
  end
258
258
 
259
259
  def validate_rubygems_version
@@ -300,7 +300,7 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
300
300
  non_files = @specification.files.reject {|x| File.file?(x) || File.symlink?(x) }
301
301
 
302
302
  unless non_files.empty?
303
- error "[\"#{non_files.join "\", \""}\"] are not files"
303
+ error "[\"#{non_files.join '", "'}\"] are not files"
304
304
  end
305
305
  end
306
306
 
@@ -377,7 +377,7 @@ license value '#{license}' is invalid. Use a license identifier from
377
377
  http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard license,
378
378
  or set it to nil if you don't want to specify a license.
379
379
  WARNING
380
- message += "Did you mean #{suggestions.map {|s| "'#{s}'" }.join(', ')}?\n" unless suggestions.nil?
380
+ message += "Did you mean #{suggestions.map {|s| "'#{s}'" }.join(", ")}?\n" unless suggestions.nil?
381
381
  warning(message)
382
382
  end
383
383
 
@@ -202,7 +202,7 @@ class Gem::Uninstaller
202
202
 
203
203
  remove = if @force_executables.nil?
204
204
  ask_yes_no("Remove executables:\n" +
205
- "\t#{executables.join ', '}\n\n" +
205
+ "\t#{executables.join ", "}\n\n" +
206
206
  "in addition to the gem?",
207
207
  true)
208
208
  else
@@ -59,7 +59,7 @@ Run `gem update --system #{Gem.latest_rubygems_version}` to update your installa
59
59
 
60
60
  return eglible
61
61
  end
62
- rescue # don't block install command on any problem
62
+ rescue StandardError # don't block install command on any problem
63
63
  false
64
64
  end
65
65
 
data/lib/rubygems/util.rb CHANGED
@@ -85,7 +85,11 @@ module Gem::Util
85
85
 
86
86
  here = File.expand_path directory
87
87
  loop do
88
- Dir.chdir here, &block rescue Errno::EACCES
88
+ begin
89
+ Dir.chdir here, &block
90
+ rescue StandardError
91
+ Errno::EACCES
92
+ end
89
93
 
90
94
  new_here = File.expand_path("..", here)
91
95
  return if new_here == here # toplevel
@@ -131,7 +131,7 @@ require_relative "deprecate"
131
131
  #
132
132
  # == Preventing Version Catastrophe:
133
133
  #
134
- # From: http://blog.zenspider.com/2008/10/rubygems-howto-preventing-cata.html
134
+ # From: https://www.zenspider.com/ruby/2008/10/rubygems-how-to-preventing-catastrophe.html
135
135
  #
136
136
  # Let's say you're depending on the fnord gem version 2.y.z. If you
137
137
  # specify your dependency as ">= 2.0.0" then, you're good, right? What
@@ -366,7 +366,8 @@ class Gem::Version
366
366
  i = 0
367
367
 
368
368
  while i <= limit
369
- lhs, rhs = lhsegments[i] || 0, rhsegments[i] || 0
369
+ lhs = lhsegments[i] || 0
370
+ rhs = rhsegments[i] || 0
370
371
  i += 1
371
372
 
372
373
  next if lhs == rhs
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gem
4
+ # A stub yaml serializer that can handle only hashes and strings (as of now).
5
+ module YAMLSerializer
6
+ module_function
7
+
8
+ def dump(hash)
9
+ yaml = String.new("---")
10
+ yaml << dump_hash(hash)
11
+ end
12
+
13
+ def dump_hash(hash)
14
+ yaml = String.new("\n")
15
+ hash.each do |k, v|
16
+ yaml << k << ":"
17
+ if v.is_a?(Hash)
18
+ yaml << dump_hash(v).gsub(/^(?!$)/, " ") # indent all non-empty lines
19
+ elsif v.is_a?(Array) # Expected to be array of strings
20
+ yaml << "\n- " << v.map {|s| s.to_s.gsub(/\s+/, " ").inspect }.join("\n- ") << "\n"
21
+ else
22
+ yaml << " " << v.to_s.gsub(/\s+/, " ").inspect << "\n"
23
+ end
24
+ end
25
+ yaml
26
+ end
27
+
28
+ ARRAY_REGEX = /
29
+ ^
30
+ (?:[ ]*-[ ]) # '- ' before array items
31
+ (['"]?) # optional opening quote
32
+ (.*) # value
33
+ \1 # matching closing quote
34
+ $
35
+ /xo.freeze
36
+
37
+ HASH_REGEX = /
38
+ ^
39
+ ([ ]*) # indentations
40
+ (.+) # key
41
+ (?::(?=(?:\s|$))) # : (without the lookahead the #key includes this when : is present in value)
42
+ [ ]?
43
+ (['"]?) # optional opening quote
44
+ (.*) # value
45
+ \3 # matching closing quote
46
+ $
47
+ /xo.freeze
48
+
49
+ def load(str)
50
+ res = {}
51
+ stack = [res]
52
+ last_hash = nil
53
+ last_empty_key = nil
54
+ str.split(/\r?\n/).each do |line|
55
+ if match = HASH_REGEX.match(line)
56
+ indent, key, quote, val = match.captures
57
+ convert_to_backward_compatible_key!(key)
58
+ depth = indent.size / 2
59
+ if quote.empty? && val.empty?
60
+ new_hash = {}
61
+ stack[depth][key] = new_hash
62
+ stack[depth + 1] = new_hash
63
+ last_empty_key = key
64
+ last_hash = stack[depth]
65
+ else
66
+ stack[depth][key] = val
67
+ end
68
+ elsif match = ARRAY_REGEX.match(line)
69
+ _, val = match.captures
70
+ last_hash[last_empty_key] = [] unless last_hash[last_empty_key].is_a?(Array)
71
+
72
+ last_hash[last_empty_key].push(val)
73
+ end
74
+ end
75
+ res
76
+ end
77
+
78
+ # for settings' keys
79
+ def convert_to_backward_compatible_key!(key)
80
+ key << "/" if /https?:/i.match?(key) && !%r{/\Z}.match?(key)
81
+ key.gsub!(".", "__")
82
+ end
83
+
84
+ class << self
85
+ private :dump_hash, :convert_to_backward_compatible_key!
86
+ end
87
+ end
88
+ end
data/lib/rubygems.rb CHANGED
@@ -9,7 +9,7 @@
9
9
  require "rbconfig"
10
10
 
11
11
  module Gem
12
- VERSION = "3.4.20"
12
+ VERSION = "3.4.21"
13
13
  end
14
14
 
15
15
  # Must be first since it unloads the prelude from 1.9.2
@@ -439,7 +439,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
439
439
 
440
440
  def self.ensure_subdirectories(dir, mode, subdirs) # :nodoc:
441
441
  old_umask = File.umask
442
- File.umask old_umask | 002
442
+ File.umask old_umask | 0o02
443
443
 
444
444
  options = {}
445
445
 
@@ -582,7 +582,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
582
582
 
583
583
  ##
584
584
  # The number of paths in the +$LOAD_PATH+ from activated gems. Used to
585
- # prioritize +-I+ and +ENV['RUBYLIB']+ entries during +require+.
585
+ # prioritize +-I+ and <code>ENV['RUBYLIB']</code> entries during +require+.
586
586
 
587
587
  def self.activated_gem_paths
588
588
  @activated_gem_paths ||= 0
@@ -914,7 +914,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
914
914
  # Glob pattern for require-able path suffixes.
915
915
 
916
916
  def self.suffix_pattern
917
- @suffix_pattern ||= "{#{suffixes.join(',')}}"
917
+ @suffix_pattern ||= "{#{suffixes.join(",")}}"
918
918
  end
919
919
 
920
920
  ##
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "rubygems-update"
5
- s.version = "3.4.20"
5
+ s.version = "3.4.21"
6
6
  s.authors = ["Jim Weirich", "Chad Fowler", "Eric Hodel", "Luis Lavena", "Aaron Patterson", "Samuel Giddins", "André Arko", "Evan Phoenix", "Hiroshi SHIBATA"]
7
7
  s.email = ["", "", "drbrain@segment7.net", "luislavena@gmail.com", "aaron@tenderlovemaking.com", "segiddins@segiddins.me", "andre@arko.net", "evan@phx.io", "hsbt@ruby-lang.org"]
8
8
 
data/setup.rb CHANGED
@@ -7,6 +7,8 @@
7
7
  # See LICENSE.txt for permissions.
8
8
  #++
9
9
 
10
+ abort "RubyGems only supports Ruby 2.6 or higher" if RUBY_VERSION < "2.6.0"
11
+
10
12
  # Make sure rubygems isn't already loaded.
11
13
  if ENV["RUBYOPT"] || defined? Gem
12
14
  ENV.delete "RUBYOPT"
@@ -384,8 +384,10 @@ You may need to `bundle install` to install missing gems
384
384
  end
385
385
 
386
386
  def with_path_and_rubyopt(path_value, rubyopt_value)
387
- path, ENV["PATH"] = ENV["PATH"], path_value
388
- rubyopt, ENV["RUBYOPT"] = ENV["RUBYOPT"], rubyopt_value
387
+ path = ENV["PATH"]
388
+ ENV["PATH"] = path_value
389
+ rubyopt = ENV["RUBYOPT"]
390
+ ENV["RUBYOPT"] = rubyopt_value
389
391
 
390
392
  yield
391
393
  ensure
@@ -394,7 +396,8 @@ You may need to `bundle install` to install missing gems
394
396
  end
395
397
 
396
398
  def with_rubygems_gemdeps(value)
397
- rubygems_gemdeps, ENV["RUBYGEMS_GEMDEPS"] = ENV["RUBYGEMS_GEMDEPS"], value
399
+ rubygems_gemdeps = ENV["RUBYGEMS_GEMDEPS"]
400
+ ENV["RUBYGEMS_GEMDEPS"] = value
398
401
 
399
402
  yield
400
403
  ensure
@@ -120,9 +120,11 @@ class Gem::TestCase < Test::Unit::TestCase
120
120
  _synchronize do
121
121
  require "tempfile"
122
122
 
123
- captured_stdout, captured_stderr = Tempfile.new("out"), Tempfile.new("err")
123
+ captured_stdout = Tempfile.new("out")
124
+ captured_stderr = Tempfile.new("err")
124
125
 
125
- orig_stdout, orig_stderr = $stdout.dup, $stderr.dup
126
+ orig_stdout = $stdout.dup
127
+ orig_stderr = $stderr.dup
126
128
  $stdout.reopen captured_stdout
127
129
  $stderr.reopen captured_stderr
128
130
 
@@ -335,14 +337,18 @@ class Gem::TestCase < Test::Unit::TestCase
335
337
  ruby
336
338
  end
337
339
 
338
- @git = ENV["GIT"] || "git#{RbConfig::CONFIG['EXEEXT']}"
340
+ @git = ENV["GIT"] || "git#{RbConfig::CONFIG["EXEEXT"]}"
339
341
 
340
342
  Gem.ensure_gem_subdirectories @gemhome
341
343
  Gem.ensure_default_gem_subdirectories @gemhome
342
344
 
343
345
  @orig_LOAD_PATH = $LOAD_PATH.dup
344
346
  $LOAD_PATH.map! do |s|
345
- expand_path = File.realpath(s) rescue File.expand_path(s)
347
+ expand_path = begin
348
+ File.realpath(s)
349
+ rescue StandardError
350
+ File.expand_path(s)
351
+ end
346
352
  if expand_path != s
347
353
  expand_path.tap(&Gem::UNTAINT)
348
354
  if s.instance_variable_defined?(:@gem_prelude_index)
@@ -484,7 +490,7 @@ class Gem::TestCase < Test::Unit::TestCase
484
490
  @temp_cred = File.join(@userhome, ".gem", "credentials")
485
491
  FileUtils.mkdir_p File.dirname(@temp_cred)
486
492
  File.write @temp_cred, ":rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97"
487
- File.chmod 0600, @temp_cred
493
+ File.chmod 0o600, @temp_cred
488
494
  end
489
495
 
490
496
  def credential_teardown
@@ -686,11 +692,8 @@ class Gem::TestCase < Test::Unit::TestCase
686
692
  # Load a YAML file, the psych 3 way
687
693
 
688
694
  def load_yaml_file(file)
689
- if Psych.respond_to?(:unsafe_load_file)
690
- Psych.unsafe_load_file(file)
691
- else
692
- Psych.load_file(file)
693
- end
695
+ require "rubygems/config_file"
696
+ Gem::ConfigFile.load_with_rubygems_config_hash(File.read(file))
694
697
  end
695
698
 
696
699
  def all_spec_names
@@ -1274,7 +1277,7 @@ Also, a list:
1274
1277
  ruby = ENV["RUBY"]
1275
1278
  return ruby if ruby
1276
1279
  ruby = "ruby"
1277
- rubyexe = "#{ruby}#{RbConfig::CONFIG['EXEEXT']}"
1280
+ rubyexe = "#{ruby}#{RbConfig::CONFIG["EXEEXT"]}"
1278
1281
 
1279
1282
  3.times do
1280
1283
  if File.exist?(ruby) && File.executable?(ruby) && !File.directory?(ruby)
@@ -1325,7 +1328,8 @@ Also, a list:
1325
1328
  end
1326
1329
 
1327
1330
  def silence_warnings
1328
- old_verbose, $VERBOSE = $VERBOSE, false
1331
+ old_verbose = $VERBOSE
1332
+ $VERBOSE = false
1329
1333
  yield
1330
1334
  ensure
1331
1335
  $VERBOSE = old_verbose
@@ -1349,8 +1353,8 @@ Also, a list:
1349
1353
  end
1350
1354
  end
1351
1355
 
1352
- @@good_rake = "#{rubybin} #{escape_path(__dir__, 'good_rake.rb')}"
1353
- @@bad_rake = "#{rubybin} #{escape_path(__dir__, 'bad_rake.rb')}"
1356
+ @@good_rake = "#{rubybin} #{escape_path(__dir__, "good_rake.rb")}"
1357
+ @@bad_rake = "#{rubybin} #{escape_path(__dir__, "bad_rake.rb")}"
1354
1358
 
1355
1359
  ##
1356
1360
  # Construct a new Gem::Dependency.
@@ -1536,7 +1540,11 @@ Also, a list:
1536
1540
  # <tt>test/rubygems/</tt>.
1537
1541
 
1538
1542
  def self.cert_path(cert_name)
1539
- if 32 == (Time.at(2**32) rescue 32)
1543
+ if 32 == begin
1544
+ Time.at(2**32)
1545
+ rescue StandardError
1546
+ 32
1547
+ end
1540
1548
  cert_file = "#{__dir__}/#{cert_name}_cert_32.pem"
1541
1549
 
1542
1550
  return cert_file if File.exist? cert_file
@@ -163,11 +163,11 @@ class Gem::Package::TarTestCase < Gem::TestCase
163
163
  data_tgz = util_tar_gz(&block)
164
164
  util_tar do |tar|
165
165
  if spec
166
- tar.add_file "metadata.gz", 0444 do |io|
166
+ tar.add_file "metadata.gz", 0o444 do |io|
167
167
  io.write util_gzip(spec.to_yaml)
168
168
  end
169
169
  end
170
- tar.add_file "data.tar.gz", 0644 do |io|
170
+ tar.add_file "data.tar.gz", 0o644 do |io|
171
171
  io.write data_tgz.string
172
172
  end
173
173
  end
@@ -132,7 +132,7 @@ class TestGem < Gem::TestCase
132
132
  end
133
133
 
134
134
  def test_self_install_permissions_umask_077
135
- umask = File.umask(077)
135
+ umask = File.umask(0o77)
136
136
  assert_self_install_permissions
137
137
  ensure
138
138
  File.umask(umask)
@@ -152,11 +152,11 @@ class TestGem < Gem::TestCase
152
152
  end
153
153
 
154
154
  def assert_self_install_permissions(format_executable: false)
155
- mask = win_platform? ? 0700 : 0777
155
+ mask = win_platform? ? 0o700 : 0o777
156
156
  options = {
157
- :dir_mode => 0500,
158
- :prog_mode => win_platform? ? 0410 : 0510,
159
- :data_mode => 0640,
157
+ :dir_mode => 0o500,
158
+ :prog_mode => win_platform? ? 0o410 : 0o510,
159
+ :data_mode => 0o640,
160
160
  :wrappers => true,
161
161
  :format_executable => format_executable,
162
162
  }
@@ -165,7 +165,7 @@ class TestGem < Gem::TestCase
165
165
  Dir.mkdir "data"
166
166
 
167
167
  File.write "bin/foo", "#!/usr/bin/env ruby\n"
168
- File.chmod 0755, "bin/foo"
168
+ File.chmod 0o755, "bin/foo"
169
169
 
170
170
  File.write "data/foo.txt", "blah\n"
171
171
 
@@ -201,7 +201,7 @@ class TestGem < Gem::TestCase
201
201
  end
202
202
  assert_equal(expected, result)
203
203
  ensure
204
- File.chmod(0755, *Dir.glob(@gemhome + "/gems/**/").map {|path| path.tap(&Gem::UNTAINT) })
204
+ File.chmod(0o755, *Dir.glob(@gemhome + "/gems/**/").map {|path| path.tap(&Gem::UNTAINT) })
205
205
  end
206
206
 
207
207
  def test_require_missing
@@ -639,12 +639,12 @@ class TestGem < Gem::TestCase
639
639
  FileUtils.rm_r @gemhome
640
640
  Gem.use_paths @gemhome
641
641
 
642
- Gem.ensure_gem_subdirectories @gemhome, 0750
642
+ Gem.ensure_gem_subdirectories @gemhome, 0o750
643
643
 
644
644
  assert_directory_exists File.join(@gemhome, "cache")
645
645
 
646
- assert_equal 0750, File::Stat.new(@gemhome).mode & 0777
647
- assert_equal 0750, File::Stat.new(File.join(@gemhome, "cache")).mode & 0777
646
+ assert_equal 0o750, File::Stat.new(@gemhome).mode & 0o777
647
+ assert_equal 0o750, File::Stat.new(File.join(@gemhome, "cache")).mode & 0o777
648
648
  end unless win_platform?
649
649
 
650
650
  def test_self_ensure_gem_directories_safe_permissions
@@ -655,17 +655,21 @@ class TestGem < Gem::TestCase
655
655
  File.umask 0
656
656
  Gem.ensure_gem_subdirectories @gemhome
657
657
 
658
- assert_equal 0, File::Stat.new(@gemhome).mode & 002
659
- assert_equal 0, File::Stat.new(File.join(@gemhome, "cache")).mode & 002
658
+ assert_equal 0, File::Stat.new(@gemhome).mode & 0o02
659
+ assert_equal 0, File::Stat.new(File.join(@gemhome, "cache")).mode & 0o02
660
660
  ensure
661
661
  File.umask old_umask
662
662
  end unless win_platform?
663
663
 
664
664
  def test_self_ensure_gem_directories_missing_parents
665
665
  gemdir = File.join @tempdir, "a/b/c/gemdir"
666
- FileUtils.rm_rf File.join(@tempdir, "a") rescue nil
666
+ begin
667
+ FileUtils.rm_rf File.join(@tempdir, "a")
668
+ rescue StandardError
669
+ nil
670
+ end
667
671
  refute File.exist?(File.join(@tempdir, "a")),
668
- "manually remove #{File.join @tempdir, 'a'}, tests are broken"
672
+ "manually remove #{File.join @tempdir, "a"}, tests are broken"
669
673
  Gem.use_paths gemdir
670
674
 
671
675
  Gem.ensure_gem_subdirectories gemdir
@@ -676,34 +680,42 @@ class TestGem < Gem::TestCase
676
680
  unless win_platform? || Process.uid.zero? # only for FS that support write protection
677
681
  def test_self_ensure_gem_directories_write_protected
678
682
  gemdir = File.join @tempdir, "egd"
679
- FileUtils.rm_r gemdir rescue nil
683
+ begin
684
+ FileUtils.rm_r gemdir
685
+ rescue StandardError
686
+ nil
687
+ end
680
688
  refute File.exist?(gemdir), "manually remove #{gemdir}, tests are broken"
681
689
  FileUtils.mkdir_p gemdir
682
- FileUtils.chmod 0400, gemdir
690
+ FileUtils.chmod 0o400, gemdir
683
691
  Gem.use_paths gemdir
684
692
 
685
693
  Gem.ensure_gem_subdirectories gemdir
686
694
 
687
695
  refute File.exist?(util_cache_dir)
688
696
  ensure
689
- FileUtils.chmod 0600, gemdir
697
+ FileUtils.chmod 0o600, gemdir
690
698
  end
691
699
 
692
700
  def test_self_ensure_gem_directories_write_protected_parents
693
701
  parent = File.join(@tempdir, "egd")
694
702
  gemdir = "#{parent}/a/b/c"
695
703
 
696
- FileUtils.rm_r parent rescue nil
704
+ begin
705
+ FileUtils.rm_r parent
706
+ rescue StandardError
707
+ nil
708
+ end
697
709
  refute File.exist?(parent), "manually remove #{parent}, tests are broken"
698
710
  FileUtils.mkdir_p parent
699
- FileUtils.chmod 0400, parent
711
+ FileUtils.chmod 0o400, parent
700
712
  Gem.use_paths(gemdir)
701
713
 
702
714
  Gem.ensure_gem_subdirectories gemdir
703
715
 
704
716
  refute File.exist? File.join(gemdir, "gems")
705
717
  ensure
706
- FileUtils.chmod 0600, parent
718
+ FileUtils.chmod 0o600, parent
707
719
  end
708
720
 
709
721
  def test_self_ensure_gem_directories_non_existent_paths
@@ -965,11 +977,11 @@ class TestGem < Gem::TestCase
965
977
  pend "chmod not supported" if Gem.win_platform?
966
978
 
967
979
  begin
968
- File.chmod 0444, "test"
980
+ File.chmod 0o444, "test"
969
981
 
970
982
  assert_equal ["\xCF", "\x80"], Gem.read_binary("test").chars.to_a
971
983
  ensure
972
- File.chmod 0644, "test"
984
+ File.chmod 0o644, "test"
973
985
  end
974
986
  end
975
987
 
@@ -1030,7 +1042,8 @@ class TestGem < Gem::TestCase
1030
1042
  end
1031
1043
 
1032
1044
  def test_self_ruby_api_version
1033
- orig_ruby_version, RbConfig::CONFIG["ruby_version"] = RbConfig::CONFIG["ruby_version"], "1.2.3"
1045
+ orig_ruby_version = RbConfig::CONFIG["ruby_version"]
1046
+ RbConfig::CONFIG["ruby_version"] = "1.2.3"
1034
1047
 
1035
1048
  Gem.instance_variable_set :@ruby_api_version, nil
1036
1049
 
@@ -1503,19 +1516,31 @@ class TestGem < Gem::TestCase
1503
1516
 
1504
1517
  def test_load_env_plugins
1505
1518
  with_plugin("load") { Gem.load_env_plugins }
1506
- assert_equal :loaded, TEST_PLUGIN_LOAD rescue nil
1519
+ begin
1520
+ assert_equal :loaded, TEST_PLUGIN_LOAD
1521
+ rescue StandardError
1522
+ nil
1523
+ end
1507
1524
 
1508
1525
  util_remove_interrupt_command
1509
1526
 
1510
1527
  # Should attempt to cause a StandardError
1511
1528
  with_plugin("standarderror") { Gem.load_env_plugins }
1512
- assert_equal :loaded, TEST_PLUGIN_STANDARDERROR rescue nil
1529
+ begin
1530
+ assert_equal :loaded, TEST_PLUGIN_STANDARDERROR
1531
+ rescue StandardError
1532
+ nil
1533
+ end
1513
1534
 
1514
1535
  util_remove_interrupt_command
1515
1536
 
1516
1537
  # Should attempt to cause an Exception
1517
1538
  with_plugin("exception") { Gem.load_env_plugins }
1518
- assert_equal :loaded, TEST_PLUGIN_EXCEPTION rescue nil
1539
+ begin
1540
+ assert_equal :loaded, TEST_PLUGIN_EXCEPTION
1541
+ rescue StandardError
1542
+ nil
1543
+ end
1519
1544
  end
1520
1545
 
1521
1546
  def test_gem_path_ordering
@@ -56,7 +56,9 @@ class TestGemCommand < Gem::TestCase
56
56
  end
57
57
 
58
58
  def test_self_extra_args
59
- verbose, $VERBOSE, separator = $VERBOSE, nil, $;
59
+ verbose = $VERBOSE
60
+ $VERBOSE = nil
61
+ separator = $;
60
62
  extra_args = Gem::Command.extra_args
61
63
 
62
64
  Gem::Command.extra_args = %w[--all]