rubygems-update 3.4.21 → 3.4.22

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 (113) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +33 -0
  3. data/Manifest.txt +5 -0
  4. data/bundler/CHANGELOG.md +21 -0
  5. data/bundler/README.md +1 -2
  6. data/bundler/lib/bundler/build_metadata.rb +2 -2
  7. data/bundler/lib/bundler/cli/gem.rb +3 -0
  8. data/bundler/lib/bundler/definition.rb +1 -1
  9. data/bundler/lib/bundler/endpoint_specification.rb +1 -1
  10. data/bundler/lib/bundler/errors.rb +15 -0
  11. data/bundler/lib/bundler/gem_helpers.rb +7 -0
  12. data/bundler/lib/bundler/installer/gem_installer.rb +5 -5
  13. data/bundler/lib/bundler/lazy_specification.rb +4 -0
  14. data/bundler/lib/bundler/plugin/index.rb +8 -0
  15. data/bundler/lib/bundler/plugin.rb +9 -2
  16. data/bundler/lib/bundler/rubygems_ext.rb +3 -4
  17. data/bundler/lib/bundler/rubygems_gem_installer.rb +23 -8
  18. data/bundler/lib/bundler/source/git/git_proxy.rb +9 -1
  19. data/bundler/lib/bundler/source/metadata.rb +1 -1
  20. data/bundler/lib/bundler/spec_set.rb +5 -2
  21. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +1 -1
  22. data/bundler/lib/bundler/ui/shell.rb +1 -1
  23. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +1 -0
  24. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +21 -9
  25. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1 -1
  26. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +3 -2
  27. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +1 -1
  28. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +1 -1
  29. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +8 -10
  30. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +15 -4
  31. data/bundler/lib/bundler/vendor/thor/lib/thor/actions.rb +15 -15
  32. data/bundler/lib/bundler/vendor/thor/lib/thor/base.rb +140 -14
  33. data/bundler/lib/bundler/vendor/thor/lib/thor/command.rb +13 -4
  34. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +4 -0
  35. data/bundler/lib/bundler/vendor/thor/lib/thor/error.rb +16 -25
  36. data/bundler/lib/bundler/vendor/thor/lib/thor/group.rb +1 -1
  37. data/bundler/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -1
  38. data/bundler/lib/bundler/vendor/thor/lib/thor/nested_context.rb +2 -2
  39. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +20 -1
  40. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +33 -17
  41. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/option.rb +27 -8
  42. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +44 -6
  43. data/bundler/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +2 -2
  44. data/bundler/lib/bundler/vendor/thor/lib/thor/runner.rb +40 -30
  45. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +26 -150
  46. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/color.rb +4 -46
  47. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb +29 -0
  48. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/html.rb +3 -45
  49. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/lcs_diff.rb +49 -0
  50. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +134 -0
  51. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb +42 -0
  52. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb +38 -0
  53. data/bundler/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  54. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +8 -7
  55. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  56. data/bundler/lib/bundler/vendor/thor/lib/thor.rb +155 -8
  57. data/bundler/lib/bundler/version.rb +1 -1
  58. data/bundler/lib/bundler/yaml_serializer.rb +6 -1
  59. data/bundler/lib/bundler.rb +0 -8
  60. data/lib/rubygems/command.rb +3 -3
  61. data/lib/rubygems/commands/cert_command.rb +1 -1
  62. data/lib/rubygems/commands/contents_command.rb +1 -1
  63. data/lib/rubygems/commands/environment_command.rb +2 -2
  64. data/lib/rubygems/commands/help_command.rb +1 -1
  65. data/lib/rubygems/commands/setup_command.rb +2 -2
  66. data/lib/rubygems/commands/uninstall_command.rb +4 -4
  67. data/lib/rubygems/commands/unpack_command.rb +3 -3
  68. data/lib/rubygems/commands/update_command.rb +1 -1
  69. data/lib/rubygems/config_file.rb +3 -3
  70. data/lib/rubygems/core_ext/kernel_require.rb +1 -1
  71. data/lib/rubygems/dependency_installer.rb +4 -4
  72. data/lib/rubygems/doctor.rb +1 -1
  73. data/lib/rubygems/ext/ext_conf_builder.rb +1 -1
  74. data/lib/rubygems/ext/rake_builder.rb +1 -1
  75. data/lib/rubygems/installer.rb +7 -12
  76. data/lib/rubygems/local_remote_options.rb +1 -1
  77. data/lib/rubygems/package/digest_io.rb +1 -1
  78. data/lib/rubygems/package/tar_header.rb +2 -2
  79. data/lib/rubygems/package/tar_reader.rb +9 -2
  80. data/lib/rubygems/package/tar_writer.rb +1 -1
  81. data/lib/rubygems/package.rb +1 -1
  82. data/lib/rubygems/path_support.rb +1 -1
  83. data/lib/rubygems/platform.rb +6 -4
  84. data/lib/rubygems/remote_fetcher.rb +2 -2
  85. data/lib/rubygems/request.rb +1 -1
  86. data/lib/rubygems/request_set/gem_dependency_api.rb +1 -1
  87. data/lib/rubygems/resolver.rb +3 -3
  88. data/lib/rubygems/security/trust_dir.rb +1 -1
  89. data/lib/rubygems/source/local.rb +2 -1
  90. data/lib/rubygems/source_list.rb +1 -1
  91. data/lib/rubygems/spec_fetcher.rb +2 -2
  92. data/lib/rubygems/specification.rb +21 -13
  93. data/lib/rubygems/specification_policy.rb +6 -6
  94. data/lib/rubygems/uninstaller.rb +2 -2
  95. data/lib/rubygems/user_interaction.rb +2 -2
  96. data/lib/rubygems/util/licenses.rb +48 -0
  97. data/lib/rubygems/validator.rb +1 -1
  98. data/lib/rubygems/version.rb +3 -3
  99. data/lib/rubygems/yaml_serializer.rb +6 -1
  100. data/lib/rubygems.rb +6 -6
  101. data/rubygems-update.gemspec +1 -1
  102. data/test/rubygems/helper.rb +6 -6
  103. data/test/rubygems/test_gem_command_manager.rb +6 -6
  104. data/test/rubygems/test_gem_commands_cert_command.rb +1 -1
  105. data/test/rubygems/test_gem_commands_install_command.rb +2 -2
  106. data/test/rubygems/test_gem_commands_uninstall_command.rb +20 -0
  107. data/test/rubygems/test_gem_ext_builder.rb +1 -1
  108. data/test/rubygems/test_gem_installer.rb +1 -1
  109. data/test/rubygems/test_gem_package_tar_reader.rb +15 -0
  110. data/test/rubygems/test_gem_security_policy.rb +2 -2
  111. data/test/rubygems/test_gem_stream_ui.rb +1 -1
  112. data/test/rubygems/utilities.rb +2 -2
  113. metadata +8 -3
@@ -17,7 +17,7 @@ class Gem::Commands::EnvironmentCommand < Gem::Command
17
17
  platform display the supported gem platforms
18
18
  <omitted> display everything
19
19
  EOF
20
- return args.gsub(/^\s+/, "")
20
+ args.gsub(/^\s+/, "")
21
21
  end
22
22
 
23
23
  def description # :nodoc:
@@ -173,6 +173,6 @@ lib/rubygems/defaults/operating_system.rb
173
173
  end
174
174
  end
175
175
 
176
- return nil
176
+ nil
177
177
  end
178
178
  end
@@ -269,7 +269,7 @@ Gem::Platform::CURRENT. This will correctly mark the gem with your ruby's
269
269
  platform.
270
270
  EOF
271
271
 
272
- # NOTE when updating also update Gem::Command::HELP
272
+ # NOTE: when updating also update Gem::Command::HELP
273
273
 
274
274
  SUBCOMMANDS = [
275
275
  ["commands", :show_commands],
@@ -357,7 +357,7 @@ By default, this RubyGems will install gem as:
357
357
  say "Set the GEM_HOME environment variable if you want RDoc generated"
358
358
  end
359
359
 
360
- return false
360
+ false
361
361
  end
362
362
 
363
363
  def install_default_bundler_gem(bin_dir)
@@ -433,7 +433,7 @@ By default, this RubyGems will install gem as:
433
433
  mkdir_p lib_dir, :mode => 0o755
434
434
  mkdir_p bin_dir, :mode => 0o755
435
435
 
436
- return lib_dir, bin_dir
436
+ [lib_dir, bin_dir]
437
437
  end
438
438
 
439
439
  def generate_default_man_dir
@@ -169,10 +169,10 @@ that is a dependency of an existing gem. You can use the
169
169
  gems_to_uninstall = {}
170
170
 
171
171
  deps.each do |dep|
172
- next if gems_to_uninstall[dep.name]
173
- gems_to_uninstall[dep.name] = true
174
-
175
- unless original_gem_version[dep.name] == Gem::Requirement.default
172
+ if original_gem_version[dep.name] == Gem::Requirement.default
173
+ next if gems_to_uninstall[dep.name]
174
+ gems_to_uninstall[dep.name] = true
175
+ else
176
176
  options[:version] = dep.version
177
177
  end
178
178
 
@@ -130,7 +130,7 @@ command help for an example.
130
130
  return this_path if File.exist? this_path
131
131
  end
132
132
 
133
- return nil
133
+ nil
134
134
  end
135
135
 
136
136
  ##
@@ -151,7 +151,7 @@ command help for an example.
151
151
  # source directories?
152
152
 
153
153
  def get_path(dependency)
154
- return dependency.name if dependency.name =~ /\.gem$/i
154
+ return dependency.name if /\.gem$/i.match?(dependency.name)
155
155
 
156
156
  specs = dependency.matching_specs
157
157
 
@@ -160,7 +160,7 @@ command help for an example.
160
160
  return Gem::RemoteFetcher.fetcher.download_to_cache(dependency) unless
161
161
  selected
162
162
 
163
- return unless dependency.name =~ /^#{selected.name}$/i
163
+ return unless /^#{selected.name}$/i.match?(dependency.name)
164
164
 
165
165
  # We expect to find (basename).gem in the 'cache' directory. Furthermore,
166
166
  # the name match must be exact (ignoring case).
@@ -231,7 +231,7 @@ command to remove old versions.
231
231
  highest_remote_tup = highest_remote_name_tuple(rubygems_update)
232
232
  target = highest_remote_tup ? highest_remote_tup.version : version
233
233
 
234
- return target, requirement
234
+ [target, requirement]
235
235
  end
236
236
 
237
237
  def update_gem(name, version = Gem::Requirement.default)
@@ -202,7 +202,7 @@ class Gem::ConfigFile
202
202
  @hash = @hash.merge environment_config
203
203
  end
204
204
 
205
- # HACK these override command-line args, which is bad
205
+ # HACK: these override command-line args, which is bad
206
206
  @backtrace = @hash[:backtrace] if @hash.key? :backtrace
207
207
  @bulk_threshold = @hash[:bulk_threshold] if @hash.key? :bulk_threshold
208
208
  @home = @hash[:gemhome] if @hash.key? :gemhome
@@ -479,7 +479,7 @@ if you believe they were disclosed to a third party.
479
479
 
480
480
  @hash.each do |key, value|
481
481
  key = key.to_s
482
- next if key =~ re
482
+ next if key&.match?(re)
483
483
  yaml_hash[key.to_s] = value
484
484
  end
485
485
 
@@ -581,7 +581,7 @@ if you believe they were disclosed to a third party.
581
581
  need_config_file_name = false
582
582
  elsif arg =~ /^--config-file=(.*)/
583
583
  @config_file_name = $1
584
- elsif arg =~ /^--config-file$/
584
+ elsif /^--config-file$/.match?(arg)
585
585
  need_config_file_name = true
586
586
  end
587
587
  end
@@ -146,7 +146,7 @@ module Kernel
146
146
  end
147
147
 
148
148
  RUBYGEMS_ACTIVATION_MONITOR.exit
149
- return gem_original_require(path)
149
+ gem_original_require(path)
150
150
  rescue LoadError => load_error
151
151
  if load_error.path == path
152
152
  RUBYGEMS_ACTIVATION_MONITOR.enter
@@ -19,12 +19,12 @@ class Gem::DependencyInstaller
19
19
  DEFAULT_OPTIONS = { # :nodoc:
20
20
  :env_shebang => false,
21
21
  :document => %w[ri],
22
- :domain => :both, # HACK dup
22
+ :domain => :both, # HACK: dup
23
23
  :force => false,
24
- :format_executable => false, # HACK dup
24
+ :format_executable => false, # HACK: dup
25
25
  :ignore_dependencies => false,
26
26
  :prerelease => false,
27
- :security_policy => nil, # HACK NoSecurity requires OpenSSL. AlmostNo? Low?
27
+ :security_policy => nil, # HACK: NoSecurity requires OpenSSL. AlmostNo? Low?
28
28
  :wrappers => true,
29
29
  :build_args => nil,
30
30
  :build_docs_in_background => false,
@@ -292,7 +292,7 @@ class Gem::DependencyInstaller
292
292
  src = Gem::Source::SpecificFile.new dep_or_name
293
293
  installer_set.add_local dep_or_name, src.spec, src
294
294
  version = src.spec.version if version == Gem::Requirement.default
295
- elsif dep_or_name =~ /\.gem$/
295
+ elsif dep_or_name =~ /\.gem$/ # rubocop:disable Performance/RegexpMatch
296
296
  Dir[dep_or_name].each do |name|
297
297
  src = Gem::Source::SpecificFile.new name
298
298
  installer_set.add_local dep_or_name, src.spec, src
@@ -111,7 +111,7 @@ class Gem::Doctor
111
111
 
112
112
  basename = File.basename(child, extension)
113
113
  next if installed_specs.include? basename
114
- next if /^rubygems-\d/ =~ basename
114
+ next if /^rubygems-\d/.match?(basename)
115
115
  next if "specifications" == sub_directory && "default" == basename
116
116
  next if "plugins" == sub_directory && Gem.plugin_suffix_regexp =~ (basename)
117
117
 
@@ -43,7 +43,7 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
43
43
 
44
44
  full_tmp_dest = File.join(extension_dir, tmp_dest_relative)
45
45
 
46
- # TODO remove in RubyGems 4
46
+ # TODO: remove in RubyGems 4
47
47
  if Gem.install_extension_in_lib && lib_dir
48
48
  FileUtils.mkdir_p lib_dir
49
49
  entries = Dir.entries(full_tmp_dest) - %w[. ..]
@@ -10,7 +10,7 @@ require_relative "../shellwords"
10
10
 
11
11
  class Gem::Ext::RakeBuilder < Gem::Ext::Builder
12
12
  def self.build(extension, dest_path, results, args=[], lib_dir=nil, extension_dir=Dir.pwd)
13
- if File.basename(extension) =~ /mkrf_conf/i
13
+ if /mkrf_conf/i.match?(File.basename(extension))
14
14
  run([Gem.ruby, File.basename(extension), *args], results, class_name, extension_dir)
15
15
  end
16
16
 
@@ -230,11 +230,11 @@ class Gem::Installer
230
230
  end
231
231
  end
232
232
 
233
- next unless line =~ shebang
233
+ next unless line&.match?(shebang)
234
234
 
235
235
  io.gets # blankline
236
236
 
237
- # TODO detect a specially formatted comment instead of trying
237
+ # TODO: detect a specially formatted comment instead of trying
238
238
  # to find a string inside Ruby code.
239
239
  next unless io.gets.to_s.include?("This file was generated by RubyGems")
240
240
 
@@ -348,11 +348,6 @@ class Gem::Installer
348
348
  run_post_install_hooks
349
349
 
350
350
  spec
351
-
352
- # TODO This rescue is in the wrong place. What is raising this exception?
353
- # move this rescue to around the code that actually might raise it.
354
- rescue Zlib::GzipFile::Error
355
- raise Gem::InstallError, "gzip error installing #{gem}"
356
351
  end
357
352
 
358
353
  def run_pre_install_hooks # :nodoc:
@@ -714,7 +709,7 @@ class Gem::Installer
714
709
  end
715
710
 
716
711
  def verify_spec
717
- unless spec.name =~ Gem::Specification::VALID_NAME_PATTERN
712
+ unless Gem::Specification::VALID_NAME_PATTERN.match?(spec.name)
718
713
  raise Gem::InstallError, "#{spec} has an invalid name"
719
714
  end
720
715
 
@@ -726,11 +721,11 @@ class Gem::Installer
726
721
  raise Gem::InstallError, "#{spec} has an invalid extensions"
727
722
  end
728
723
 
729
- if spec.platform.to_s =~ /\R/
724
+ if /\R/.match?(spec.platform.to_s)
730
725
  raise Gem::InstallError, "#{spec.platform} is an invalid platform"
731
726
  end
732
727
 
733
- unless spec.specification_version.to_s =~ /\A\d+\z/
728
+ unless /\A\d+\z/.match?(spec.specification_version.to_s)
734
729
  raise Gem::InstallError, "#{spec} has an invalid specification_version"
735
730
  end
736
731
 
@@ -747,9 +742,9 @@ class Gem::Installer
747
742
  # Return the text for an application file.
748
743
 
749
744
  def app_script_text(bin_file_name)
750
- # note that the `load` lines cannot be indented, as old RG versions match
745
+ # NOTE: that the `load` lines cannot be indented, as old RG versions match
751
746
  # against the beginning of the line
752
- return <<-TEXT
747
+ <<-TEXT
753
748
  #{shebang bin_file_name}
754
749
  #
755
750
  # This file was generated by RubyGems.
@@ -105,7 +105,7 @@ module Gem::LocalRemoteOptions
105
105
 
106
106
  add_option(:"Local/Remote", "-s", "--source URL", URI::HTTP,
107
107
  "Append URL to list of remote gem sources") do |source, options|
108
- source << "/" if source !~ /\/\z/
108
+ source << "/" unless source.end_with?("/")
109
109
 
110
110
  if options.delete :sources_cleared
111
111
  Gem.sources = [source]
@@ -36,7 +36,7 @@ class Gem::Package::DigestIO
36
36
 
37
37
  yield digest_io
38
38
 
39
- return digests
39
+ digests
40
40
  end
41
41
 
42
42
  ##
@@ -125,7 +125,7 @@ class Gem::Package::TarHeader
125
125
  end
126
126
 
127
127
  def self.strict_oct(str)
128
- return str.strip.oct if str.strip =~ /\A[0-7]*\z/
128
+ return str.strip.oct if /\A[0-7]*\z/.match?(str.strip)
129
129
 
130
130
  raise ArgumentError, "#{str.inspect} is not an octal string"
131
131
  end
@@ -135,7 +135,7 @@ class Gem::Package::TarHeader
135
135
  # \ff flags a negative 256-based number
136
136
  # In case we have a match, parse it as a signed binary value
137
137
  # in big-endian order, except that the high-order bit is ignored.
138
- return str.unpack("N2").last if str =~ /\A[\x80\xff]/n
138
+ return str.unpack("N2").last if /\A[\x80\xff]/n.match?(str)
139
139
  strict_oct(str)
140
140
  end
141
141
 
@@ -50,7 +50,14 @@ class Gem::Package::TarReader
50
50
  return enum_for __method__ unless block_given?
51
51
 
52
52
  until @io.eof? do
53
- header = Gem::Package::TarHeader.from @io
53
+ begin
54
+ header = Gem::Package::TarHeader.from @io
55
+ rescue ArgumentError => e
56
+ # Specialize only exceptions from Gem::Package::TarHeader.strict_oct
57
+ raise e unless e.message.match?(/ is not an octal string$/)
58
+ raise Gem::Package::TarInvalidError, e.message
59
+ end
60
+
54
61
  return if header.empty?
55
62
  entry = Gem::Package::TarReader::Entry.new header, @io
56
63
  yield entry
@@ -83,7 +90,7 @@ class Gem::Package::TarReader
83
90
 
84
91
  return unless found
85
92
 
86
- return yield found
93
+ yield found
87
94
  ensure
88
95
  rewind
89
96
  end
@@ -324,6 +324,6 @@ class Gem::Package::TarWriter
324
324
  end
325
325
  end
326
326
 
327
- return name, prefix
327
+ [name, prefix]
328
328
  end
329
329
  end
@@ -187,7 +187,7 @@ class Gem::Package
187
187
  end
188
188
  end
189
189
 
190
- return spec, metadata
190
+ [spec, metadata]
191
191
  end
192
192
 
193
193
  ##
@@ -53,7 +53,7 @@ class Gem::PathSupport
53
53
  gem_path = gpaths.split(Gem.path_separator)
54
54
  # Handle the path_separator being set to a regexp, which will cause
55
55
  # end_with? to error
56
- if gpaths =~ /#{Gem.path_separator}\z/
56
+ if /#{Gem.path_separator}\z/.match?(gpaths)
57
57
  gem_path += default_path
58
58
  end
59
59
 
@@ -13,9 +13,11 @@ class Gem::Platform
13
13
  attr_accessor :cpu, :os, :version
14
14
 
15
15
  def self.local
16
- arch = RbConfig::CONFIG["arch"]
17
- arch = "#{arch}_60" if arch =~ /mswin(?:32|64)$/
18
- @local ||= new(arch)
16
+ @local ||= begin
17
+ arch = RbConfig::CONFIG["arch"]
18
+ arch = "#{arch}_60" if /mswin(?:32|64)$/.match?(arch)
19
+ new(arch)
20
+ end
19
21
  end
20
22
 
21
23
  def self.match(platform)
@@ -37,7 +39,7 @@ class Gem::Platform
37
39
  end
38
40
 
39
41
  def self.match_gem?(platform, gem_name)
40
- # Note: this method might be redefined by Ruby implementations to
42
+ # NOTE: this method might be redefined by Ruby implementations to
41
43
  # customize behavior per RUBY_ENGINE, gem_name or other criteria.
42
44
  match_platforms?(platform, Gem.platforms)
43
45
  end
@@ -136,7 +136,7 @@ class Gem::RemoteFetcher
136
136
  scheme = source_uri.scheme
137
137
 
138
138
  # URI.parse gets confused by MS Windows paths with forward slashes.
139
- scheme = nil if scheme =~ /^[a-z]$/i
139
+ scheme = nil if /^[a-z]$/i.match?(scheme)
140
140
 
141
141
  # REFACTOR: split this up and dispatch on scheme (eg download_http)
142
142
  # REFACTOR: be sure to clean up fake fetcher when you do this... cleaner
@@ -174,7 +174,7 @@ class Gem::RemoteFetcher
174
174
  end
175
175
 
176
176
  verbose "Using local gem #{local_gem_path}"
177
- when nil then # TODO test for local overriding cache
177
+ when nil then # TODO: test for local overriding cache
178
178
  source_path = if Gem.win_platform? && source_uri.scheme &&
179
179
  !source_uri.path.include?(":")
180
180
  "#{source_uri.scheme}:#{source_uri.path}"
@@ -238,7 +238,7 @@ class Gem::Request
238
238
  verbose "fatal error"
239
239
 
240
240
  raise Gem::RemoteFetcher::FetchError.new("fatal error", @uri)
241
- # HACK work around EOFError bug in Net::HTTP
241
+ # HACK: work around EOFError bug in Net::HTTP
242
242
  # NOTE Errno::ECONNABORTED raised a lot on Windows, and make impossible
243
243
  # to install gems.
244
244
  rescue EOFError, Timeout::Error,
@@ -817,7 +817,7 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
817
817
  end
818
818
  end
819
819
 
820
- return true
820
+ true
821
821
  end
822
822
 
823
823
  ##
@@ -145,7 +145,7 @@ class Gem::Resolver
145
145
  activation_request =
146
146
  Gem::Resolver::ActivationRequest.new spec, dep, possible
147
147
 
148
- return spec, activation_request
148
+ [spec, activation_request]
149
149
  end
150
150
 
151
151
  def requests(s, act, reqs=[]) # :nodoc:
@@ -213,7 +213,7 @@ class Gem::Resolver
213
213
 
214
214
  matching_platform = select_local_platforms all
215
215
 
216
- return matching_platform, all
216
+ [matching_platform, all]
217
217
  end
218
218
 
219
219
  ##
@@ -247,7 +247,7 @@ class Gem::Resolver
247
247
 
248
248
  sources.each do |source|
249
249
  groups[source].
250
- sort_by {|spec| [spec.version, spec.platform =~ Gem::Platform.local ? 1 : 0] }.
250
+ sort_by {|spec| [spec.version, spec.platform =~ Gem::Platform.local ? 1 : 0] }. # rubocop:disable Performance/RegexpMatch
251
251
  map {|spec| ActivationRequest.new spec, dependency }.
252
252
  each {|activation_request| activation_requests << activation_request }
253
253
  end
@@ -49,7 +49,7 @@ class Gem::Security::TrustDir
49
49
 
50
50
  yield certificate, certificate_file
51
51
  rescue OpenSSL::X509::CertificateError
52
- next # HACK warn
52
+ next # HACK: warn
53
53
  end
54
54
  end
55
55
 
@@ -42,10 +42,11 @@ class Gem::Source::Local < Gem::Source
42
42
 
43
43
  Dir["*.gem"].each do |file|
44
44
  pkg = Gem::Package.new(file)
45
+ spec = pkg.spec
45
46
  rescue SystemCallError, Gem::Package::FormatError
46
47
  # ignore
47
48
  else
48
- tup = pkg.spec.name_tuple
49
+ tup = spec.name_tuple
49
50
  @specs[tup] = [File.expand_path(file), pkg]
50
51
 
51
52
  case type
@@ -36,7 +36,7 @@ class Gem::SourceList
36
36
 
37
37
  list.replace ary
38
38
 
39
- return list
39
+ list
40
40
  end
41
41
 
42
42
  def initialize_copy(other) # :nodoc:
@@ -124,7 +124,7 @@ class Gem::SpecFetcher
124
124
 
125
125
  tuples = tuples.sort_by {|x| x[0].version }
126
126
 
127
- return [tuples, errors]
127
+ [tuples, errors]
128
128
  end
129
129
 
130
130
  ##
@@ -162,7 +162,7 @@ class Gem::SpecFetcher
162
162
  specs << [spec, source]
163
163
  end
164
164
 
165
- return [specs, errors]
165
+ [specs, errors]
166
166
  end
167
167
 
168
168
  ##
@@ -533,13 +533,6 @@ class Gem::Specification < Gem::BasicSpecification
533
533
 
534
534
  attr_reader :required_rubygems_version
535
535
 
536
- ##
537
- # The version of RubyGems used to create this gem.
538
- #
539
- # Do not set this, it is set automatically when the gem is packaged.
540
-
541
- attr_accessor :rubygems_version
542
-
543
536
  ##
544
537
  # The key used to sign this gem. See Gem::Security for details.
545
538
 
@@ -727,6 +720,21 @@ class Gem::Specification < Gem::BasicSpecification
727
720
  @test_files = Array files
728
721
  end
729
722
 
723
+ ######################################################################
724
+ # :section: Read-only attributes
725
+
726
+ ##
727
+ # The version of RubyGems used to create this gem.
728
+
729
+ attr_accessor :rubygems_version
730
+
731
+ ##
732
+ # The path where this gem installs its extensions.
733
+
734
+ def extensions_dir
735
+ @extensions_dir ||= super
736
+ end
737
+
730
738
  ######################################################################
731
739
  # :section: Specification internals
732
740
 
@@ -1449,7 +1457,7 @@ class Gem::Specification < Gem::BasicSpecification
1449
1457
  @activated = true
1450
1458
  @loaded = true
1451
1459
 
1452
- return true
1460
+ true
1453
1461
  end
1454
1462
 
1455
1463
  ##
@@ -1520,7 +1528,7 @@ class Gem::Specification < Gem::BasicSpecification
1520
1528
  def sanitize_string(string)
1521
1529
  return string unless string
1522
1530
 
1523
- # HACK the #to_s is in here because RSpec has an Array of Arrays of
1531
+ # HACK: the #to_s is in here because RSpec has an Array of Arrays of
1524
1532
  # Strings for authors. Need a way to disallow bad values on gemspec
1525
1533
  # generation. (Probably won't happen.)
1526
1534
  string.to_s
@@ -1539,7 +1547,7 @@ class Gem::Specification < Gem::BasicSpecification
1539
1547
  executables
1540
1548
  end
1541
1549
  rescue StandardError
1542
- return nil
1550
+ nil
1543
1551
  end
1544
1552
 
1545
1553
  ##
@@ -2398,8 +2406,8 @@ class Gem::Specification < Gem::BasicSpecification
2398
2406
  # Checks if this specification meets the requirement of +dependency+.
2399
2407
 
2400
2408
  def satisfies_requirement?(dependency)
2401
- return @name == dependency.name &&
2402
- dependency.requirement.satisfied_by?(@version)
2409
+ @name == dependency.name &&
2410
+ dependency.requirement.satisfied_by?(@version)
2403
2411
  end
2404
2412
 
2405
2413
  ##
@@ -2685,7 +2693,7 @@ class Gem::Specification < Gem::BasicSpecification
2685
2693
  end
2686
2694
  invalidate_memoized_attributes
2687
2695
 
2688
- return @version
2696
+ @version
2689
2697
  end
2690
2698
 
2691
2699
  def stubbed?
@@ -144,7 +144,7 @@ class Gem::SpecificationPolicy
144
144
  end
145
145
 
146
146
  next unless METADATA_LINK_KEYS.include? key
147
- if value !~ VALID_URI_PATTERN
147
+ unless VALID_URI_PATTERN.match?(value)
148
148
  error "#{entry} has invalid link: #{value.inspect}"
149
149
  end
150
150
  end
@@ -279,11 +279,11 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
279
279
 
280
280
  if !name.is_a?(String)
281
281
  error "invalid value for attribute name: \"#{name.inspect}\" must be a string"
282
- elsif name !~ /[a-zA-Z]/
282
+ elsif !/[a-zA-Z]/.match?(name)
283
283
  error "invalid value for attribute name: #{name.dump} must include at least one letter"
284
- elsif name !~ VALID_NAME_PATTERN
284
+ elsif !VALID_NAME_PATTERN.match?(name)
285
285
  error "invalid value for attribute name: #{name.dump} can only include letters, numbers, dashes, and underscores"
286
- elsif name =~ SPECIAL_CHARACTERS
286
+ elsif SPECIAL_CHARACTERS.match?(name)
287
287
  error "invalid value for attribute name: #{name.dump} can not begin with a period, dash, or underscore"
288
288
  end
289
289
  end
@@ -401,11 +401,11 @@ or set it to nil if you don't want to specify a license.
401
401
  error "#{LAZY} is not an email"
402
402
  end
403
403
 
404
- if @specification.description =~ LAZY_PATTERN
404
+ if LAZY_PATTERN.match?(@specification.description)
405
405
  error "#{LAZY} is not a description"
406
406
  end
407
407
 
408
- if @specification.summary =~ LAZY_PATTERN
408
+ if LAZY_PATTERN.match?(@specification.summary)
409
409
  error "#{LAZY} is not a summary"
410
410
  end
411
411
 
@@ -46,7 +46,7 @@ class Gem::Uninstaller
46
46
  # Constructs an uninstaller that will uninstall +gem+
47
47
 
48
48
  def initialize(gem, options = {})
49
- # TODO document the valid options
49
+ # TODO: document the valid options
50
50
  @gem = gem
51
51
  @version = options[:version] || Gem::Requirement.default
52
52
  @gem_home = File.realpath(options[:install_dir] || Gem.dir)
@@ -350,7 +350,7 @@ class Gem::Uninstaller
350
350
 
351
351
  msg << "If you remove this gem, these dependencies will not be met."
352
352
  msg << "Continue with Uninstall?"
353
- return ask_yes_no(msg.join("\n"), false)
353
+ ask_yes_no(msg.join("\n"), false)
354
354
  end
355
355
 
356
356
  ##
@@ -241,7 +241,7 @@ class Gem::StreamUI
241
241
 
242
242
  result = result.strip.to_i - 1
243
243
  return nil, nil unless (0...list.size) === result
244
- return list[result], result
244
+ [list[result], result]
245
245
  end
246
246
 
247
247
  ##
@@ -279,7 +279,7 @@ class Gem::StreamUI
279
279
  end
280
280
  end
281
281
 
282
- return result
282
+ result
283
283
  end
284
284
 
285
285
  ##