rubygems-update 3.4.20 → 3.4.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +55 -0
  3. data/Manifest.txt +6 -0
  4. data/bundler/CHANGELOG.md +55 -3
  5. data/bundler/README.md +1 -2
  6. data/bundler/lib/bundler/build_metadata.rb +3 -3
  7. data/bundler/lib/bundler/cli/check.rb +1 -1
  8. data/bundler/lib/bundler/cli/gem.rb +4 -3
  9. data/bundler/lib/bundler/cli/install.rb +2 -2
  10. data/bundler/lib/bundler/cli/lock.rb +26 -23
  11. data/bundler/lib/bundler/cli/open.rb +5 -7
  12. data/bundler/lib/bundler/definition.rb +43 -26
  13. data/bundler/lib/bundler/endpoint_specification.rb +1 -1
  14. data/bundler/lib/bundler/env.rb +2 -2
  15. data/bundler/lib/bundler/errors.rb +15 -0
  16. data/bundler/lib/bundler/gem_helpers.rb +7 -0
  17. data/bundler/lib/bundler/gem_version_promoter.rb +2 -2
  18. data/bundler/lib/bundler/injector.rb +1 -1
  19. data/bundler/lib/bundler/installer/gem_installer.rb +5 -5
  20. data/bundler/lib/bundler/installer/parallel_installer.rb +0 -26
  21. data/bundler/lib/bundler/installer/standalone.rb +13 -6
  22. data/bundler/lib/bundler/lazy_specification.rb +4 -0
  23. data/bundler/lib/bundler/lockfile_parser.rb +29 -24
  24. data/bundler/lib/bundler/man/bundle-add.1 +1 -1
  25. data/bundler/lib/bundler/man/bundle-binstubs.1 +1 -1
  26. data/bundler/lib/bundler/man/bundle-cache.1 +1 -1
  27. data/bundler/lib/bundler/man/bundle-check.1 +1 -1
  28. data/bundler/lib/bundler/man/bundle-clean.1 +1 -1
  29. data/bundler/lib/bundler/man/bundle-config.1 +1 -1
  30. data/bundler/lib/bundler/man/bundle-console.1 +1 -1
  31. data/bundler/lib/bundler/man/bundle-doctor.1 +1 -1
  32. data/bundler/lib/bundler/man/bundle-exec.1 +2 -2
  33. data/bundler/lib/bundler/man/bundle-exec.1.ronn +2 -3
  34. data/bundler/lib/bundler/man/bundle-gem.1 +1 -1
  35. data/bundler/lib/bundler/man/bundle-help.1 +1 -1
  36. data/bundler/lib/bundler/man/bundle-info.1 +1 -1
  37. data/bundler/lib/bundler/man/bundle-init.1 +1 -1
  38. data/bundler/lib/bundler/man/bundle-inject.1 +1 -1
  39. data/bundler/lib/bundler/man/bundle-install.1 +1 -1
  40. data/bundler/lib/bundler/man/bundle-list.1 +1 -1
  41. data/bundler/lib/bundler/man/bundle-lock.1 +1 -1
  42. data/bundler/lib/bundler/man/bundle-open.1 +1 -1
  43. data/bundler/lib/bundler/man/bundle-outdated.1 +1 -1
  44. data/bundler/lib/bundler/man/bundle-platform.1 +1 -1
  45. data/bundler/lib/bundler/man/bundle-plugin.1 +17 -17
  46. data/bundler/lib/bundler/man/bundle-plugin.1.ronn +5 -5
  47. data/bundler/lib/bundler/man/bundle-pristine.1 +1 -1
  48. data/bundler/lib/bundler/man/bundle-remove.1 +1 -1
  49. data/bundler/lib/bundler/man/bundle-show.1 +1 -1
  50. data/bundler/lib/bundler/man/bundle-update.1 +1 -1
  51. data/bundler/lib/bundler/man/bundle-version.1 +1 -1
  52. data/bundler/lib/bundler/man/bundle-viz.1 +1 -1
  53. data/bundler/lib/bundler/man/bundle.1 +1 -1
  54. data/bundler/lib/bundler/man/gemfile.5 +1 -1
  55. data/bundler/lib/bundler/plugin/index.rb +8 -0
  56. data/bundler/lib/bundler/plugin.rb +9 -2
  57. data/bundler/lib/bundler/resolver/package.rb +5 -0
  58. data/bundler/lib/bundler/resolver.rb +27 -7
  59. data/bundler/lib/bundler/ruby_version.rb +8 -1
  60. data/bundler/lib/bundler/rubygems_ext.rb +3 -4
  61. data/bundler/lib/bundler/rubygems_gem_installer.rb +23 -8
  62. data/bundler/lib/bundler/settings.rb +53 -16
  63. data/bundler/lib/bundler/shared_helpers.rb +16 -1
  64. data/bundler/lib/bundler/source/git/git_proxy.rb +21 -4
  65. data/bundler/lib/bundler/source/metadata.rb +1 -1
  66. data/bundler/lib/bundler/spec_set.rb +7 -4
  67. data/bundler/lib/bundler/stub_specification.rb +4 -2
  68. data/bundler/lib/bundler/templates/newgem/Rakefile.tt +6 -2
  69. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +1 -1
  70. data/bundler/lib/bundler/ui/shell.rb +1 -1
  71. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +1 -0
  72. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +21 -9
  73. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1 -1
  74. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +3 -2
  75. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +1 -1
  76. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +1 -1
  77. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +8 -10
  78. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +15 -4
  79. data/bundler/lib/bundler/vendor/thor/lib/thor/actions.rb +15 -15
  80. data/bundler/lib/bundler/vendor/thor/lib/thor/base.rb +140 -14
  81. data/bundler/lib/bundler/vendor/thor/lib/thor/command.rb +13 -4
  82. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +4 -0
  83. data/bundler/lib/bundler/vendor/thor/lib/thor/error.rb +16 -25
  84. data/bundler/lib/bundler/vendor/thor/lib/thor/group.rb +1 -1
  85. data/bundler/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -1
  86. data/bundler/lib/bundler/vendor/thor/lib/thor/nested_context.rb +2 -2
  87. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +20 -1
  88. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +33 -17
  89. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/option.rb +27 -8
  90. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +44 -6
  91. data/bundler/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +2 -2
  92. data/bundler/lib/bundler/vendor/thor/lib/thor/runner.rb +40 -30
  93. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +26 -150
  94. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/color.rb +4 -46
  95. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb +29 -0
  96. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/html.rb +3 -45
  97. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/lcs_diff.rb +49 -0
  98. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +134 -0
  99. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb +42 -0
  100. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb +38 -0
  101. data/bundler/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  102. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +8 -7
  103. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  104. data/bundler/lib/bundler/vendor/thor/lib/thor.rb +155 -8
  105. data/bundler/lib/bundler/version.rb +1 -1
  106. data/bundler/lib/bundler/yaml_serializer.rb +12 -8
  107. data/bundler/lib/bundler.rb +0 -8
  108. data/lib/rubygems/basic_specification.rb +1 -1
  109. data/lib/rubygems/command.rb +5 -5
  110. data/lib/rubygems/command_manager.rb +1 -1
  111. data/lib/rubygems/commands/cert_command.rb +3 -3
  112. data/lib/rubygems/commands/check_command.rb +5 -1
  113. data/lib/rubygems/commands/cleanup_command.rb +1 -1
  114. data/lib/rubygems/commands/contents_command.rb +2 -2
  115. data/lib/rubygems/commands/environment_command.rb +2 -2
  116. data/lib/rubygems/commands/help_command.rb +3 -3
  117. data/lib/rubygems/commands/open_command.rb +1 -3
  118. data/lib/rubygems/commands/owner_command.rb +1 -1
  119. data/lib/rubygems/commands/setup_command.rb +10 -10
  120. data/lib/rubygems/commands/specification_command.rb +5 -1
  121. data/lib/rubygems/commands/stale_command.rb +1 -1
  122. data/lib/rubygems/commands/uninstall_command.rb +4 -4
  123. data/lib/rubygems/commands/unpack_command.rb +3 -3
  124. data/lib/rubygems/commands/update_command.rb +4 -4
  125. data/lib/rubygems/commands/yank_command.rb +1 -1
  126. data/lib/rubygems/config_file.rb +63 -16
  127. data/lib/rubygems/core_ext/kernel_gem.rb +1 -1
  128. data/lib/rubygems/core_ext/kernel_require.rb +2 -2
  129. data/lib/rubygems/defaults.rb +6 -2
  130. data/lib/rubygems/dependency_installer.rb +4 -4
  131. data/lib/rubygems/deprecate.rb +2 -1
  132. data/lib/rubygems/doctor.rb +2 -2
  133. data/lib/rubygems/errors.rb +1 -1
  134. data/lib/rubygems/exceptions.rb +1 -1
  135. data/lib/rubygems/ext/builder.rb +5 -4
  136. data/lib/rubygems/ext/cargo_builder.rb +2 -2
  137. data/lib/rubygems/ext/ext_conf_builder.rb +1 -1
  138. data/lib/rubygems/ext/rake_builder.rb +1 -1
  139. data/lib/rubygems/gem_runner.rb +5 -1
  140. data/lib/rubygems/gemcutter_utilities.rb +2 -2
  141. data/lib/rubygems/indexer.rb +1 -1
  142. data/lib/rubygems/install_update_options.rb +1 -1
  143. data/lib/rubygems/installer.rb +15 -20
  144. data/lib/rubygems/local_remote_options.rb +1 -1
  145. data/lib/rubygems/package/digest_io.rb +1 -1
  146. data/lib/rubygems/package/old.rb +1 -1
  147. data/lib/rubygems/package/tar_header.rb +2 -2
  148. data/lib/rubygems/package/tar_reader.rb +9 -2
  149. data/lib/rubygems/package/tar_writer.rb +2 -2
  150. data/lib/rubygems/package.rb +9 -9
  151. data/lib/rubygems/path_support.rb +1 -1
  152. data/lib/rubygems/platform.rb +12 -6
  153. data/lib/rubygems/query_utils.rb +4 -4
  154. data/lib/rubygems/remote_fetcher.rb +12 -4
  155. data/lib/rubygems/request.rb +1 -1
  156. data/lib/rubygems/request_set/gem_dependency_api.rb +1 -1
  157. data/lib/rubygems/request_set.rb +2 -1
  158. data/lib/rubygems/requirement.rb +1 -1
  159. data/lib/rubygems/resolver/api_set.rb +2 -1
  160. data/lib/rubygems/resolver/api_specification.rb +1 -1
  161. data/lib/rubygems/resolver.rb +3 -3
  162. data/lib/rubygems/security/signer.rb +10 -2
  163. data/lib/rubygems/security/trust_dir.rb +5 -5
  164. data/lib/rubygems/security.rb +1 -1
  165. data/lib/rubygems/security_option.rb +1 -1
  166. data/lib/rubygems/source/local.rb +2 -1
  167. data/lib/rubygems/source.rb +5 -1
  168. data/lib/rubygems/source_list.rb +1 -1
  169. data/lib/rubygems/spec_fetcher.rb +2 -2
  170. data/lib/rubygems/specification.rb +30 -23
  171. data/lib/rubygems/specification_policy.rb +11 -11
  172. data/lib/rubygems/uninstaller.rb +3 -3
  173. data/lib/rubygems/update_suggestion.rb +1 -1
  174. data/lib/rubygems/user_interaction.rb +2 -2
  175. data/lib/rubygems/util/licenses.rb +48 -0
  176. data/lib/rubygems/util.rb +5 -1
  177. data/lib/rubygems/validator.rb +1 -1
  178. data/lib/rubygems/version.rb +6 -5
  179. data/lib/rubygems/yaml_serializer.rb +93 -0
  180. data/lib/rubygems.rb +9 -9
  181. data/rubygems-update.gemspec +1 -1
  182. data/setup.rb +2 -0
  183. data/test/rubygems/bundler_test_gem.rb +6 -3
  184. data/test/rubygems/helper.rb +29 -21
  185. data/test/rubygems/package/tar_test_case.rb +2 -2
  186. data/test/rubygems/test_gem.rb +51 -26
  187. data/test/rubygems/test_gem_command.rb +3 -1
  188. data/test/rubygems/test_gem_command_manager.rb +6 -6
  189. data/test/rubygems/test_gem_commands_cert_command.rb +23 -23
  190. data/test/rubygems/test_gem_commands_cleanup_command.rb +2 -2
  191. data/test/rubygems/test_gem_commands_environment_command.rb +2 -1
  192. data/test/rubygems/test_gem_commands_exec_command.rb +5 -1
  193. data/test/rubygems/test_gem_commands_install_command.rb +5 -5
  194. data/test/rubygems/test_gem_commands_open_command.rb +5 -2
  195. data/test/rubygems/test_gem_commands_pristine_command.rb +2 -2
  196. data/test/rubygems/test_gem_commands_push_command.rb +7 -6
  197. data/test/rubygems/test_gem_commands_signin_command.rb +8 -8
  198. data/test/rubygems/test_gem_commands_uninstall_command.rb +21 -1
  199. data/test/rubygems/test_gem_commands_unpack_command.rb +2 -2
  200. data/test/rubygems/test_gem_config_file.rb +46 -12
  201. data/test/rubygems/test_gem_ext_builder.rb +1 -1
  202. data/test/rubygems/test_gem_ext_cargo_builder.rb +2 -2
  203. data/test/rubygems/test_gem_gemcutter_utilities.rb +8 -5
  204. data/test/rubygems/test_gem_install_update_options.rb +3 -3
  205. data/test/rubygems/test_gem_installer.rb +16 -16
  206. data/test/rubygems/test_gem_package.rb +35 -34
  207. data/test/rubygems/test_gem_package_old.rb +1 -1
  208. data/test/rubygems/test_gem_package_tar_header.rb +3 -3
  209. data/test/rubygems/test_gem_package_tar_reader.rb +19 -4
  210. data/test/rubygems/test_gem_package_tar_writer.rb +28 -28
  211. data/test/rubygems/test_gem_rdoc.rb +2 -2
  212. data/test/rubygems/test_gem_remote_fetcher.rb +13 -9
  213. data/test/rubygems/test_gem_request.rb +5 -5
  214. data/test/rubygems/test_gem_request_connection_pools.rb +2 -1
  215. data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +14 -7
  216. data/test/rubygems/test_gem_security.rb +2 -2
  217. data/test/rubygems/test_gem_security_policy.rb +2 -2
  218. data/test/rubygems/test_gem_security_signer.rb +2 -2
  219. data/test/rubygems/test_gem_security_trust_dir.rb +6 -6
  220. data/test/rubygems/test_gem_spec_fetcher.rb +2 -2
  221. data/test/rubygems/test_gem_specification.rb +29 -29
  222. data/test/rubygems/test_gem_stream_ui.rb +1 -1
  223. data/test/rubygems/test_gem_update_suggestion.rb +12 -6
  224. data/test/rubygems/test_gem_util.rb +2 -2
  225. data/test/rubygems/test_gem_version.rb +4 -2
  226. data/test/rubygems/utilities.rb +4 -3
  227. metadata +9 -3
@@ -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
  ##
@@ -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
 
@@ -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
@@ -90,7 +92,10 @@ class Gem::Platform
90
92
  end
91
93
 
92
94
  os, = arch
93
- @cpu, os = nil, cpu if os.nil? # legacy jruby
95
+ if os.nil?
96
+ @cpu = nil
97
+ os = cpu
98
+ end # legacy jruby
94
99
 
95
100
  @os, @version = case os
96
101
  when /aix(\d+)?/ then [ "aix", $1 ]
@@ -107,7 +112,8 @@ class Gem::Platform
107
112
  when /mingw32/ then [ "mingw32", nil ]
108
113
  when /mingw-?(\w+)?/ then [ "mingw", $1 ]
109
114
  when /(mswin\d+)(\_(\d+))?/ then
110
- os, version = $1, $3
115
+ os = $1
116
+ version = $3
111
117
  @cpu = "x86" if @cpu.nil? && os =~ /32$/
112
118
  [os, version]
113
119
  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,14 +125,18 @@ 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
 
132
136
  scheme = source_uri.scheme
133
137
 
134
138
  # URI.parse gets confused by MS Windows paths with forward slashes.
135
- scheme = nil if scheme =~ /^[a-z]$/i
139
+ scheme = nil if /^[a-z]$/i.match?(scheme)
136
140
 
137
141
  # REFACTOR: split this up and dispatch on scheme (eg download_http)
138
142
  # REFACTOR: be sure to clean up fake fetcher when you do this... cleaner
@@ -170,7 +174,7 @@ class Gem::RemoteFetcher
170
174
  end
171
175
 
172
176
  verbose "Using local gem #{local_gem_path}"
173
- when nil then # TODO test for local overriding cache
177
+ when nil then # TODO: test for local overriding cache
174
178
  source_path = if Gem.win_platform? && source_uri.scheme &&
175
179
  !source_uri.path.include?(":")
176
180
  "#{source_uri.scheme}:#{source_uri.path}"
@@ -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
 
@@ -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
  ##
@@ -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)
@@ -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
@@ -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
  ##
@@ -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
 
@@ -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
@@ -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
@@ -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
 
@@ -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
  ##
@@ -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
 
@@ -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
@@ -1538,8 +1546,8 @@ class Gem::Specification < Gem::BasicSpecification
1538
1546
  else
1539
1547
  executables
1540
1548
  end
1541
- rescue
1542
- return nil
1549
+ rescue StandardError
1550
+ nil
1543
1551
  end
1544
1552
 
1545
1553
  ##
@@ -2362,13 +2370,13 @@ class Gem::Specification < Gem::BasicSpecification
2362
2370
  when Array then "[" + obj.map {|x| ruby_code x }.join(", ") + "]"
2363
2371
  when Hash then
2364
2372
  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
2373
+ "{ #{seg.join(", ")} }"
2374
+ when Gem::Version then ruby_code(obj.to_s)
2367
2375
  when DateLike then obj.strftime("%Y-%m-%d").dump
2368
2376
  when Time then obj.strftime("%Y-%m-%d").dump
2369
2377
  when Numeric then obj.inspect
2370
2378
  when true, false, nil then obj.inspect
2371
- when Gem::Platform then "Gem::Platform.new(#{obj.to_a.inspect})"
2379
+ when Gem::Platform then "Gem::Platform.new(#{ruby_code obj.to_a})"
2372
2380
  when Gem::Requirement then
2373
2381
  list = obj.as_list
2374
2382
  "Gem::Requirement.new(#{ruby_code(list.size == 1 ? obj.to_s : list)})"
@@ -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
  ##
@@ -2533,12 +2541,12 @@ class Gem::Specification < Gem::BasicSpecification
2533
2541
  end
2534
2542
 
2535
2543
  if String === signing_key
2536
- result << " s.signing_key = #{signing_key.dump}.freeze"
2544
+ result << " s.signing_key = #{ruby_code signing_key}"
2537
2545
  end
2538
2546
 
2539
2547
  if @installed_by_version
2540
2548
  result << nil
2541
- result << " s.installed_by_version = \"#{Gem::VERSION}\" if s.respond_to? :installed_by_version"
2549
+ result << " s.installed_by_version = #{ruby_code Gem::VERSION} if s.respond_to? :installed_by_version"
2542
2550
  end
2543
2551
 
2544
2552
  unless dependencies.empty?
@@ -2547,9 +2555,8 @@ class Gem::Specification < Gem::BasicSpecification
2547
2555
  result << nil
2548
2556
 
2549
2557
  dependencies.each do |dep|
2550
- req = dep.requirements_list.inspect
2551
2558
  dep.instance_variable_set :@type, :runtime if dep.type.nil? # HACK
2552
- result << " s.add_#{dep.type}_dependency(%q<#{dep.name}>.freeze, #{req})"
2559
+ result << " s.add_#{dep.type}_dependency(%q<#{dep.name}>.freeze, #{ruby_code dep.requirements_list})"
2553
2560
  end
2554
2561
  end
2555
2562
 
@@ -2686,7 +2693,7 @@ class Gem::Specification < Gem::BasicSpecification
2686
2693
  end
2687
2694
  invalidate_memoized_attributes
2688
2695
 
2689
- return @version
2696
+ @version
2690
2697
  end
2691
2698
 
2692
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
@@ -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
@@ -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
@@ -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
 
@@ -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