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
@@ -241,9 +241,9 @@ class Gem::ConfigFile
241
241
  return if Gem.win_platform? # windows doesn't write 0600 as 0600
242
242
  return unless File.exist? credentials_path
243
243
 
244
- existing_permissions = File.stat(credentials_path).mode & 0777
244
+ existing_permissions = File.stat(credentials_path).mode & 0o777
245
245
 
246
- return if existing_permissions == 0600
246
+ return if existing_permissions == 0o600
247
247
 
248
248
  alert_error <<-ERROR
249
249
  Your gem push credentials file located at:
@@ -324,11 +324,9 @@ if you believe they were disclosed to a third party.
324
324
  require "fileutils"
325
325
  FileUtils.mkdir_p(dirname)
326
326
 
327
- Gem.load_yaml
328
-
329
- permissions = 0600 & (~File.umask)
327
+ permissions = 0o600 & (~File.umask)
330
328
  File.open(credentials_path, "w", permissions) do |f|
331
- f.write config.to_yaml
329
+ f.write self.class.dump_with_rubygems_yaml(config)
332
330
  end
333
331
 
334
332
  load_api_keys # reload
@@ -344,20 +342,18 @@ if you believe they were disclosed to a third party.
344
342
  end
345
343
 
346
344
  def load_file(filename)
347
- Gem.load_yaml
348
-
349
345
  yaml_errors = [ArgumentError]
350
- yaml_errors << Psych::SyntaxError if defined?(Psych::SyntaxError)
351
346
 
352
347
  return {} unless filename && !filename.empty? && File.exist?(filename)
353
348
 
354
349
  begin
355
- content = Gem::SafeYAML.load(File.read(filename))
356
- unless content.is_a? Hash
350
+ config = self.class.load_with_rubygems_config_hash(File.read(filename))
351
+ if config.keys.any? {|k| k.to_s.gsub(%r{https?:\/\/}, "").include?(": ") }
357
352
  warn "Failed to load #{filename} because it doesn't contain valid YAML hash"
358
353
  return {}
354
+ else
355
+ return config
359
356
  end
360
- return content
361
357
  rescue *yaml_errors => e
362
358
  warn "Failed to load #{filename}, #{e}"
363
359
  rescue Errno::EACCES
@@ -487,7 +483,7 @@ if you believe they were disclosed to a third party.
487
483
  yaml_hash[key.to_s] = value
488
484
  end
489
485
 
490
- yaml_hash.to_yaml
486
+ self.class.dump_with_rubygems_yaml(yaml_hash)
491
487
  end
492
488
 
493
489
  # Writes out this config file, replacing its source.
@@ -522,6 +518,57 @@ if you believe they were disclosed to a third party.
522
518
  attr_reader :hash
523
519
  protected :hash
524
520
 
521
+ def self.dump_with_rubygems_yaml(content)
522
+ content.transform_keys! do |k|
523
+ k.is_a?(Symbol) ? ":#{k}" : k
524
+ end
525
+
526
+ require_relative "yaml_serializer"
527
+ Gem::YAMLSerializer.dump(content)
528
+ end
529
+
530
+ def self.load_with_rubygems_config_hash(yaml)
531
+ require_relative "yaml_serializer"
532
+
533
+ content = Gem::YAMLSerializer.load(yaml)
534
+
535
+ content.transform_keys! do |k|
536
+ if k.match?(/\A:(.*)\Z/)
537
+ k[1..-1].to_sym
538
+ elsif k.include?("__") || k.match?(%r{/\Z})
539
+ if k.is_a?(Symbol)
540
+ k.to_s.gsub(/__/,".").gsub(%r{/\Z}, "").to_sym
541
+ else
542
+ k.dup.gsub(/__/,".").gsub(%r{/\Z}, "")
543
+ end
544
+ else
545
+ k
546
+ end
547
+ end
548
+
549
+ content.transform_values! do |v|
550
+ if v.is_a?(String)
551
+ if v.match?(/\A:(.*)\Z/)
552
+ v[1..-1].to_sym
553
+ elsif v.match?(/\A[+-]?\d+\Z/)
554
+ v.to_i
555
+ elsif v.match?(/\Atrue|false\Z/)
556
+ v == "true"
557
+ elsif v.empty?
558
+ nil
559
+ else
560
+ v
561
+ end
562
+ elsif v.is_a?(Hash) && v.empty?
563
+ nil
564
+ else
565
+ v
566
+ end
567
+ end
568
+
569
+ content
570
+ end
571
+
525
572
  private
526
573
 
527
574
  def set_config_file_name(args)
@@ -39,7 +39,7 @@ module Kernel
39
39
 
40
40
  if gem_name.is_a? Gem::Dependency
41
41
  unless Gem::Deprecate.skip
42
- warn "#{Gem.location_of_caller.join ':'}:Warning: Kernel.gem no longer "\
42
+ warn "#{Gem.location_of_caller.join ":"}:Warning: Kernel.gem no longer "\
43
43
  "accepts a Gem::Dependency object, please pass the name "\
44
44
  "and requirements directly"
45
45
  end
@@ -128,7 +128,7 @@ module Kernel
128
128
 
129
129
  if names.size > 1
130
130
  RUBYGEMS_ACTIVATION_MONITOR.exit
131
- raise Gem::LoadError, "#{path} found in multiple gems: #{names.join ', '}"
131
+ raise Gem::LoadError, "#{path} found in multiple gems: #{names.join ", "}"
132
132
  end
133
133
 
134
134
  # Ok, now find a gem that has no conflicts, starting
@@ -80,7 +80,7 @@ module Gem
80
80
 
81
81
  def self.find_home
82
82
  Dir.home.dup
83
- rescue
83
+ rescue StandardError
84
84
  if Gem.win_platform?
85
85
  File.expand_path File.join(ENV["HOMEDRIVE"] || ENV["SystemDrive"], "/")
86
86
  else
@@ -184,7 +184,11 @@ module Gem
184
184
  # Deduce Ruby's --program-prefix and --program-suffix from its install name
185
185
 
186
186
  def self.default_exec_format
187
- exec_format = RbConfig::CONFIG["ruby_install_name"].sub("ruby", "%s") rescue "%s"
187
+ exec_format = begin
188
+ RbConfig::CONFIG["ruby_install_name"].sub("ruby", "%s")
189
+ rescue StandardError
190
+ "%s"
191
+ end
188
192
 
189
193
  unless exec_format.include?("%s")
190
194
  raise Gem::Exception,
@@ -83,7 +83,8 @@ module Gem::Deprecate
83
83
  # Temporarily turn off warnings. Intended for tests only.
84
84
 
85
85
  def skip_during
86
- Gem::Deprecate.skip, original = true, Gem::Deprecate.skip
86
+ original = Gem::Deprecate.skip
87
+ Gem::Deprecate.skip = true
87
88
  yield
88
89
  ensure
89
90
  Gem::Deprecate.skip = original
@@ -33,7 +33,7 @@ class Gem::Doctor
33
33
  Gem::REPOSITORY_SUBDIRECTORIES.sort -
34
34
  REPOSITORY_EXTENSION_MAP.map {|(k,_)| k }.sort
35
35
 
36
- raise "Update REPOSITORY_EXTENSION_MAP, missing: #{missing.join ', '}" unless
36
+ raise "Update REPOSITORY_EXTENSION_MAP, missing: #{missing.join ", "}" unless
37
37
  missing.empty?
38
38
 
39
39
  ##
@@ -61,7 +61,7 @@ module Gem
61
61
 
62
62
  def build_message
63
63
  names = specs.map(&:full_name)
64
- "Could not find '#{name}' (#{requirement}) - did find: [#{names.join ','}]\n"
64
+ "Could not find '#{name}' (#{requirement}) - did find: [#{names.join ","}]\n"
65
65
  end
66
66
  end
67
67
 
@@ -264,7 +264,7 @@ class Gem::UnsatisfiableDependencyError < Gem::DependencyError
264
264
  def initialize(dep, platform_mismatch=nil)
265
265
  if platform_mismatch && !platform_mismatch.empty?
266
266
  plats = platform_mismatch.map {|x| x.platform.to_s }.sort.uniq
267
- super "Unable to resolve dependency: No match for '#{dep}' on this platform. Found: #{plats.join(', ')}"
267
+ super "Unable to resolve dependency: No match for '#{dep}' on this platform. Found: #{plats.join(", ")}"
268
268
  else
269
269
  if dep.explicit?
270
270
  super "Unable to resolve dependency: user requested '#{dep}'"
@@ -77,7 +77,8 @@ class Gem::Ext::Builder
77
77
  verbose = Gem.configuration.really_verbose
78
78
 
79
79
  begin
80
- rubygems_gemdeps, ENV["RUBYGEMS_GEMDEPS"] = ENV["RUBYGEMS_GEMDEPS"], nil
80
+ rubygems_gemdeps = ENV["RUBYGEMS_GEMDEPS"]
81
+ ENV["RUBYGEMS_GEMDEPS"] = nil
81
82
  if verbose
82
83
  puts("current directory: #{dir}")
83
84
  p(command)
@@ -90,7 +91,7 @@ class Gem::Ext::Builder
90
91
  build_env = { "SOURCE_DATE_EPOCH" => Gem.source_date_epoch_string }.merge(env)
91
92
  output, status = begin
92
93
  Open3.capture2e(build_env, *command, :chdir => dir)
93
- rescue => error
94
+ rescue StandardError => error
94
95
  raise Gem::InstallError, "#{command_name || class_name} failed#{error.message}"
95
96
  end
96
97
  if verbose
@@ -190,7 +191,7 @@ EOF
190
191
  verbose { results.join("\n") }
191
192
 
192
193
  write_gem_make_out results.join "\n"
193
- rescue => e
194
+ rescue StandardError => e
194
195
  results << e.message
195
196
  build_error(results.join("\n"), $@)
196
197
  end
@@ -206,7 +207,7 @@ EOF
206
207
  if @build_args.empty?
207
208
  say "Building native extensions. This could take a while..."
208
209
  else
209
- say "Building native extensions with: '#{@build_args.join ' '}'"
210
+ say "Building native extensions with: '#{@build_args.join " "}'"
210
211
  say "This could take a while..."
211
212
  end
212
213
 
@@ -199,7 +199,7 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
199
199
  output, status =
200
200
  begin
201
201
  Open3.capture2e(cargo, "metadata", "--no-deps", "--format-version", "1", :chdir => cargo_dir)
202
- rescue => error
202
+ rescue StandardError => error
203
203
  raise Gem::InstallError, "cargo metadata failed #{error.message}"
204
204
  end
205
205
 
@@ -313,7 +313,7 @@ EOF
313
313
  deffile_path
314
314
  end
315
315
 
316
- # We have to basically reimplement RbConfig::CONFIG['SOEXT'] here to support
316
+ # We have to basically reimplement <code>RbConfig::CONFIG['SOEXT']</code> here to support
317
317
  # Ruby < 2.5
318
318
  #
319
319
  # @see https://github.com/ruby/ruby/blob/c87c027f18c005460746a74c07cd80ee355b16e4/configure.ac#L3185
@@ -33,7 +33,11 @@ class Gem::GemRunner
33
33
 
34
34
  do_configuration args
35
35
 
36
- Gem.load_env_plugins rescue nil
36
+ begin
37
+ Gem.load_env_plugins
38
+ rescue StandardError
39
+ nil
40
+ end
37
41
  Gem.load_plugins
38
42
 
39
43
  cmd = @command_manager_class.instance
@@ -216,7 +216,7 @@ module Gem::GemcutterUtilities
216
216
  say clean_text(response.body)
217
217
  end
218
218
  when Net::HTTPPermanentRedirect, Net::HTTPRedirection then
219
- message = "The request has redirected permanently to #{response['location']}. Please check your defined push host URL."
219
+ message = "The request has redirected permanently to #{response["location"]}. Please check your defined push host URL."
220
220
  message = "#{error_prefix}: #{message}" if error_prefix
221
221
 
222
222
  say clean_text(message)
@@ -338,7 +338,7 @@ module Gem::GemcutterUtilities
338
338
  end
339
339
 
340
340
  with_response response do |resp|
341
- Gem::SafeYAML.load clean_text(resp.body)
341
+ Gem::ConfigFile.load_with_rubygems_config_hash(clean_text(resp.body))
342
342
  end
343
343
  end
344
344
 
@@ -327,7 +327,7 @@ class Gem::Indexer
327
327
 
328
328
  def make_temp_directories
329
329
  FileUtils.rm_rf @directory
330
- FileUtils.mkdir_p @directory, :mode => 0700
330
+ FileUtils.mkdir_p @directory, :mode => 0o700
331
331
  FileUtils.mkdir_p @quick_marshal_dir
332
332
  end
333
333
 
@@ -142,7 +142,7 @@ module Gem::InstallUpdateOptions
142
142
  end unless v
143
143
 
144
144
  unless v
145
- message = v ? v : "(tried #{Gem::GEM_DEP_FILES.join ', '})"
145
+ message = v ? v : "(tried #{Gem::GEM_DEP_FILES.join ", "})"
146
146
 
147
147
  raise Gem::OptionParser::InvalidArgument,
148
148
  "cannot find gem dependencies file #{message}"
@@ -316,7 +316,7 @@ class Gem::Installer
316
316
  FileUtils.rm_rf spec.extension_dir
317
317
 
318
318
  dir_mode = options[:dir_mode]
319
- FileUtils.mkdir_p gem_dir, :mode => dir_mode && 0755
319
+ FileUtils.mkdir_p gem_dir, :mode => dir_mode && 0o755
320
320
 
321
321
  if @options[:install_as_default]
322
322
  extract_bin
@@ -494,7 +494,7 @@ class Gem::Installer
494
494
  next unless File.exist? bin_path
495
495
 
496
496
  mode = File.stat(bin_path).mode
497
- dir_mode = options[:prog_mode] || (mode | 0111)
497
+ dir_mode = options[:prog_mode] || (mode | 0o111)
498
498
 
499
499
  unless dir_mode == mode
500
500
  require "fileutils"
@@ -537,9 +537,9 @@ class Gem::Installer
537
537
  require "fileutils"
538
538
  FileUtils.rm_f bin_script_path # prior install may have been --no-wrappers
539
539
 
540
- File.open bin_script_path, "wb", 0755 do |file|
540
+ File.open bin_script_path, "wb", 0o755 do |file|
541
541
  file.print app_script_text(filename)
542
- file.chmod(options[:prog_mode] || 0755)
542
+ file.chmod(options[:prog_mode] || 0o755)
543
543
  end
544
544
 
545
545
  verbose bin_script_path
@@ -709,7 +709,7 @@ class Gem::Installer
709
709
  end
710
710
 
711
711
  def verify_gem_home # :nodoc:
712
- FileUtils.mkdir_p gem_home, :mode => options[:dir_mode] && 0755
712
+ FileUtils.mkdir_p gem_home, :mode => options[:dir_mode] && 0o755
713
713
  raise Gem::FilePermissionError, gem_home unless File.writable?(gem_home)
714
714
  end
715
715
 
@@ -806,7 +806,7 @@ TEXT
806
806
  rb_topdir = RbConfig::TOPDIR || File.dirname(rb_config["bindir"])
807
807
 
808
808
  # get ruby executable file name from RbConfig
809
- ruby_exe = "#{rb_config['RUBY_INSTALL_NAME']}#{rb_config['EXEEXT']}"
809
+ ruby_exe = "#{rb_config["RUBY_INSTALL_NAME"]}#{rb_config["EXEEXT"]}"
810
810
  ruby_exe = "ruby.exe" if ruby_exe.empty?
811
811
 
812
812
  if File.exist?(File.join bindir, ruby_exe)
@@ -931,7 +931,7 @@ TEXT
931
931
  build_info_dir = File.join gem_home, "build_info"
932
932
 
933
933
  dir_mode = options[:dir_mode]
934
- FileUtils.mkdir_p build_info_dir, :mode => dir_mode && 0755
934
+ FileUtils.mkdir_p build_info_dir, :mode => dir_mode && 0o755
935
935
 
936
936
  build_info_file = File.join build_info_dir, "#{spec.full_name}.info"
937
937
 
@@ -954,7 +954,7 @@ TEXT
954
954
 
955
955
  def ensure_writable_dir(dir) # :nodoc:
956
956
  begin
957
- Dir.mkdir dir, *[options[:dir_mode] && 0755].compact
957
+ Dir.mkdir dir, *[options[:dir_mode] && 0o755].compact
958
958
  rescue SystemCallError
959
959
  raise unless File.directory? dir
960
960
  end
@@ -78,7 +78,7 @@ class Gem::Package::Old < Gem::Package
78
78
 
79
79
  FileUtils.rm_rf destination
80
80
 
81
- FileUtils.mkdir_p File.dirname(destination), :mode => dir_mode && 0755
81
+ FileUtils.mkdir_p File.dirname(destination), :mode => dir_mode && 0o755
82
82
 
83
83
  File.open destination, "wb", file_mode(entry["mode"]) do |out|
84
84
  out.write file_data
@@ -190,7 +190,7 @@ class Gem::Package::TarWriter
190
190
  if signer.key
191
191
  signature = signer.sign signature_digest.digest
192
192
 
193
- add_file_simple "#{name}.sig", 0444, signature.length do |io|
193
+ add_file_simple "#{name}.sig", 0o444, signature.length do |io|
194
194
  io.write signature
195
195
  end
196
196
  end
@@ -230,7 +230,7 @@ class Gem::Package
230
230
  end
231
231
  end
232
232
 
233
- tar.add_file_signed "checksums.yaml.gz", 0444, @signer do |io|
233
+ tar.add_file_signed "checksums.yaml.gz", 0o444, @signer do |io|
234
234
  gzip_to io do |gz_io|
235
235
  Psych.dump checksums_by_algorithm, gz_io
236
236
  end
@@ -242,7 +242,7 @@ class Gem::Package
242
242
  # and adds this file to the +tar+.
243
243
 
244
244
  def add_contents(tar) # :nodoc:
245
- digests = tar.add_file_signed "data.tar.gz", 0444, @signer do |io|
245
+ digests = tar.add_file_signed "data.tar.gz", 0o444, @signer do |io|
246
246
  gzip_to io do |gz_io|
247
247
  Gem::Package::TarWriter.new gz_io do |data_tar|
248
248
  add_files data_tar
@@ -278,7 +278,7 @@ class Gem::Package
278
278
  # Adds the package's Gem::Specification to the +tar+ file
279
279
 
280
280
  def add_metadata(tar) # :nodoc:
281
- digests = tar.add_file_signed "metadata.gz", 0444, @signer do |io|
281
+ digests = tar.add_file_signed "metadata.gz", 0o444, @signer do |io|
282
282
  gzip_to io do |gz_io|
283
283
  gz_io.write @spec.to_yaml
284
284
  end
@@ -384,7 +384,7 @@ EOM
384
384
  def extract_files(destination_dir, pattern = "*")
385
385
  verify unless @spec
386
386
 
387
- FileUtils.mkdir_p destination_dir, :mode => dir_mode && 0755
387
+ FileUtils.mkdir_p destination_dir, :mode => dir_mode && 0o755
388
388
 
389
389
  @gem.with_read_io do |io|
390
390
  reader = Gem::Package::TarReader.new io
@@ -438,7 +438,7 @@ EOM
438
438
  FileUtils.rm_rf destination
439
439
 
440
440
  mkdir_options = {}
441
- mkdir_options[:mode] = dir_mode ? 0755 : (entry.header.mode if entry.directory?)
441
+ mkdir_options[:mode] = dir_mode ? 0o755 : (entry.header.mode if entry.directory?)
442
442
  mkdir =
443
443
  if entry.directory?
444
444
  destination
@@ -474,7 +474,7 @@ EOM
474
474
  end
475
475
 
476
476
  def file_mode(mode) # :nodoc:
477
- ((mode & 0111).zero? ? data_mode : prog_mode) ||
477
+ ((mode & 0o111).zero? ? data_mode : prog_mode) ||
478
478
  # If we're not using one of the default modes, then we're going to fall
479
479
  # back to the mode from the tarball. In this case we need to mask it down
480
480
  # to fit into 2^16 bits (the maximum value for a mode in CRuby since it
@@ -676,7 +676,7 @@ EOM
676
676
  when "data.tar.gz" then
677
677
  verify_gz entry
678
678
  end
679
- rescue
679
+ rescue StandardError
680
680
  warn "Exception while verifying #{@gem.path}"
681
681
  raise
682
682
  end
@@ -699,7 +699,7 @@ EOM
699
699
  end
700
700
 
701
701
  if (duplicates = @files.group_by {|f| f }.select {|k,v| v.size > 1 }.map(&:first)) && duplicates.any?
702
- raise Gem::Security::Exception, "duplicate files in the package: (#{duplicates.map(&:inspect).join(', ')})"
702
+ raise Gem::Security::Exception, "duplicate files in the package: (#{duplicates.map(&:inspect).join(", ")})"
703
703
  end
704
704
  end
705
705
 
@@ -90,7 +90,10 @@ class Gem::Platform
90
90
  end
91
91
 
92
92
  os, = arch
93
- @cpu, os = nil, cpu if os.nil? # legacy jruby
93
+ if os.nil?
94
+ @cpu = nil
95
+ os = cpu
96
+ end # legacy jruby
94
97
 
95
98
  @os, @version = case os
96
99
  when /aix(\d+)?/ then [ "aix", $1 ]
@@ -107,7 +110,8 @@ class Gem::Platform
107
110
  when /mingw32/ then [ "mingw32", nil ]
108
111
  when /mingw-?(\w+)?/ then [ "mingw", $1 ]
109
112
  when /(mswin\d+)(\_(\d+))?/ then
110
- os, version = $1, $3
113
+ os = $1
114
+ version = $3
111
115
  @cpu = "x86" if @cpu.nil? && os =~ /32$/
112
116
  [os, version]
113
117
  when /netbsdelf/ then [ "netbsdelf", nil ]
@@ -264,7 +264,7 @@ module Gem::QueryUtils
264
264
  end
265
265
  end
266
266
 
267
- entry << " (#{list.join ', '})"
267
+ entry << " (#{list.join ", "})"
268
268
  end
269
269
 
270
270
  def make_entry(entry_tuples, platforms)
@@ -283,7 +283,7 @@ module Gem::QueryUtils
283
283
  end
284
284
 
285
285
  def spec_authors(entry, spec)
286
- authors = "Author#{spec.authors.length > 1 ? 's' : ''}: ".dup
286
+ authors = "Author#{spec.authors.length > 1 ? "s" : ""}: ".dup
287
287
  authors << spec.authors.join(", ")
288
288
  entry << format_text(authors, 68, 4)
289
289
  end
@@ -297,7 +297,7 @@ module Gem::QueryUtils
297
297
  def spec_license(entry, spec)
298
298
  return if spec.license.nil? || spec.license.empty?
299
299
 
300
- licenses = "License#{spec.licenses.length > 1 ? 's' : ''}: ".dup
300
+ licenses = "License#{spec.licenses.length > 1 ? "s" : ""}: ".dup
301
301
  licenses << spec.licenses.join(", ")
302
302
  entry << "\n" << format_text(licenses, 68, 4)
303
303
  end
@@ -328,7 +328,7 @@ module Gem::QueryUtils
328
328
 
329
329
  if platforms.length == 1
330
330
  title = platforms.values.length == 1 ? "Platform" : "Platforms"
331
- entry << " #{title}: #{platforms.values.sort.join(', ')}\n"
331
+ entry << " #{title}: #{platforms.values.sort.join(", ")}\n"
332
332
  else
333
333
  entry << " Platforms:\n"
334
334
 
@@ -125,7 +125,11 @@ class Gem::RemoteFetcher
125
125
  local_gem_path = File.join cache_dir, gem_file_name
126
126
 
127
127
  require "fileutils"
128
- FileUtils.mkdir_p cache_dir rescue nil unless File.exist? cache_dir
128
+ begin
129
+ FileUtils.mkdir_p cache_dir
130
+ rescue StandardError
131
+ nil
132
+ end unless File.exist? cache_dir
129
133
 
130
134
  source_uri = Gem::Uri.new(source_uri)
131
135
 
@@ -281,7 +285,11 @@ class Gem::RemoteFetcher
281
285
  # passes the data.
282
286
 
283
287
  def cache_update_path(uri, path = nil, update = true)
284
- mtime = path && File.stat(path).mtime rescue nil
288
+ mtime = begin
289
+ path && File.stat(path).mtime
290
+ rescue StandardError
291
+ nil
292
+ end
285
293
 
286
294
  data = fetch_path(uri, mtime)
287
295
 
@@ -255,7 +255,8 @@ class Gem::RequestSet
255
255
  end
256
256
 
257
257
  def install_into(dir, force = true, options = {})
258
- gem_home, ENV["GEM_HOME"] = ENV["GEM_HOME"], dir
258
+ gem_home = ENV["GEM_HOME"]
259
+ ENV["GEM_HOME"] = dir
259
260
 
260
261
  existing = force ? [] : specs_in(dir)
261
262
  existing.delete_if {|s| @always_install.include? s }
@@ -164,7 +164,7 @@ class Gem::Requirement
164
164
  "#{op} #{version}"
165
165
  end.uniq
166
166
 
167
- " (#{list.join ', '})"
167
+ " (#{list.join ", "})"
168
168
  end
169
169
 
170
170
  ##
@@ -76,7 +76,8 @@ class Gem::Resolver::APISet < Gem::Resolver::Set
76
76
  end
77
77
 
78
78
  def prefetch_now # :nodoc:
79
- needed, @to_fetch = @to_fetch, []
79
+ needed = @to_fetch
80
+ @to_fetch = []
80
81
 
81
82
  needed.sort.each do |name|
82
83
  versions(name)
@@ -22,7 +22,7 @@ class Gem::Resolver::APISpecification < Gem::Resolver::Specification
22
22
  # Creates an APISpecification for the given +set+ from the rubygems.org
23
23
  # +api_data+.
24
24
  #
25
- # See https://guides.rubygems.org/rubygems-org-api/#misc_methods for the
25
+ # See https://guides.rubygems.org/rubygems-org-api/#misc-methods for the
26
26
  # format of the +api_data+.
27
27
 
28
28
  def initialize(set, api_data)
@@ -175,10 +175,18 @@ class Gem::Security::Signer
175
175
  old_cert = @cert_chain.last
176
176
 
177
177
  disk_cert_path = File.join(Gem.default_cert_path)
178
- disk_cert = File.read(disk_cert_path) rescue nil
178
+ disk_cert = begin
179
+ File.read(disk_cert_path)
180
+ rescue StandardError
181
+ nil
182
+ end
179
183
 
180
184
  disk_key_path = File.join(Gem.default_key_path)
181
- disk_key = OpenSSL::PKey.read(File.read(disk_key_path), @passphrase) rescue nil
185
+ disk_key = begin
186
+ OpenSSL::PKey.read(File.read(disk_key_path), @passphrase)
187
+ rescue StandardError
188
+ nil
189
+ end
182
190
 
183
191
  return unless disk_key
184
192
 
@@ -9,8 +9,8 @@ class Gem::Security::TrustDir
9
9
  # Default permissions for the trust directory and its contents
10
10
 
11
11
  DEFAULT_PERMISSIONS = {
12
- :trust_dir => 0700,
13
- :trusted_cert => 0600,
12
+ :trust_dir => 0o700,
13
+ :trusted_cert => 0o600,
14
14
  }.freeze
15
15
 
16
16
  ##
@@ -91,7 +91,7 @@ class Gem::Security::TrustDir
91
91
 
92
92
  destination = cert_path certificate
93
93
 
94
- File.open destination, "wb", 0600 do |io|
94
+ File.open destination, "wb", 0o600 do |io|
95
95
  io.write certificate.to_pem
96
96
  io.chmod(@permissions[:trusted_cert])
97
97
  end
@@ -109,7 +109,7 @@ class Gem::Security::TrustDir
109
109
  "trust directory #{@dir} is not a directory" unless
110
110
  File.directory? @dir
111
111
 
112
- FileUtils.chmod 0700, @dir
112
+ FileUtils.chmod 0o700, @dir
113
113
  else
114
114
  FileUtils.mkdir_p @dir, :mode => @permissions[:trust_dir]
115
115
  end
@@ -602,7 +602,7 @@ module Gem::Security
602
602
  # +permissions+. If passed +cipher+ and +passphrase+ those arguments will be
603
603
  # passed to +to_pem+.
604
604
 
605
- def self.write(pemmable, path, permissions = 0600, passphrase = nil, cipher = KEY_CIPHER)
605
+ def self.write(pemmable, path, permissions = 0o600, passphrase = nil, cipher = KEY_CIPHER)
606
606
  path = File.expand_path path
607
607
 
608
608
  File.open path, "wb", permissions do |io|
@@ -29,7 +29,7 @@ module Gem::SecurityOption
29
29
  policy = Gem::Security::Policies[value]
30
30
  unless policy
31
31
  valid = Gem::Security::Policies.keys.sort
32
- raise Gem::OptionParser::InvalidArgument, "#{value} (#{valid.join ', '} are valid)"
32
+ raise Gem::OptionParser::InvalidArgument, "#{value} (#{valid.join ", "} are valid)"
33
33
  end
34
34
  policy
35
35
  end