rubygems-update 3.1.6 → 3.2.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (347) hide show
  1. checksums.yaml +4 -4
  2. data/CODE_OF_CONDUCT.md +55 -19
  3. data/CONTRIBUTING.md +1 -2
  4. data/History.txt +122 -14
  5. data/Manifest.txt +13 -25
  6. data/POLICIES.md +2 -9
  7. data/README.md +1 -1
  8. data/Rakefile +31 -33
  9. data/bin/update_rubygems +1 -1
  10. data/bundler/CHANGELOG.md +806 -741
  11. data/bundler/README.md +6 -8
  12. data/bundler/UPGRADING.md +16 -30
  13. data/bundler/bundler.gemspec +3 -3
  14. data/bundler/exe/bundle +3 -0
  15. data/bundler/lib/bundler.rb +15 -4
  16. data/bundler/lib/bundler/build_metadata.rb +2 -2
  17. data/bundler/lib/bundler/cli.rb +32 -11
  18. data/bundler/lib/bundler/cli/console.rb +1 -1
  19. data/bundler/lib/bundler/cli/gem.rb +83 -10
  20. data/bundler/lib/bundler/cli/info.rb +13 -3
  21. data/bundler/lib/bundler/cli/init.rb +1 -1
  22. data/bundler/lib/bundler/cli/install.rb +5 -14
  23. data/bundler/lib/bundler/cli/issue.rb +2 -2
  24. data/bundler/lib/bundler/cli/list.rb +11 -9
  25. data/bundler/lib/bundler/cli/outdated.rb +88 -65
  26. data/bundler/lib/bundler/cli/plugin.rb +10 -0
  27. data/bundler/lib/bundler/cli/pristine.rb +5 -0
  28. data/bundler/lib/bundler/definition.rb +32 -32
  29. data/bundler/lib/bundler/dependency.rb +0 -9
  30. data/bundler/lib/bundler/dsl.rb +1 -5
  31. data/bundler/lib/bundler/environment_preserver.rb +26 -2
  32. data/bundler/lib/bundler/errors.rb +1 -0
  33. data/bundler/lib/bundler/feature_flag.rb +0 -2
  34. data/bundler/lib/bundler/fetcher.rb +1 -0
  35. data/bundler/lib/bundler/friendly_errors.rb +4 -10
  36. data/bundler/lib/bundler/gem_helper.rb +17 -10
  37. data/bundler/lib/bundler/gem_version_promoter.rb +1 -1
  38. data/bundler/lib/bundler/injector.rb +14 -3
  39. data/bundler/lib/bundler/inline.rb +1 -1
  40. data/bundler/lib/bundler/installer.rb +29 -28
  41. data/bundler/lib/bundler/installer/gem_installer.rb +2 -2
  42. data/bundler/lib/bundler/installer/parallel_installer.rb +9 -9
  43. data/bundler/lib/bundler/lazy_specification.rb +16 -3
  44. data/bundler/lib/bundler/plugin.rb +26 -0
  45. data/bundler/lib/bundler/plugin/index.rb +9 -0
  46. data/bundler/lib/bundler/psyched_yaml.rb +0 -15
  47. data/bundler/lib/bundler/remote_specification.rb +4 -1
  48. data/bundler/lib/bundler/resolver.rb +31 -8
  49. data/bundler/lib/bundler/resolver/spec_group.rb +26 -5
  50. data/bundler/lib/bundler/rubygems_ext.rb +7 -8
  51. data/bundler/lib/bundler/rubygems_gem_installer.rb +1 -7
  52. data/bundler/lib/bundler/rubygems_integration.rb +3 -48
  53. data/bundler/lib/bundler/runtime.rb +2 -12
  54. data/bundler/lib/bundler/settings.rb +0 -3
  55. data/bundler/lib/bundler/shared_helpers.rb +1 -1
  56. data/bundler/lib/bundler/source/git.rb +4 -4
  57. data/bundler/lib/bundler/source/git/git_proxy.rb +53 -58
  58. data/bundler/lib/bundler/source/path.rb +5 -1
  59. data/bundler/lib/bundler/source/path/installer.rb +7 -9
  60. data/bundler/lib/bundler/source/rubygems.rb +11 -14
  61. data/bundler/lib/bundler/stub_specification.rb +16 -4
  62. data/bundler/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +57 -47
  63. data/bundler/lib/bundler/templates/newgem/Gemfile.tt +9 -1
  64. data/bundler/lib/bundler/templates/newgem/Rakefile.tt +19 -5
  65. data/bundler/lib/bundler/templates/newgem/bin/console.tt +2 -0
  66. data/bundler/lib/bundler/templates/newgem/circleci/config.yml.tt +13 -0
  67. data/bundler/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +2 -0
  68. data/bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt +18 -0
  69. data/bundler/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
  70. data/bundler/lib/bundler/templates/newgem/lib/newgem.rb.tt +2 -0
  71. data/bundler/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +2 -0
  72. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +6 -4
  73. data/bundler/lib/bundler/templates/newgem/rubocop.yml.tt +10 -0
  74. data/bundler/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +2 -0
  75. data/bundler/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -0
  76. data/bundler/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/newgem_test.rb.tt} +2 -0
  77. data/bundler/lib/bundler/templates/newgem/test/{test_helper.rb.tt → minitest/test_helper.rb.tt} +2 -0
  78. data/bundler/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
  79. data/bundler/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
  80. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +75 -189
  81. data/bundler/lib/bundler/vendor/thor/lib/thor.rb +0 -7
  82. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +2 -1
  83. data/bundler/lib/bundler/vendor/thor/lib/thor/base.rb +9 -0
  84. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  85. data/bundler/lib/bundler/version.rb +1 -1
  86. data/bundler/man/bundle-add.1 +1 -1
  87. data/bundler/man/bundle-add.1.txt +15 -15
  88. data/bundler/man/bundle-binstubs.1 +1 -1
  89. data/bundler/man/bundle-binstubs.1.txt +10 -10
  90. data/bundler/man/bundle-cache.1 +1 -1
  91. data/bundler/man/bundle-cache.1.txt +15 -15
  92. data/bundler/man/bundle-check.1 +1 -1
  93. data/bundler/man/bundle-check.1.txt +8 -8
  94. data/bundler/man/bundle-clean.1 +1 -1
  95. data/bundler/man/bundle-clean.1.txt +6 -6
  96. data/bundler/man/bundle-config.1 +3 -9
  97. data/bundler/man/bundle-config.1.txt +271 -272
  98. data/bundler/man/bundle-config.ronn +5 -9
  99. data/bundler/man/bundle-doctor.1 +1 -1
  100. data/bundler/man/bundle-doctor.1.txt +9 -9
  101. data/bundler/man/bundle-exec.1 +1 -1
  102. data/bundler/man/bundle-exec.1.txt +84 -81
  103. data/bundler/man/bundle-gem.1 +25 -3
  104. data/bundler/man/bundle-gem.1.txt +65 -39
  105. data/bundler/man/bundle-gem.ronn +30 -7
  106. data/bundler/man/bundle-info.1 +1 -1
  107. data/bundler/man/bundle-info.1.txt +2 -2
  108. data/bundler/man/bundle-init.1 +1 -1
  109. data/bundler/man/bundle-init.1.txt +9 -9
  110. data/bundler/man/bundle-inject.1 +1 -1
  111. data/bundler/man/bundle-inject.1.txt +4 -4
  112. data/bundler/man/bundle-install.1 +1 -1
  113. data/bundler/man/bundle-install.1.txt +169 -169
  114. data/bundler/man/bundle-list.1 +7 -7
  115. data/bundler/man/bundle-list.1.txt +12 -11
  116. data/bundler/man/bundle-list.ronn +6 -6
  117. data/bundler/man/bundle-lock.1 +1 -1
  118. data/bundler/man/bundle-lock.1.txt +28 -28
  119. data/bundler/man/bundle-open.1 +1 -1
  120. data/bundler/man/bundle-open.1.txt +3 -3
  121. data/bundler/man/bundle-outdated.1 +1 -1
  122. data/bundler/man/bundle-outdated.1.txt +34 -34
  123. data/bundler/man/bundle-platform.1 +1 -1
  124. data/bundler/man/bundle-platform.1.txt +16 -16
  125. data/bundler/man/bundle-pristine.1 +1 -1
  126. data/bundler/man/bundle-pristine.1.txt +8 -8
  127. data/bundler/man/bundle-remove.1 +1 -1
  128. data/bundler/man/bundle-remove.1.txt +9 -9
  129. data/bundler/man/bundle-show.1 +1 -1
  130. data/bundler/man/bundle-show.1.txt +8 -8
  131. data/bundler/man/bundle-update.1 +1 -1
  132. data/bundler/man/bundle-update.1.txt +149 -148
  133. data/bundler/man/bundle-viz.1 +1 -1
  134. data/bundler/man/bundle-viz.1.txt +11 -11
  135. data/bundler/man/bundle.1 +1 -1
  136. data/bundler/man/bundle.1.txt +31 -31
  137. data/bundler/man/gemfile.5 +1 -1
  138. data/bundler/man/gemfile.5.txt +218 -216
  139. data/lib/rubygems.rb +68 -148
  140. data/lib/rubygems/available_set.rb +4 -4
  141. data/lib/rubygems/basic_specification.rb +11 -5
  142. data/lib/rubygems/bundler_version_finder.rb +14 -9
  143. data/lib/rubygems/command.rb +16 -14
  144. data/lib/rubygems/command_manager.rb +4 -3
  145. data/lib/rubygems/commands/cert_command.rb +1 -1
  146. data/lib/rubygems/commands/cleanup_command.rb +3 -3
  147. data/lib/rubygems/commands/contents_command.rb +4 -4
  148. data/lib/rubygems/commands/dependency_command.rb +6 -6
  149. data/lib/rubygems/commands/fetch_command.rb +2 -2
  150. data/lib/rubygems/commands/help_command.rb +1 -1
  151. data/lib/rubygems/commands/info_command.rb +9 -4
  152. data/lib/rubygems/commands/install_command.rb +3 -3
  153. data/lib/rubygems/commands/list_command.rb +9 -6
  154. data/lib/rubygems/commands/lock_command.rb +1 -1
  155. data/lib/rubygems/commands/open_command.rb +0 -2
  156. data/lib/rubygems/commands/pristine_command.rb +10 -2
  157. data/lib/rubygems/commands/push_command.rb +4 -42
  158. data/lib/rubygems/commands/query_command.rb +7 -352
  159. data/lib/rubygems/commands/search_command.rb +8 -6
  160. data/lib/rubygems/commands/setup_command.rb +128 -32
  161. data/lib/rubygems/commands/specification_command.rb +2 -2
  162. data/lib/rubygems/commands/stale_command.rb +1 -1
  163. data/lib/rubygems/commands/uninstall_command.rb +1 -1
  164. data/lib/rubygems/commands/unpack_command.rb +1 -1
  165. data/lib/rubygems/commands/update_command.rb +40 -10
  166. data/lib/rubygems/config_file.rb +11 -2
  167. data/lib/rubygems/core_ext/kernel_require.rb +2 -2
  168. data/lib/rubygems/defaults.rb +99 -5
  169. data/lib/rubygems/dependency.rb +2 -5
  170. data/lib/rubygems/dependency_installer.rb +1 -73
  171. data/lib/rubygems/dependency_list.rb +7 -7
  172. data/lib/rubygems/deprecate.rb +46 -1
  173. data/lib/rubygems/doctor.rb +4 -2
  174. data/lib/rubygems/errors.rb +3 -2
  175. data/lib/rubygems/exceptions.rb +2 -13
  176. data/lib/rubygems/ext.rb +6 -6
  177. data/lib/rubygems/ext/build_error.rb +2 -0
  178. data/lib/rubygems/ext/builder.rb +1 -1
  179. data/lib/rubygems/ext/cmake_builder.rb +1 -1
  180. data/lib/rubygems/ext/ext_conf_builder.rb +6 -7
  181. data/lib/rubygems/gem_runner.rb +3 -8
  182. data/lib/rubygems/gemcutter_utilities.rb +1 -1
  183. data/lib/rubygems/indexer.rb +1 -19
  184. data/lib/rubygems/install_update_options.rb +5 -5
  185. data/lib/rubygems/installer.rb +45 -42
  186. data/lib/rubygems/installer_test_case.rb +19 -2
  187. data/lib/rubygems/installer_uninstaller_utils.rb +24 -0
  188. data/lib/rubygems/local_remote_options.rb +1 -1
  189. data/lib/rubygems/name_tuple.rb +2 -4
  190. data/lib/rubygems/package.rb +8 -13
  191. data/lib/rubygems/package/old.rb +1 -1
  192. data/lib/rubygems/package/tar_header.rb +3 -3
  193. data/lib/rubygems/package/tar_reader.rb +0 -1
  194. data/lib/rubygems/package/tar_reader/entry.rb +0 -1
  195. data/lib/rubygems/package/tar_test_case.rb +1 -1
  196. data/lib/rubygems/package/tar_writer.rb +2 -6
  197. data/lib/rubygems/package_task.rb +1 -5
  198. data/lib/rubygems/path_support.rb +1 -1
  199. data/lib/rubygems/platform.rb +3 -3
  200. data/lib/rubygems/query_utils.rb +362 -0
  201. data/lib/rubygems/rdoc.rb +0 -12
  202. data/lib/rubygems/remote_fetcher.rb +5 -19
  203. data/lib/rubygems/request/connection_pools.rb +1 -1
  204. data/lib/rubygems/request_set.rb +5 -5
  205. data/lib/rubygems/request_set/gem_dependency_api.rb +1 -1
  206. data/lib/rubygems/request_set/lockfile.rb +8 -8
  207. data/lib/rubygems/request_set/lockfile/tokenizer.rb +1 -1
  208. data/lib/rubygems/requirement.rb +14 -15
  209. data/lib/rubygems/resolver.rb +7 -8
  210. data/lib/rubygems/resolver/api_set.rb +3 -3
  211. data/lib/rubygems/resolver/composed_set.rb +3 -3
  212. data/lib/rubygems/resolver/conflict.rb +1 -1
  213. data/lib/rubygems/resolver/index_set.rb +1 -1
  214. data/lib/rubygems/resolver/installer_set.rb +3 -3
  215. data/lib/rubygems/resolver/lock_set.rb +1 -1
  216. data/lib/rubygems/safe_yaml.rb +4 -4
  217. data/lib/rubygems/security.rb +25 -25
  218. data/lib/rubygems/security/policy.rb +3 -3
  219. data/lib/rubygems/security/signer.rb +4 -4
  220. data/lib/rubygems/security/trust_dir.rb +1 -1
  221. data/lib/rubygems/server.rb +8 -8
  222. data/lib/rubygems/source/git.rb +7 -6
  223. data/lib/rubygems/source/local.rb +2 -2
  224. data/lib/rubygems/source_list.rb +4 -5
  225. data/lib/rubygems/spec_fetcher.rb +18 -15
  226. data/lib/rubygems/specification.rb +79 -104
  227. data/lib/rubygems/specification_policy.rb +79 -27
  228. data/lib/rubygems/ssl_certs/{rubygems.org → index.rubygems.org}/GlobalSignRootCA.pem +0 -0
  229. data/lib/rubygems/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +23 -0
  230. data/lib/rubygems/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +25 -0
  231. data/lib/rubygems/test_case.rb +63 -83
  232. data/lib/rubygems/test_utilities.rb +6 -6
  233. data/lib/rubygems/uninstaller.rb +35 -14
  234. data/lib/rubygems/user_interaction.rb +1 -10
  235. data/lib/rubygems/util.rb +10 -2
  236. data/lib/rubygems/util/licenses.rb +4 -4
  237. data/lib/rubygems/validator.rb +1 -1
  238. data/lib/rubygems/version.rb +4 -4
  239. data/rubygems-update.gemspec +2 -2
  240. data/setup.rb +2 -7
  241. data/test/rubygems/specifications/bar-0.0.2.gemspec +0 -2
  242. data/test/rubygems/specifications/rubyforge-0.0.1.gemspec +0 -2
  243. data/test/rubygems/test_bundled_ca.rb +4 -12
  244. data/test/rubygems/test_deprecate.rb +43 -4
  245. data/test/rubygems/test_gem.rb +79 -74
  246. data/test/rubygems/test_gem_available_set.rb +3 -3
  247. data/test/rubygems/test_gem_bundler_version_finder.rb +19 -1
  248. data/test/rubygems/test_gem_command.rb +24 -3
  249. data/test/rubygems/test_gem_command_manager.rb +37 -4
  250. data/test/rubygems/test_gem_commands_build_command.rb +7 -2
  251. data/test/rubygems/test_gem_commands_cert_command.rb +2 -2
  252. data/test/rubygems/test_gem_commands_cleanup_command.rb +1 -1
  253. data/test/rubygems/test_gem_commands_contents_command.rb +48 -15
  254. data/test/rubygems/test_gem_commands_environment_command.rb +21 -21
  255. data/test/rubygems/test_gem_commands_generate_index_command.rb +1 -5
  256. data/test/rubygems/test_gem_commands_info_command.rb +6 -6
  257. data/test/rubygems/test_gem_commands_install_command.rb +31 -31
  258. data/test/rubygems/test_gem_commands_mirror.rb +1 -1
  259. data/test/rubygems/test_gem_commands_open_command.rb +4 -4
  260. data/test/rubygems/test_gem_commands_owner_command.rb +11 -3
  261. data/test/rubygems/test_gem_commands_pristine_command.rb +41 -8
  262. data/test/rubygems/test_gem_commands_push_command.rb +7 -2
  263. data/test/rubygems/test_gem_commands_query_command.rb +9 -5
  264. data/test/rubygems/test_gem_commands_setup_command.rb +160 -108
  265. data/test/rubygems/test_gem_commands_signin_command.rb +6 -4
  266. data/test/rubygems/test_gem_commands_signout_command.rb +0 -5
  267. data/test/rubygems/test_gem_commands_specification_command.rb +18 -18
  268. data/test/rubygems/test_gem_commands_uninstall_command.rb +1 -1
  269. data/test/rubygems/test_gem_commands_update_command.rb +68 -5
  270. data/test/rubygems/test_gem_commands_which_command.rb +3 -3
  271. data/test/rubygems/test_gem_commands_yank_command.rb +14 -6
  272. data/test/rubygems/test_gem_config_file.rb +7 -10
  273. data/test/rubygems/test_gem_dependency_installer.rb +52 -189
  274. data/test/rubygems/test_gem_dependency_list.rb +8 -8
  275. data/test/rubygems/test_gem_dependency_resolution_error.rb +1 -1
  276. data/test/rubygems/test_gem_doctor.rb +28 -0
  277. data/test/rubygems/test_gem_ext_builder.rb +14 -25
  278. data/test/rubygems/test_gem_ext_cmake_builder.rb +13 -12
  279. data/test/rubygems/test_gem_ext_configure_builder.rb +1 -9
  280. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +0 -1
  281. data/test/rubygems/test_gem_ext_rake_builder.rb +9 -9
  282. data/test/rubygems/test_gem_gem_runner.rb +42 -0
  283. data/test/rubygems/test_gem_gemcutter_utilities.rb +5 -0
  284. data/test/rubygems/test_gem_indexer.rb +9 -13
  285. data/test/rubygems/test_gem_installer.rb +149 -45
  286. data/test/rubygems/test_gem_package.rb +13 -12
  287. data/test/rubygems/test_gem_package_tar_header.rb +19 -0
  288. data/test/rubygems/test_gem_package_tar_writer.rb +3 -3
  289. data/test/rubygems/test_gem_package_task.rb +46 -11
  290. data/test/rubygems/test_gem_remote_fetcher.rb +152 -190
  291. data/test/rubygems/test_gem_request.rb +11 -11
  292. data/test/rubygems/test_gem_request_set.rb +20 -20
  293. data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +3 -3
  294. data/test/rubygems/test_gem_request_set_lockfile_parser.rb +9 -9
  295. data/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb +118 -118
  296. data/test/rubygems/test_gem_requirement.rb +2 -2
  297. data/test/rubygems/test_gem_resolver.rb +6 -6
  298. data/test/rubygems/test_gem_resolver_api_set.rb +3 -3
  299. data/test/rubygems/test_gem_resolver_best_set.rb +2 -2
  300. data/test/rubygems/test_gem_resolver_index_set.rb +2 -2
  301. data/test/rubygems/test_gem_resolver_installer_set.rb +7 -7
  302. data/test/rubygems/test_gem_resolver_lock_set.rb +3 -3
  303. data/test/rubygems/test_gem_security.rb +20 -20
  304. data/test/rubygems/test_gem_security_policy.rb +5 -8
  305. data/test/rubygems/test_gem_security_signer.rb +8 -8
  306. data/test/rubygems/test_gem_security_trust_dir.rb +2 -2
  307. data/test/rubygems/test_gem_server.rb +10 -10
  308. data/test/rubygems/test_gem_source.rb +12 -14
  309. data/test/rubygems/test_gem_source_git.rb +12 -11
  310. data/test/rubygems/test_gem_source_installed.rb +7 -7
  311. data/test/rubygems/test_gem_source_local.rb +8 -8
  312. data/test/rubygems/test_gem_source_lock.rb +10 -10
  313. data/test/rubygems/test_gem_source_specific_file.rb +7 -7
  314. data/test/rubygems/test_gem_source_vendor.rb +7 -7
  315. data/test/rubygems/test_gem_spec_fetcher.rb +11 -2
  316. data/test/rubygems/test_gem_specification.rb +143 -113
  317. data/test/rubygems/test_gem_stream_ui.rb +3 -1
  318. data/test/rubygems/test_gem_text.rb +1 -1
  319. data/test/rubygems/test_gem_uninstaller.rb +134 -10
  320. data/test/rubygems/test_gem_util.rb +7 -5
  321. data/test/rubygems/test_gem_version.rb +1 -1
  322. data/test/rubygems/test_kernel.rb +10 -12
  323. data/test/rubygems/test_project_sanity.rb +8 -1
  324. data/test/rubygems/test_require.rb +141 -43
  325. metadata +32 -45
  326. data/.bundle/config +0 -2
  327. data/.rubocop.yml +0 -91
  328. data/Gemfile +0 -8
  329. data/Gemfile.lock +0 -43
  330. data/bundler/CODE_OF_CONDUCT.md +0 -136
  331. data/lib/rubygems/source_local.rb +0 -7
  332. data/lib/rubygems/source_specific_file.rb +0 -6
  333. data/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA_R3.pem +0 -21
  334. data/lib/ubygems.rb +0 -14
  335. data/tmp/.keep +0 -0
  336. data/util/CL2notes +0 -55
  337. data/util/bisect +0 -10
  338. data/util/ci.sh +0 -62
  339. data/util/cops/deprecations.rb +0 -52
  340. data/util/create_certs.rb +0 -171
  341. data/util/create_certs.sh +0 -27
  342. data/util/create_encrypted_key.rb +0 -16
  343. data/util/generate_spdx_license_list.rb +0 -63
  344. data/util/patch_with_prs.rb +0 -77
  345. data/util/rubocop +0 -8
  346. data/util/update_bundled_ca_certificates.rb +0 -137
  347. data/util/update_changelog.rb +0 -64
@@ -75,7 +75,7 @@ class Gem::Resolver::LockSet < Gem::Resolver::Set
75
75
  q.text 'specs:'
76
76
 
77
77
  q.breakable
78
- q.pp @specs.map { |spec| spec.full_name }
78
+ q.pp @specs.map {|spec| spec.full_name }
79
79
  end
80
80
  end
81
81
 
@@ -7,7 +7,7 @@ module Gem
7
7
  # Psych.safe_load
8
8
 
9
9
  module SafeYAML
10
- PERMITTED_CLASSES = %w(
10
+ PERMITTED_CLASSES = %w[
11
11
  Symbol
12
12
  Time
13
13
  Date
@@ -19,12 +19,12 @@ module Gem
19
19
  Gem::Version::Requirement
20
20
  YAML::Syck::DefaultKey
21
21
  Syck::DefaultKey
22
- ).freeze
22
+ ].freeze
23
23
 
24
- PERMITTED_SYMBOLS = %w(
24
+ PERMITTED_SYMBOLS = %w[
25
25
  development
26
26
  runtime
27
- ).freeze
27
+ ].freeze
28
28
 
29
29
  if ::YAML.respond_to? :safe_load
30
30
  def self.safe_load(input)
@@ -62,11 +62,11 @@ end
62
62
  #
63
63
  # $ tar tf your-gem-1.0.gem
64
64
  # metadata.gz
65
- # metadata.gz.sum
66
65
  # metadata.gz.sig # metadata signature
67
66
  # data.tar.gz
68
- # data.tar.gz.sum
69
67
  # data.tar.gz.sig # data signature
68
+ # checksums.yaml.gz
69
+ # checksums.yaml.gz.sig # checksums signature
70
70
  #
71
71
  # === Manually signing gems
72
72
  #
@@ -161,6 +161,8 @@ end
161
161
  # -K, --private-key KEY Key for --sign or --build
162
162
  # -s, --sign CERT Signs CERT with the key from -K
163
163
  # and the certificate from -C
164
+ # -d, --days NUMBER_OF_DAYS Days before the certificate expires
165
+ # -R, --re-sign Re-signs the certificate from -C with the key from -K
164
166
  #
165
167
  # We've already covered the <code>--build</code> option, and the
166
168
  # <code>--add</code>, <code>--list</code>, and <code>--remove</code> commands
@@ -265,7 +267,7 @@ end
265
267
  # 2. Grab the public key from the gemspec
266
268
  #
267
269
  # gem spec some_signed_gem-1.0.gem cert_chain | \
268
- # ruby -ryaml -e 'puts YAML.load_documents($stdin)' > public_key.crt
270
+ # ruby -ryaml -e 'puts YAML.load($stdin)' > public_key.crt
269
271
  #
270
272
  # 3. Generate a SHA1 hash of the data.tar.gz
271
273
  #
@@ -336,28 +338,10 @@ module Gem::Security
336
338
 
337
339
  class Exception < Gem::Exception; end
338
340
 
339
- ##
340
- # Digest algorithm used to sign gems
341
-
342
- DIGEST_ALGORITHM =
343
- if defined?(OpenSSL::Digest::SHA256)
344
- OpenSSL::Digest::SHA256
345
- elsif defined?(OpenSSL::Digest::SHA1)
346
- OpenSSL::Digest::SHA1
347
- else
348
- require 'digest'
349
- Digest::SHA512
350
- end
351
-
352
341
  ##
353
342
  # Used internally to select the signing digest from all computed digests
354
343
 
355
- DIGEST_NAME = # :nodoc:
356
- if DIGEST_ALGORITHM.method_defined? :name
357
- DIGEST_ALGORITHM.new.name
358
- else
359
- DIGEST_ALGORITHM.name[/::([^:]+)\z/, 1]
360
- end
344
+ DIGEST_NAME = 'SHA256' # :nodoc:
361
345
 
362
346
  ##
363
347
  # Algorithm for creating the key pair used to sign gems
@@ -465,6 +449,22 @@ module Gem::Security
465
449
  sign certificate, key, certificate, age, extensions, serial
466
450
  end
467
451
 
452
+ ##
453
+ # Creates a new digest instance using the specified +algorithm+. The default
454
+ # is SHA256.
455
+
456
+ if defined?(OpenSSL::Digest)
457
+ def self.create_digest(algorithm = DIGEST_NAME)
458
+ OpenSSL::Digest.new(algorithm)
459
+ end
460
+ else
461
+ require 'digest'
462
+
463
+ def self.create_digest(algorithm = DIGEST_NAME)
464
+ Digest.const_get(algorithm).new
465
+ end
466
+ end
467
+
468
468
  ##
469
469
  # Creates a new key pair of the specified +length+ and +algorithm+. The
470
470
  # default is a 3072 bit RSA key.
@@ -483,7 +483,7 @@ module Gem::Security
483
483
 
484
484
  dcs = dcs.split '.'
485
485
 
486
- name = "CN=#{cn}/#{dcs.map { |dc| "DC=#{dc}" }.join '/'}"
486
+ name = "CN=#{cn}/#{dcs.map {|dc| "DC=#{dc}" }.join '/'}"
487
487
 
488
488
  OpenSSL::X509::Name.parse name
489
489
  end
@@ -526,7 +526,7 @@ module Gem::Security
526
526
 
527
527
  ##
528
528
  # Sign the public key from +certificate+ with the +signing_key+ and
529
- # +signing_cert+, using the Gem::Security::DIGEST_ALGORITHM. Uses the
529
+ # +signing_cert+, using the Gem::Security::DIGEST_NAME. Uses the
530
530
  # default certificate validity range and extensions.
531
531
  #
532
532
  # Returns the newly signed certificate.
@@ -553,7 +553,7 @@ module Gem::Security
553
553
  signed = create_cert signee_subject, signee_key, age, extensions, serial
554
554
  signed.issuer = signing_cert.subject
555
555
 
556
- signed.sign signing_key, Gem::Security::DIGEST_ALGORITHM.new
556
+ signed.sign signing_key, Gem::Security::DIGEST_NAME
557
557
  end
558
558
 
559
559
  ##
@@ -76,7 +76,7 @@ class Gem::Security::Policy
76
76
 
77
77
  def check_data(public_key, digest, signature, data)
78
78
  raise Gem::Security::Exception, "invalid signature" unless
79
- public_key.verify digest.new, signature, data.digest
79
+ public_key.verify digest, signature, data.digest
80
80
 
81
81
  true
82
82
  end
@@ -139,7 +139,7 @@ class Gem::Security::Policy
139
139
  raise Gem::Security::Exception,
140
140
  "root certificate #{root.subject} is not self-signed " +
141
141
  "(issuer #{root.issuer})" if
142
- root.issuer.to_s != root.subject.to_s # HACK to_s is for ruby 1.8
142
+ root.issuer != root.subject
143
143
 
144
144
  check_cert root, root, time
145
145
  end
@@ -224,7 +224,7 @@ class Gem::Security::Policy
224
224
  end
225
225
 
226
226
  opt = @opt
227
- digester = Gem::Security::DIGEST_ALGORITHM
227
+ digester = Gem::Security.create_digest
228
228
  trust_dir = opt[:trust_dir]
229
229
  time = Time.now
230
230
 
@@ -39,7 +39,7 @@ class Gem::Security::Signer
39
39
  }.freeze
40
40
 
41
41
  ##
42
- # Attemps to re-sign an expired cert with a given private key
42
+ # Attempts to re-sign an expired cert with a given private key
43
43
  def self.re_sign_cert(expired_cert, expired_cert_path, private_key)
44
44
  return unless expired_cert.not_after < Time.now
45
45
 
@@ -81,8 +81,8 @@ class Gem::Security::Signer
81
81
  @cert_chain = [default_cert] if File.exist? default_cert
82
82
  end
83
83
 
84
- @digest_algorithm = Gem::Security::DIGEST_ALGORITHM
85
84
  @digest_name = Gem::Security::DIGEST_NAME
85
+ @digest_algorithm = Gem::Security.create_digest(@digest_name)
86
86
 
87
87
  if @key && !@key.is_a?(OpenSSL::PKey::RSA)
88
88
  @key = OpenSSL::PKey::RSA.new(File.read(@key), @passphrase)
@@ -106,10 +106,10 @@ class Gem::Security::Signer
106
106
  # this value is preferred, otherwise the subject is used.
107
107
 
108
108
  def extract_name(cert) # :nodoc:
109
- subject_alt_name = cert.extensions.find { |e| 'subjectAltName' == e.oid }
109
+ subject_alt_name = cert.extensions.find {|e| 'subjectAltName' == e.oid }
110
110
 
111
111
  if subject_alt_name
112
- /\Aemail:/ =~ subject_alt_name.value
112
+ /\Aemail:/ =~ subject_alt_name.value # rubocop:disable Performance/StartWith
113
113
 
114
114
  $' || subject_alt_name.value
115
115
  else
@@ -26,7 +26,7 @@ class Gem::Security::TrustDir
26
26
  @dir = dir
27
27
  @permissions = permissions
28
28
 
29
- @digester = Gem::Security::DIGEST_ALGORITHM
29
+ @digester = Gem::Security.create_digest
30
30
  end
31
31
 
32
32
  ##
@@ -442,8 +442,8 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
442
442
  logger = WEBrick::Log.new nil, WEBrick::BasicLog::FATAL
443
443
  @server = WEBrick::HTTPServer.new :DoNotListen => true, :Logger => logger
444
444
 
445
- @spec_dirs = @gem_dirs.map { |gem_dir| File.join gem_dir, 'specifications' }
446
- @spec_dirs.reject! { |spec_dir| !File.directory? spec_dir }
445
+ @spec_dirs = @gem_dirs.map {|gem_dir| File.join gem_dir, 'specifications' }
446
+ @spec_dirs.reject! {|spec_dir| !File.directory? spec_dir }
447
447
 
448
448
  reset_gems
449
449
 
@@ -458,7 +458,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
458
458
 
459
459
  def uri_encode(str)
460
460
  str.gsub(URI::UNSAFE) do |match|
461
- match.each_byte.map { |c| sprintf('%%%02X', c.ord) }.join
461
+ match.each_byte.map {|c| sprintf('%%%02X', c.ord) }.join
462
462
  end
463
463
  end
464
464
 
@@ -573,7 +573,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
573
573
  add_date res
574
574
 
575
575
  case req.request_uri.path
576
- when %r|^/quick/(Marshal.#{Regexp.escape Gem.marshal_version}/)?(.*?)\.gemspec\.rz$| then
576
+ when %r{^/quick/(Marshal.#{Regexp.escape Gem.marshal_version}/)?(.*?)\.gemspec\.rz$} then
577
577
  marshal_format, full_name = $1, $2
578
578
  specs = Gem::Specification.find_all_by_full_name(full_name)
579
579
 
@@ -615,11 +615,11 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
615
615
  }
616
616
  end
617
617
 
618
- deps = deps.sort_by { |dep| [dep["name"].downcase, dep["version"]] }
618
+ deps = deps.sort_by {|dep| [dep["name"].downcase, dep["version"]] }
619
619
  deps.last["is_last"] = true unless deps.empty?
620
620
 
621
621
  # executables
622
- executables = spec.executables.sort.collect { |exec| {"executable" => exec} }
622
+ executables = spec.executables.sort.collect {|exec| {"executable" => exec} }
623
623
  executables = nil if executables.empty?
624
624
  executables.last["is_last"] = true if executables
625
625
 
@@ -668,7 +668,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
668
668
  "version" => Gem::VERSION,
669
669
  }
670
670
 
671
- specs = specs.sort_by { |spec| [spec["name"].downcase, spec["version"]] }
671
+ specs = specs.sort_by {|spec| [spec["name"].downcase, spec["version"]] }
672
672
  specs.last["is_last"] = true
673
673
 
674
674
  # tag all specs with first_name_entry
@@ -869,7 +869,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
869
869
  listeners = @server.listeners.map{|l| l.addr[2] }
870
870
 
871
871
  # TODO: 0.0.0.0 == any, not localhost.
872
- host = listeners.any?{|l| l == '0.0.0.0'} ? 'localhost' : listeners.first
872
+ host = listeners.any?{|l| l == '0.0.0.0' } ? 'localhost' : listeners.first
873
873
 
874
874
  say "Launching browser to http://#{host}:#{@port}"
875
875
 
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- require 'rubygems/util'
3
2
 
4
3
  ##
5
4
  # A git gem for use in a gem dependencies file.
@@ -103,9 +102,11 @@ class Gem::Source::Git < Gem::Source
103
102
 
104
103
  success = system @git, 'reset', '--quiet', '--hard', rev_parse
105
104
 
106
- success &&=
107
- Gem::Util.silent_system @git, 'submodule', 'update',
108
- '--quiet', '--init', '--recursive' if @need_submodules
105
+ if @need_submodules
106
+ _, status = Open3.capture2e(@git, 'submodule', 'update', '--quiet', '--init', '--recursive')
107
+
108
+ success &&= status.success?
109
+ end
109
110
 
110
111
  success
111
112
  end
@@ -228,8 +229,8 @@ class Gem::Source::Git < Gem::Source
228
229
  require 'digest' # required here to avoid deadlocking in Gem.activate_bin_path (because digest is a gem on 2.5+)
229
230
 
230
231
  normalized =
231
- if @repository =~ %r%^\w+://(\w+@)?%
232
- uri = URI(@repository).normalize.to_s.sub %r%/$%,''
232
+ if @repository =~ %r{^\w+://(\w+@)?}
233
+ uri = URI(@repository).normalize.to_s.sub %r{/$},''
233
234
  uri.sub(/\A(\w+)/) { $1.downcase }
234
235
  else
235
236
  @repository
@@ -61,7 +61,7 @@ class Gem::Source::Local < Gem::Source
61
61
  when :latest
62
62
  tup = pkg.spec.name_tuple
63
63
 
64
- cur = names.find { |x| x.name == tup.name }
64
+ cur = names.find {|x| x.name == tup.name }
65
65
  if !cur
66
66
  names << tup
67
67
  elsif cur.version < tup.version
@@ -98,7 +98,7 @@ class Gem::Source::Local < Gem::Source
98
98
  end
99
99
  end
100
100
 
101
- found.max_by { |s| s.version }
101
+ found.max_by {|s| s.version }
102
102
  end
103
103
 
104
104
  def fetch_spec(name) # :nodoc:
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- require 'rubygems/source'
3
2
 
4
3
  ##
5
4
  # The SourceList represents the sources rubygems has been configured to use.
@@ -90,7 +89,7 @@ class Gem::SourceList
90
89
  # Yields each source URI in the list.
91
90
 
92
91
  def each
93
- @sources.each { |s| yield s.uri.to_s }
92
+ @sources.each {|s| yield s.uri.to_s }
94
93
  end
95
94
 
96
95
  ##
@@ -115,7 +114,7 @@ class Gem::SourceList
115
114
  # Returns an Array of source URI Strings.
116
115
 
117
116
  def to_a
118
- @sources.map { |x| x.uri.to_s }
117
+ @sources.map {|x| x.uri.to_s }
119
118
  end
120
119
 
121
120
  alias_method :to_ary, :to_a
@@ -135,7 +134,7 @@ class Gem::SourceList
135
134
  if other.kind_of? Gem::Source
136
135
  @sources.include? other
137
136
  else
138
- @sources.find { |x| x.uri.to_s == other.to_s }
137
+ @sources.find {|x| x.uri.to_s == other.to_s }
139
138
  end
140
139
  end
141
140
 
@@ -146,7 +145,7 @@ class Gem::SourceList
146
145
  if source.kind_of? Gem::Source
147
146
  @sources.delete source
148
147
  else
149
- @sources.delete_if { |x| x.uri.to_s == source.to_s }
148
+ @sources.delete_if {|x| x.uri.to_s == source.to_s }
150
149
  end
151
150
  end
152
151
 
@@ -92,8 +92,8 @@ class Gem::SpecFetcher
92
92
 
93
93
  list.each do |source, specs|
94
94
  if dependency.name.is_a?(String) && specs.respond_to?(:bsearch)
95
- start_index = (0 ... specs.length).bsearch{ |i| specs[i].name >= dependency.name }
96
- end_index = (0 ... specs.length).bsearch{ |i| specs[i].name > dependency.name }
95
+ start_index = (0 ... specs.length).bsearch{|i| specs[i].name >= dependency.name }
96
+ end_index = (0 ... specs.length).bsearch{|i| specs[i].name > dependency.name }
97
97
  specs = specs[start_index ... end_index] if start_index && end_index
98
98
  end
99
99
 
@@ -122,7 +122,7 @@ class Gem::SpecFetcher
122
122
  end
123
123
  end
124
124
 
125
- tuples = tuples.sort_by { |x| x[0] }
125
+ tuples = tuples.sort_by {|x| x[0] }
126
126
 
127
127
  return [tuples, errors]
128
128
  end
@@ -171,30 +171,33 @@ class Gem::SpecFetcher
171
171
  # Suggests gems based on the supplied +gem_name+. Returns an array of
172
172
  # alternative gem names.
173
173
 
174
- def suggest_gems_from_name(gem_name, type = :latest)
174
+ def suggest_gems_from_name(gem_name, type = :latest, num_results = 5)
175
175
  gem_name = gem_name.downcase.tr('_-', '')
176
176
  max = gem_name.size / 2
177
177
  names = available_specs(type).first.values.flatten(1)
178
178
 
179
179
  matches = names.map do |n|
180
180
  next unless n.match_platform?
181
-
182
- distance = levenshtein_distance gem_name, n.name.downcase.tr('_-', '')
183
-
184
- next if distance >= max
185
-
186
- return [n.name] if distance == 0
187
-
188
- [n.name, distance]
181
+ [n.name, 0] if n.name.downcase.tr('_-', '').include?(gem_name)
189
182
  end.compact
190
183
 
184
+ if matches.length < num_results
185
+ matches += names.map do |n|
186
+ next unless n.match_platform?
187
+ distance = levenshtein_distance gem_name, n.name.downcase.tr('_-', '')
188
+ next if distance >= max
189
+ return [n.name] if distance == 0
190
+ [n.name, distance]
191
+ end.compact
192
+ end
193
+
191
194
  matches = if matches.empty? && type != :prerelease
192
195
  suggest_gems_from_name gem_name, :prerelease
193
196
  else
194
- matches.uniq.sort_by { |name, dist| dist }
197
+ matches.uniq.sort_by {|name, dist| dist }
195
198
  end
196
199
 
197
- matches.first(5).map { |name, dist| name }
200
+ matches.map {|name, dist| name }.uniq.first(num_results)
198
201
  end
199
202
 
200
203
  ##
@@ -251,7 +254,7 @@ class Gem::SpecFetcher
251
254
 
252
255
  def tuples_for(source, type, gracefully_ignore=false) # :nodoc:
253
256
  @caches[type][source.uri] ||=
254
- source.load_specs(type).sort_by { |tup| tup.name }
257
+ source.load_specs(type).sort_by {|tup| tup.name }
255
258
  rescue Gem::RemoteFetcher::FetchError
256
259
  raise unless gracefully_ignore
257
260
  []
@@ -6,9 +6,6 @@
6
6
  # See LICENSE.txt for permissions.
7
7
  #++
8
8
 
9
- require 'rubygems/version'
10
- require 'rubygems/requirement'
11
- require 'rubygems/platform'
12
9
  require 'rubygems/deprecate'
13
10
  require 'rubygems/basic_specification'
14
11
  require 'rubygems/stub_specification'
@@ -180,8 +177,8 @@ class Gem::Specification < Gem::BasicSpecification
180
177
  end
181
178
  end
182
179
 
183
- @@attributes = @@default_value.keys.sort_by { |s| s.to_s }
184
- @@array_attributes = @@default_value.reject { |k,v| v != [] }.keys
180
+ @@attributes = @@default_value.keys.sort_by {|s| s.to_s }
181
+ @@array_attributes = @@default_value.reject {|k,v| v != [] }.keys
185
182
  @@nil_attributes, @@non_nil_attributes = @@default_value.keys.partition do |k|
186
183
  @@default_value[k].nil?
187
184
  end
@@ -249,12 +246,11 @@ class Gem::Specification < Gem::BasicSpecification
249
246
  # require 'rake'
250
247
  # spec.files = FileList['lib/**/*.rb',
251
248
  # 'bin/*',
252
- # '[A-Z]*',
253
- # 'test/**/*'].to_a
249
+ # '[A-Z]*'].to_a
254
250
  #
255
251
  # # or without Rake...
256
252
  # spec.files = Dir['lib/**/*.rb'] + Dir['bin/*']
257
- # spec.files += Dir['[A-Z]*'] + Dir['test/**/*']
253
+ # spec.files += Dir['[A-Z]*']
258
254
  # spec.files.reject! { |fn| fn.include? "CVS" }
259
255
 
260
256
  def files
@@ -390,6 +386,7 @@ class Gem::Specification < Gem::BasicSpecification
390
386
  # "mailing_list_uri" => "https://groups.example.com/bestgemever",
391
387
  # "source_code_uri" => "https://example.com/user/bestgemever",
392
388
  # "wiki_uri" => "https://example.com/user/bestgemever/wiki"
389
+ # "funding_uri" => "https://example.com/donate"
393
390
  # }
394
391
  #
395
392
  # These links will be used on your gem's page on rubygems.org and must pass
@@ -725,7 +722,7 @@ class Gem::Specification < Gem::BasicSpecification
725
722
  # Deprecated: You must now specify the executable name to Gem.bin_path.
726
723
 
727
724
  attr_writer :default_executable
728
- deprecate :default_executable=, :none, 2018, 12
725
+ rubygems_deprecate :default_executable=
729
726
 
730
727
  ##
731
728
  # Allows deinstallation of gems with legacy platforms.
@@ -746,8 +743,8 @@ class Gem::Specification < Gem::BasicSpecification
746
743
  # After a reset, make sure already loaded specs
747
744
  # are still marked as activated.
748
745
  specs = {}
749
- Gem.loaded_specs.each_value{|s| specs[s] = true}
750
- @@all.each{|s| s.activated = true if specs[s]}
746
+ Gem.loaded_specs.each_value{|s| specs[s] = true }
747
+ @@all.each{|s| s.activated = true if specs[s] }
751
748
  end
752
749
  @@all
753
750
  end
@@ -767,7 +764,7 @@ class Gem::Specification < Gem::BasicSpecification
767
764
  end
768
765
 
769
766
  def self.gemspec_stubs_in(dir, pattern)
770
- Gem::Util.glob_files_in_dir(pattern, dir).map { |path| yield path }.select(&:valid?)
767
+ Gem::Util.glob_files_in_dir(pattern, dir).map {|path| yield path }.select(&:valid?)
771
768
  end
772
769
  private_class_method :gemspec_stubs_in
773
770
 
@@ -782,21 +779,11 @@ class Gem::Specification < Gem::BasicSpecification
782
779
  dirs.flat_map do |dir|
783
780
  base_dir = File.dirname dir
784
781
  gems_dir = File.join base_dir, "gems"
785
- gemspec_stubs_in(dir, pattern) { |path| yield path, base_dir, gems_dir }
782
+ gemspec_stubs_in(dir, pattern) {|path| yield path, base_dir, gems_dir }
786
783
  end
787
784
  end
788
785
  private_class_method :map_stubs
789
786
 
790
- def self.uniq_by(list, &block) # :nodoc:
791
- list.uniq(&block)
792
- end
793
- private_class_method :uniq_by
794
-
795
- def self.sort_by!(list, &block)
796
- list.sort_by!(&block)
797
- end
798
- private_class_method :sort_by!
799
-
800
787
  def self.each_spec(dirs) # :nodoc:
801
788
  each_gemspec(dirs) do |path|
802
789
  spec = self.load path
@@ -810,11 +797,11 @@ class Gem::Specification < Gem::BasicSpecification
810
797
  def self.stubs
811
798
  @@stubs ||= begin
812
799
  pattern = "*.gemspec"
813
- stubs = Gem.loaded_specs.values + installed_stubs(dirs, pattern) + default_stubs(pattern)
814
- stubs = uniq_by(stubs) { |stub| stub.full_name }
800
+ stubs = installed_stubs(dirs, pattern) + default_stubs(pattern)
801
+ stubs = stubs.uniq {|stub| stub.full_name }
815
802
 
816
803
  _resort!(stubs)
817
- @@stubs_by_name = stubs.select { |s| Gem::Platform.match s.platform }.group_by(&:name)
804
+ @@stubs_by_name = stubs.select {|s| Gem::Platform.match s.platform }.group_by(&:name)
818
805
  stubs
819
806
  end
820
807
  end
@@ -837,15 +824,13 @@ class Gem::Specification < Gem::BasicSpecification
837
824
  # only returns stubs that match Gem.platforms
838
825
 
839
826
  def self.stubs_for(name)
840
- if @@stubs
841
- @@stubs_by_name[name] || []
827
+ if @@stubs_by_name[name]
828
+ @@stubs_by_name[name]
842
829
  else
843
830
  pattern = "#{name}-*.gemspec"
844
- stubs = Gem.loaded_specs.values +
845
- installed_stubs(dirs, pattern).select { |s| Gem::Platform.match s.platform } +
846
- default_stubs(pattern)
847
- stubs = uniq_by(stubs) { |stub| stub.full_name }.group_by(&:name)
848
- stubs.each_value { |v| _resort!(v) }
831
+ stubs = installed_stubs(dirs, pattern).select {|s| Gem::Platform.match s.platform } + default_stubs(pattern)
832
+ stubs = stubs.uniq {|stub| stub.full_name }.group_by(&:name)
833
+ stubs.each_value {|v| _resort!(v) }
849
834
 
850
835
  @@stubs_by_name.merge! stubs
851
836
  @@stubs_by_name[name] ||= EMPTY
@@ -939,7 +924,7 @@ class Gem::Specification < Gem::BasicSpecification
939
924
  def self.dirs=(dirs)
940
925
  self.reset
941
926
 
942
- @@dirs = Array(dirs).map { |dir| File.join dir, "specifications" }
927
+ @@dirs = Array(dirs).map {|dir| File.join dir, "specifications" }
943
928
  end
944
929
 
945
930
  extend Enumerable
@@ -1023,9 +1008,9 @@ class Gem::Specification < Gem::BasicSpecification
1023
1008
 
1024
1009
  def self.find_in_unresolved(path)
1025
1010
  # TODO: do we need these?? Kill it
1026
- specs = unresolved_deps.values.map { |dep| dep.to_specs }.flatten
1011
+ specs = unresolved_deps.values.map {|dep| dep.to_specs }.flatten
1027
1012
 
1028
- specs.find_all { |spec| spec.contains_requirable_file? path }
1013
+ specs.find_all {|spec| spec.contains_requirable_file? path }
1029
1014
  end
1030
1015
 
1031
1016
  ##
@@ -1033,7 +1018,7 @@ class Gem::Specification < Gem::BasicSpecification
1033
1018
  # specs that contain the file matching +path+.
1034
1019
 
1035
1020
  def self.find_in_unresolved_tree(path)
1036
- specs = unresolved_deps.values.map { |dep| dep.to_specs }.flatten
1021
+ specs = unresolved_deps.values.map {|dep| dep.to_specs }.flatten
1037
1022
 
1038
1023
  specs.each do |spec|
1039
1024
  spec.traverse do |from_spec, dep, to_spec, trail|
@@ -1084,8 +1069,15 @@ class Gem::Specification < Gem::BasicSpecification
1084
1069
  _latest_specs Gem::Specification._all, prerelease
1085
1070
  end
1086
1071
 
1072
+ ##
1073
+ # Return the latest installed spec for gem +name+.
1074
+
1075
+ def self.latest_spec_for(name)
1076
+ latest_specs(true).find {|installed_spec| installed_spec.name == name }
1077
+ end
1078
+
1087
1079
  def self._latest_specs(specs, prerelease = false) # :nodoc:
1088
- result = Hash.new { |h,k| h[k] = {} }
1080
+ result = Hash.new {|h,k| h[k] = {} }
1089
1081
  native = {}
1090
1082
 
1091
1083
  specs.reverse_each do |spec|
@@ -1098,7 +1090,7 @@ class Gem::Specification < Gem::BasicSpecification
1098
1090
  result.map(&:last).map(&:values).flatten.reject do |spec|
1099
1091
  minimum = native[spec.name]
1100
1092
  minimum && spec.version < minimum
1101
- end.sort_by{ |tup| tup.name }
1093
+ end.sort_by{|tup| tup.name }
1102
1094
  end
1103
1095
 
1104
1096
  ##
@@ -1155,7 +1147,7 @@ class Gem::Specification < Gem::BasicSpecification
1155
1147
 
1156
1148
  def self.normalize_yaml_input(input)
1157
1149
  result = input.respond_to?(:read) ? input.read : input
1158
- result = "--- " + result unless result =~ /\A--- /
1150
+ result = "--- " + result unless result.start_with?("--- ")
1159
1151
  result = result.dup
1160
1152
  result.gsub!(/ !!null \n/, " \n")
1161
1153
  # date: 2011-04-26 00:00:00.000000000Z
@@ -1172,7 +1164,7 @@ class Gem::Specification < Gem::BasicSpecification
1172
1164
  # version as well.
1173
1165
 
1174
1166
  def self.outdated
1175
- outdated_and_latest_version.map { |local, _| local.name }
1167
+ outdated_and_latest_version.map {|local, _| local.name }
1176
1168
  end
1177
1169
 
1178
1170
  ##
@@ -1193,7 +1185,7 @@ class Gem::Specification < Gem::BasicSpecification
1193
1185
  Gem::Dependency.new local_spec.name, ">= #{local_spec.version}"
1194
1186
 
1195
1187
  remotes, = fetcher.search_for_dependency dependency
1196
- remotes = remotes.map { |n, _| n.version }
1188
+ remotes = remotes.map {|n, _| n.version }
1197
1189
 
1198
1190
  latest_remote = remotes.sort.last
1199
1191
 
@@ -1224,7 +1216,7 @@ class Gem::Specification < Gem::BasicSpecification
1224
1216
 
1225
1217
  def self.reset
1226
1218
  @@dirs = nil
1227
- Gem.pre_reset_hooks.each { |hook| hook.call }
1219
+ Gem.pre_reset_hooks.each {|hook| hook.call }
1228
1220
  @@all = nil
1229
1221
  @@stubs = nil
1230
1222
  @@stubs_by_name = {}
@@ -1241,19 +1233,19 @@ class Gem::Specification < Gem::BasicSpecification
1241
1233
  versions = find_all_by_name(dep.name)
1242
1234
  unless versions.empty?
1243
1235
  warn " Available/installed versions of this gem:"
1244
- versions.each { |s| warn " - #{s.version}" }
1236
+ versions.each {|s| warn " - #{s.version}" }
1245
1237
  end
1246
1238
  end
1247
1239
  warn "#{w}: Clearing out unresolved specs. Try 'gem cleanup <gem>'"
1248
1240
  warn "Please report a bug if this causes problems."
1249
1241
  unresolved.clear
1250
1242
  end
1251
- Gem.post_reset_hooks.each { |hook| hook.call }
1243
+ Gem.post_reset_hooks.each {|hook| hook.call }
1252
1244
  end
1253
1245
 
1254
1246
  # DOC: This method needs documented or nodoc'd
1255
1247
  def self.unresolved_deps
1256
- @unresolved_deps ||= Hash.new { |h, n| h[n] = Gem::Dependency.new n }
1248
+ @unresolved_deps ||= Hash.new {|h, n| h[n] = Gem::Dependency.new n }
1257
1249
  end
1258
1250
 
1259
1251
  ##
@@ -1284,7 +1276,7 @@ class Gem::Specification < Gem::BasicSpecification
1284
1276
  # Cleanup any YAML::PrivateType. They only show up for an old bug
1285
1277
  # where nil => null, so just convert them to nil based on the type.
1286
1278
 
1287
- array.map! { |e| e.kind_of?(YAML::PrivateType) ? nil : e }
1279
+ array.map! {|e| e.kind_of?(YAML::PrivateType) ? nil : e }
1288
1280
 
1289
1281
  spec.instance_variable_set :@rubygems_version, array[0]
1290
1282
  # spec version
@@ -1397,7 +1389,11 @@ class Gem::Specification < Gem::BasicSpecification
1397
1389
  raise e
1398
1390
  end
1399
1391
 
1400
- specs = spec_dep.to_specs
1392
+ begin
1393
+ specs = spec_dep.to_specs
1394
+ rescue Gem::MissingSpecError => e
1395
+ raise Gem::MissingSpecError.new(e.name, e.requirement, "at: #{self.spec_file}")
1396
+ end
1401
1397
 
1402
1398
  if specs.size == 1
1403
1399
  specs.first.activate
@@ -1433,7 +1429,7 @@ class Gem::Specification < Gem::BasicSpecification
1433
1429
  self.summary = sanitize_string(summary)
1434
1430
  self.description = sanitize_string(description)
1435
1431
  self.post_install_message = sanitize_string(post_install_message)
1436
- self.authors = authors.collect { |a| sanitize_string(a) }
1432
+ self.authors = authors.collect {|a| sanitize_string(a) }
1437
1433
  end
1438
1434
 
1439
1435
  ##
@@ -1445,13 +1441,7 @@ class Gem::Specification < Gem::BasicSpecification
1445
1441
  # HACK the #to_s is in here because RSpec has an Array of Arrays of
1446
1442
  # Strings for authors. Need a way to disallow bad values on gemspec
1447
1443
  # generation. (Probably won't happen.)
1448
- string = string.to_s
1449
-
1450
- begin
1451
- Builder::XChar.encode string
1452
- rescue NameError, NoMethodError
1453
- string.to_xs
1454
- end
1444
+ string.to_s
1455
1445
  end
1456
1446
 
1457
1447
  ##
@@ -1462,7 +1452,7 @@ class Gem::Specification < Gem::BasicSpecification
1462
1452
  return nil if executables.nil?
1463
1453
 
1464
1454
  if @bindir
1465
- Array(executables).map { |e| File.join(@bindir, e) }
1455
+ Array(executables).map {|e| File.join(@bindir, e) }
1466
1456
  else
1467
1457
  executables
1468
1458
  end
@@ -1544,7 +1534,7 @@ class Gem::Specification < Gem::BasicSpecification
1544
1534
  def build_args
1545
1535
  if File.exist? build_info_file
1546
1536
  build_info = File.readlines build_info_file
1547
- build_info = build_info.map { |x| x.strip }
1537
+ build_info = build_info.map {|x| x.strip }
1548
1538
  build_info.delete ""
1549
1539
  build_info
1550
1540
  else
@@ -1636,7 +1626,7 @@ class Gem::Specification < Gem::BasicSpecification
1636
1626
 
1637
1627
  def conficts_when_loaded_with?(list_of_specs) # :nodoc:
1638
1628
  result = list_of_specs.any? do |spec|
1639
- spec.dependencies.any? { |dep| dep.runtime? && (dep.name == name) && !satisfies_requirement?(dep) }
1629
+ spec.dependencies.any? {|dep| dep.runtime? && (dep.name == name) && !satisfies_requirement?(dep) }
1640
1630
  end
1641
1631
  result
1642
1632
  end
@@ -1725,7 +1715,7 @@ class Gem::Specification < Gem::BasicSpecification
1725
1715
  end
1726
1716
  result
1727
1717
  end
1728
- deprecate :default_executable, :none, 2018, 12
1718
+ rubygems_deprecate :default_executable
1729
1719
 
1730
1720
  ##
1731
1721
  # The default value for specification attribute +name+
@@ -1750,10 +1740,11 @@ class Gem::Specification < Gem::BasicSpecification
1750
1740
  #
1751
1741
  # [depending_gem, dependency, [list_of_gems_that_satisfy_dependency]]
1752
1742
 
1753
- def dependent_gems
1743
+ def dependent_gems(check_dev=true)
1754
1744
  out = []
1755
1745
  Gem::Specification.each do |spec|
1756
- spec.dependencies.each do |dep|
1746
+ deps = check_dev ? spec.dependencies : spec.runtime_dependencies
1747
+ deps.each do |dep|
1757
1748
  if self.satisfies_requirement?(dep)
1758
1749
  sats = []
1759
1750
  find_all_satisfiers(dep) do |sat|
@@ -1770,7 +1761,7 @@ class Gem::Specification < Gem::BasicSpecification
1770
1761
  # Returns all specs that matches this spec's runtime dependencies.
1771
1762
 
1772
1763
  def dependent_specs
1773
- runtime_dependencies.map { |dep| dep.to_specs }.flatten
1764
+ runtime_dependencies.map {|dep| dep.to_specs }.flatten
1774
1765
  end
1775
1766
 
1776
1767
  ##
@@ -1784,7 +1775,7 @@ class Gem::Specification < Gem::BasicSpecification
1784
1775
  # List of dependencies that are used for development
1785
1776
 
1786
1777
  def development_dependencies
1787
- dependencies.select { |d| d.type == :development }
1778
+ dependencies.select {|d| d.type == :development }
1788
1779
  end
1789
1780
 
1790
1781
  ##
@@ -1845,29 +1836,23 @@ class Gem::Specification < Gem::BasicSpecification
1845
1836
  end
1846
1837
 
1847
1838
  ##
1848
- # Sets executables to +value+, ensuring it is an array. Don't
1849
- # use this, push onto the array instead.
1839
+ # Sets executables to +value+, ensuring it is an array.
1850
1840
 
1851
1841
  def executables=(value)
1852
- # TODO: warn about setting instead of pushing
1853
1842
  @executables = Array(value)
1854
1843
  end
1855
1844
 
1856
1845
  ##
1857
- # Sets extensions to +extensions+, ensuring it is an array. Don't
1858
- # use this, push onto the array instead.
1846
+ # Sets extensions to +extensions+, ensuring it is an array.
1859
1847
 
1860
1848
  def extensions=(extensions)
1861
- # TODO: warn about setting instead of pushing
1862
1849
  @extensions = Array extensions
1863
1850
  end
1864
1851
 
1865
1852
  ##
1866
- # Sets extra_rdoc_files to +files+, ensuring it is an array. Don't
1867
- # use this, push onto the array instead.
1853
+ # Sets extra_rdoc_files to +files+, ensuring it is an array.
1868
1854
 
1869
1855
  def extra_rdoc_files=(files)
1870
- # TODO: warn about setting instead of pushing
1871
1856
  @extra_rdoc_files = Array files
1872
1857
  end
1873
1858
 
@@ -1933,7 +1918,7 @@ class Gem::Specification < Gem::BasicSpecification
1933
1918
  def has_rdoc # :nodoc:
1934
1919
  true
1935
1920
  end
1936
- deprecate :has_rdoc, :none, 2018, 12
1921
+ rubygems_deprecate :has_rdoc
1937
1922
 
1938
1923
  ##
1939
1924
  # Deprecated and ignored.
@@ -1943,10 +1928,10 @@ class Gem::Specification < Gem::BasicSpecification
1943
1928
  def has_rdoc=(ignored) # :nodoc:
1944
1929
  @has_rdoc = true
1945
1930
  end
1946
- deprecate :has_rdoc=, :none, 2018, 12
1931
+ rubygems_deprecate :has_rdoc=
1947
1932
 
1948
1933
  alias :has_rdoc? :has_rdoc # :nodoc:
1949
- deprecate :has_rdoc?, :none, 2018, 12
1934
+ rubygems_deprecate :has_rdoc?
1950
1935
 
1951
1936
  ##
1952
1937
  # True if this gem has files in test_files
@@ -1968,7 +1953,7 @@ class Gem::Specification < Gem::BasicSpecification
1968
1953
  yaml_initialize coder.tag, coder.map
1969
1954
  end
1970
1955
 
1971
- eval <<-RB, binding, __FILE__, __LINE__ + 1
1956
+ eval <<-RUBY, binding, __FILE__, __LINE__ + 1
1972
1957
  def set_nil_attributes_to_nil
1973
1958
  #{@@nil_attributes.map {|key| "@#{key} = nil" }.join "; "}
1974
1959
  end
@@ -1978,7 +1963,7 @@ class Gem::Specification < Gem::BasicSpecification
1978
1963
  #{@@non_nil_attributes.map {|key| "@#{key} = #{INITIALIZE_CODE_FOR_DEFAULTS[key]}" }.join ";"}
1979
1964
  end
1980
1965
  private :set_not_nil_attributes_to_default_values
1981
- RB
1966
+ RUBY
1982
1967
 
1983
1968
  ##
1984
1969
  # Specification constructor. Assigns the default values to the attributes
@@ -2115,7 +2100,7 @@ class Gem::Specification < Gem::BasicSpecification
2115
2100
  end
2116
2101
 
2117
2102
  if @specification_version > CURRENT_SPECIFICATION_VERSION and
2118
- sym.to_s =~ /=$/
2103
+ sym.to_s.end_with?("=")
2119
2104
  warn "ignoring #{sym} loading #{full_name}" if $DEBUG
2120
2105
  else
2121
2106
  super
@@ -2199,7 +2184,7 @@ class Gem::Specification < Gem::BasicSpecification
2199
2184
 
2200
2185
  attributes.each do |attr_name|
2201
2186
  current_value = self.send attr_name
2202
- current_value = current_value.sort if %i(files test_files).include? attr_name
2187
+ current_value = current_value.sort if %i[files test_files].include? attr_name
2203
2188
  if current_value != default_value(attr_name) or
2204
2189
  self.class.required_attribute? attr_name
2205
2190
 
@@ -2249,11 +2234,9 @@ class Gem::Specification < Gem::BasicSpecification
2249
2234
  end
2250
2235
 
2251
2236
  ##
2252
- # Sets rdoc_options to +value+, ensuring it is an array. Don't
2253
- # use this, push onto the array instead.
2237
+ # Sets rdoc_options to +value+, ensuring it is an array.
2254
2238
 
2255
2239
  def rdoc_options=(options)
2256
- # TODO: warn about setting instead of pushing
2257
2240
  @rdoc_options = Array options
2258
2241
  end
2259
2242
 
@@ -2272,11 +2255,9 @@ class Gem::Specification < Gem::BasicSpecification
2272
2255
  end
2273
2256
 
2274
2257
  ##
2275
- # Set requirements to +req+, ensuring it is an array. Don't
2276
- # use this, push onto the array instead.
2258
+ # Set requirements to +req+, ensuring it is an array.
2277
2259
 
2278
2260
  def requirements=(req)
2279
- # TODO: warn about setting instead of pushing
2280
2261
  @requirements = Array req
2281
2262
  end
2282
2263
 
@@ -2298,9 +2279,9 @@ class Gem::Specification < Gem::BasicSpecification
2298
2279
  def ruby_code(obj)
2299
2280
  case obj
2300
2281
  when String then obj.dump + ".freeze"
2301
- when Array then '[' + obj.map { |x| ruby_code x }.join(", ") + ']'
2282
+ when Array then '[' + obj.map {|x| ruby_code x }.join(", ") + ']'
2302
2283
  when Hash then
2303
- seg = obj.keys.sort.map { |k| "#{k.to_s.dump} => #{obj[k].to_s.dump}" }
2284
+ seg = obj.keys.sort.map {|k| "#{k.to_s.dump} => #{obj[k].to_s.dump}" }
2304
2285
  "{ #{seg.join(', ')} }"
2305
2286
  when Gem::Version then obj.to_s.dump
2306
2287
  when DateLike then obj.strftime('%Y-%m-%d').dump
@@ -2328,7 +2309,7 @@ class Gem::Specification < Gem::BasicSpecification
2328
2309
  # True if this gem has the same attributes as +other+.
2329
2310
 
2330
2311
  def same_attributes?(spec)
2331
- @@attributes.all? { |name, default| self.send(name) == spec.send(name) }
2312
+ @@attributes.all? {|name, default| self.send(name) == spec.send(name) }
2332
2313
  end
2333
2314
 
2334
2315
  private :same_attributes?
@@ -2570,7 +2551,7 @@ class Gem::Specification < Gem::BasicSpecification
2570
2551
  unless result == :next
2571
2552
  spec_name = dep_spec.name
2572
2553
  dep_spec.traverse(trail, visited, &block) unless
2573
- trail.any? { |s| s.name == spec_name }
2554
+ trail.any? {|s| s.name == spec_name }
2574
2555
  end
2575
2556
  end
2576
2557
  end
@@ -2595,30 +2576,27 @@ class Gem::Specification < Gem::BasicSpecification
2595
2576
  end
2596
2577
 
2597
2578
  def keep_only_files_and_directories
2598
- @executables.delete_if { |x| File.directory?(File.join(@bindir, x)) }
2599
- @extensions.delete_if { |x| File.directory?(x) && !File.symlink?(x) }
2600
- @extra_rdoc_files.delete_if { |x| File.directory?(x) && !File.symlink?(x) }
2601
- @files.delete_if { |x| File.directory?(x) && !File.symlink?(x) }
2602
- @test_files.delete_if { |x| File.directory?(x) && !File.symlink?(x) }
2579
+ @executables.delete_if {|x| File.directory?(File.join(@bindir, x)) }
2580
+ @extensions.delete_if {|x| File.directory?(x) && !File.symlink?(x) }
2581
+ @extra_rdoc_files.delete_if {|x| File.directory?(x) && !File.symlink?(x) }
2582
+ @files.delete_if {|x| File.directory?(x) && !File.symlink?(x) }
2583
+ @test_files.delete_if {|x| File.directory?(x) && !File.symlink?(x) }
2603
2584
  end
2604
2585
 
2605
2586
  def validate_metadata
2606
2587
  Gem::SpecificationPolicy.new(self).validate_metadata
2607
2588
  end
2589
+ rubygems_deprecate :validate_metadata
2608
2590
 
2609
- ##
2610
- # Checks that dependencies use requirements as we recommend. Warnings are
2611
- # issued when dependencies are open-ended or overly strict for semantic
2612
- # versioning.
2613
2591
  def validate_dependencies
2614
2592
  Gem::SpecificationPolicy.new(self).validate_dependencies
2615
2593
  end
2594
+ rubygems_deprecate :validate_dependencies
2616
2595
 
2617
- ##
2618
- # Checks to see if the files to be packaged are world-readable.
2619
2596
  def validate_permissions
2620
2597
  Gem::SpecificationPolicy.new(self).validate_permissions
2621
2598
  end
2599
+ rubygems_deprecate :validate_permissions
2622
2600
 
2623
2601
  ##
2624
2602
  # Set the version to +version+, potentially also setting
@@ -2683,6 +2661,3 @@ class Gem::Specification < Gem::BasicSpecification
2683
2661
  end
2684
2662
 
2685
2663
  end
2686
-
2687
- # DOC: What is this and why is it here, randomly, at the end of this file?
2688
- Gem.clear_paths