rubygems-update 2.7.11 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubygems-update might be problematic. Click here for more details.

Files changed (350) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +66 -0
  3. data/.travis.yml +22 -18
  4. data/CONTRIBUTING.md +141 -0
  5. data/History.txt +289 -19
  6. data/MAINTAINERS.txt +1 -0
  7. data/Manifest.txt +16 -11
  8. data/POLICIES.md +92 -0
  9. data/README.md +47 -26
  10. data/Rakefile +47 -207
  11. data/{UPGRADING.rdoc → UPGRADING.md} +31 -32
  12. data/appveyor.yml +20 -45
  13. data/bin/gem +1 -2
  14. data/bin/update_rubygems +2 -3
  15. data/bundler/CHANGELOG.md +54 -0
  16. data/bundler/bundler.gemspec +7 -1
  17. data/bundler/lib/bundler.rb +26 -8
  18. data/bundler/lib/bundler/build_metadata.rb +2 -2
  19. data/bundler/lib/bundler/cli.rb +63 -21
  20. data/bundler/lib/bundler/cli/add.rb +15 -5
  21. data/bundler/lib/bundler/cli/binstubs.rb +8 -2
  22. data/bundler/lib/bundler/cli/doctor.rb +47 -1
  23. data/bundler/lib/bundler/cli/install.rb +8 -5
  24. data/bundler/lib/bundler/cli/list.rb +41 -5
  25. data/bundler/lib/bundler/cli/outdated.rb +7 -1
  26. data/bundler/lib/bundler/cli/pristine.rb +4 -0
  27. data/bundler/lib/bundler/cli/remove.rb +18 -0
  28. data/bundler/lib/bundler/definition.rb +15 -16
  29. data/bundler/lib/bundler/dependency.rb +2 -2
  30. data/bundler/lib/bundler/dsl.rb +19 -3
  31. data/bundler/lib/bundler/feature_flag.rb +7 -0
  32. data/bundler/lib/bundler/gem_version_promoter.rb +4 -2
  33. data/bundler/lib/bundler/injector.rb +168 -9
  34. data/bundler/lib/bundler/installer.rb +29 -6
  35. data/bundler/lib/bundler/installer/parallel_installer.rb +5 -0
  36. data/bundler/lib/bundler/plugin.rb +10 -3
  37. data/bundler/lib/bundler/plugin/events.rb +61 -0
  38. data/bundler/lib/bundler/resolver.rb +2 -2
  39. data/bundler/lib/bundler/runtime.rb +8 -2
  40. data/bundler/lib/bundler/settings.rb +24 -3
  41. data/bundler/lib/bundler/settings/validator.rb +23 -0
  42. data/bundler/lib/bundler/shared_helpers.rb +19 -3
  43. data/bundler/lib/bundler/source.rb +9 -9
  44. data/bundler/lib/bundler/templates/newgem/lib/newgem.rb.tt +1 -0
  45. data/bundler/lib/bundler/version.rb +1 -1
  46. data/bundler/man/bundle-add.ronn +13 -2
  47. data/bundler/man/bundle-config.ronn +21 -0
  48. data/bundler/man/bundle-install.ronn +1 -1
  49. data/bundler/man/bundle-list.ronn +19 -1
  50. data/bundler/man/bundle-outdated.ronn +4 -0
  51. data/bundler/man/bundle-remove.ronn +23 -0
  52. data/bundler/man/bundle-update.ronn +1 -1
  53. data/lib/rubygems.rb +70 -96
  54. data/lib/rubygems/available_set.rb +1 -1
  55. data/lib/rubygems/basic_specification.rb +12 -12
  56. data/lib/rubygems/bundler_version_finder.rb +3 -3
  57. data/lib/rubygems/command.rb +22 -15
  58. data/lib/rubygems/command_manager.rb +20 -11
  59. data/lib/rubygems/commands/build_command.rb +27 -8
  60. data/lib/rubygems/commands/cert_command.rb +45 -24
  61. data/lib/rubygems/commands/check_command.rb +1 -1
  62. data/lib/rubygems/commands/cleanup_command.rb +14 -7
  63. data/lib/rubygems/commands/contents_command.rb +14 -15
  64. data/lib/rubygems/commands/dependency_command.rb +17 -17
  65. data/lib/rubygems/commands/environment_command.rb +20 -1
  66. data/lib/rubygems/commands/fetch_command.rb +2 -3
  67. data/lib/rubygems/commands/generate_index_command.rb +2 -3
  68. data/lib/rubygems/commands/help_command.rb +12 -13
  69. data/lib/rubygems/commands/info_command.rb +33 -0
  70. data/lib/rubygems/commands/install_command.rb +21 -17
  71. data/lib/rubygems/commands/list_command.rb +0 -1
  72. data/lib/rubygems/commands/lock_command.rb +3 -4
  73. data/lib/rubygems/commands/open_command.rb +16 -10
  74. data/lib/rubygems/commands/owner_command.rb +20 -11
  75. data/lib/rubygems/commands/pristine_command.rb +23 -16
  76. data/lib/rubygems/commands/push_command.rb +17 -8
  77. data/lib/rubygems/commands/query_command.rb +24 -24
  78. data/lib/rubygems/commands/rdoc_command.rb +3 -4
  79. data/lib/rubygems/commands/search_command.rb +0 -1
  80. data/lib/rubygems/commands/server_command.rb +1 -2
  81. data/lib/rubygems/commands/setup_command.rb +78 -38
  82. data/lib/rubygems/commands/signin_command.rb +2 -1
  83. data/lib/rubygems/commands/signout_command.rb +2 -2
  84. data/lib/rubygems/commands/sources_command.rb +11 -12
  85. data/lib/rubygems/commands/specification_command.rb +7 -7
  86. data/lib/rubygems/commands/uninstall_command.rb +41 -19
  87. data/lib/rubygems/commands/unpack_command.rb +16 -7
  88. data/lib/rubygems/commands/update_command.rb +28 -23
  89. data/lib/rubygems/commands/which_command.rb +4 -5
  90. data/lib/rubygems/commands/yank_command.rb +1 -2
  91. data/lib/rubygems/compatibility.rb +1 -21
  92. data/lib/rubygems/config_file.rb +36 -36
  93. data/lib/rubygems/core_ext/kernel_require.rb +6 -6
  94. data/lib/rubygems/core_ext/kernel_warn.rb +45 -0
  95. data/lib/rubygems/defaults.rb +31 -12
  96. data/lib/rubygems/dependency.rb +14 -14
  97. data/lib/rubygems/dependency_installer.rb +29 -31
  98. data/lib/rubygems/dependency_list.rb +8 -9
  99. data/lib/rubygems/deprecate.rb +2 -3
  100. data/lib/rubygems/doctor.rb +5 -6
  101. data/lib/rubygems/errors.rb +3 -3
  102. data/lib/rubygems/exceptions.rb +11 -4
  103. data/lib/rubygems/ext.rb +0 -1
  104. data/lib/rubygems/ext/build_error.rb +0 -1
  105. data/lib/rubygems/ext/builder.rb +50 -23
  106. data/lib/rubygems/ext/cmake_builder.rb +2 -2
  107. data/lib/rubygems/ext/configure_builder.rb +2 -3
  108. data/lib/rubygems/ext/ext_conf_builder.rb +8 -7
  109. data/lib/rubygems/ext/rake_builder.rb +16 -18
  110. data/lib/rubygems/gem_runner.rb +2 -2
  111. data/lib/rubygems/gemcutter_utilities.rb +40 -13
  112. data/lib/rubygems/indexer.rb +19 -12
  113. data/lib/rubygems/install_default_message.rb +0 -1
  114. data/lib/rubygems/install_message.rb +0 -1
  115. data/lib/rubygems/install_update_options.rb +2 -28
  116. data/lib/rubygems/installer.rb +95 -75
  117. data/lib/rubygems/installer_test_case.rb +0 -14
  118. data/lib/rubygems/local_remote_options.rb +5 -4
  119. data/lib/rubygems/mock_gem_ui.rb +3 -4
  120. data/lib/rubygems/name_tuple.rb +4 -4
  121. data/lib/rubygems/package.rb +90 -73
  122. data/lib/rubygems/package/digest_io.rb +3 -4
  123. data/lib/rubygems/package/file_source.rb +3 -4
  124. data/lib/rubygems/package/io_source.rb +1 -2
  125. data/lib/rubygems/package/old.rb +8 -16
  126. data/lib/rubygems/package/source.rb +0 -1
  127. data/lib/rubygems/package/tar_header.rb +2 -2
  128. data/lib/rubygems/package/tar_reader.rb +2 -4
  129. data/lib/rubygems/package/tar_reader/entry.rb +20 -4
  130. data/lib/rubygems/package/tar_test_case.rb +2 -8
  131. data/lib/rubygems/package/tar_writer.rb +13 -15
  132. data/lib/rubygems/package_task.rb +0 -1
  133. data/lib/rubygems/path_support.rb +16 -6
  134. data/lib/rubygems/platform.rb +4 -5
  135. data/lib/rubygems/psych_tree.rb +1 -1
  136. data/lib/rubygems/rdoc.rb +0 -311
  137. data/lib/rubygems/remote_fetcher.rb +34 -48
  138. data/lib/rubygems/request.rb +16 -15
  139. data/lib/rubygems/request/connection_pools.rb +24 -13
  140. data/lib/rubygems/request/http_pool.rb +3 -4
  141. data/lib/rubygems/request/https_pool.rb +1 -3
  142. data/lib/rubygems/request_set.rb +52 -25
  143. data/lib/rubygems/request_set/gem_dependency_api.rb +36 -40
  144. data/lib/rubygems/request_set/lockfile.rb +12 -12
  145. data/lib/rubygems/request_set/lockfile/parser.rb +18 -29
  146. data/lib/rubygems/request_set/lockfile/tokenizer.rb +9 -9
  147. data/lib/rubygems/requirement.rb +16 -16
  148. data/lib/rubygems/resolver.rb +10 -15
  149. data/lib/rubygems/resolver/activation_request.rb +6 -6
  150. data/lib/rubygems/resolver/api_set.rb +5 -6
  151. data/lib/rubygems/resolver/api_specification.rb +2 -3
  152. data/lib/rubygems/resolver/best_set.rb +5 -6
  153. data/lib/rubygems/resolver/composed_set.rb +5 -6
  154. data/lib/rubygems/resolver/conflict.rb +5 -5
  155. data/lib/rubygems/resolver/current_set.rb +1 -2
  156. data/lib/rubygems/resolver/dependency_request.rb +4 -4
  157. data/lib/rubygems/resolver/git_set.rb +5 -6
  158. data/lib/rubygems/resolver/git_specification.rb +4 -5
  159. data/lib/rubygems/resolver/index_set.rb +5 -6
  160. data/lib/rubygems/resolver/index_specification.rb +3 -4
  161. data/lib/rubygems/resolver/installed_specification.rb +3 -4
  162. data/lib/rubygems/resolver/installer_set.rb +12 -12
  163. data/lib/rubygems/resolver/local_specification.rb +1 -2
  164. data/lib/rubygems/resolver/lock_set.rb +5 -6
  165. data/lib/rubygems/resolver/lock_specification.rb +7 -8
  166. data/lib/rubygems/resolver/requirement_list.rb +1 -1
  167. data/lib/rubygems/resolver/set.rb +2 -2
  168. data/lib/rubygems/resolver/source_set.rb +4 -5
  169. data/lib/rubygems/resolver/spec_specification.rb +1 -2
  170. data/lib/rubygems/resolver/specification.rb +10 -7
  171. data/lib/rubygems/resolver/stats.rb +1 -1
  172. data/lib/rubygems/resolver/vendor_set.rb +4 -5
  173. data/lib/rubygems/resolver/vendor_specification.rb +2 -3
  174. data/lib/rubygems/safe_yaml.rb +18 -10
  175. data/lib/rubygems/security.rb +21 -22
  176. data/lib/rubygems/security/policies.rb +1 -2
  177. data/lib/rubygems/security/policy.rb +25 -25
  178. data/lib/rubygems/security/signer.rb +72 -24
  179. data/lib/rubygems/security/trust_dir.rb +10 -10
  180. data/lib/rubygems/server.rb +21 -21
  181. data/lib/rubygems/source.rb +16 -25
  182. data/lib/rubygems/source/git.rb +9 -10
  183. data/lib/rubygems/source/installed.rb +3 -4
  184. data/lib/rubygems/source/local.rb +7 -7
  185. data/lib/rubygems/source/lock.rb +4 -4
  186. data/lib/rubygems/source/specific_file.rb +5 -5
  187. data/lib/rubygems/source/vendor.rb +2 -3
  188. data/lib/rubygems/source_list.rb +2 -2
  189. data/lib/rubygems/source_local.rb +0 -1
  190. data/lib/rubygems/spec_fetcher.rb +5 -6
  191. data/lib/rubygems/specification.rb +199 -536
  192. data/lib/rubygems/specification_policy.rb +407 -0
  193. data/lib/rubygems/ssl_certs/{rubygems.org → index.rubygems.org}/GlobalSignRootCA.pem +0 -0
  194. data/lib/rubygems/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +23 -0
  195. data/lib/rubygems/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +25 -0
  196. data/lib/rubygems/stub_specification.rb +11 -15
  197. data/lib/rubygems/test_case.rb +141 -66
  198. data/lib/rubygems/test_utilities.rb +20 -35
  199. data/lib/rubygems/text.rb +6 -6
  200. data/lib/rubygems/uninstaller.rb +37 -26
  201. data/lib/rubygems/uri_formatter.rb +1 -2
  202. data/lib/rubygems/user_interaction.rb +38 -93
  203. data/lib/rubygems/util.rb +20 -14
  204. data/lib/rubygems/util/licenses.rb +27 -1
  205. data/lib/rubygems/util/list.rb +1 -1
  206. data/lib/rubygems/validator.rb +4 -5
  207. data/lib/rubygems/version.rb +15 -15
  208. data/lib/rubygems/version_option.rb +2 -3
  209. data/rubygems-update.gemspec +43 -0
  210. data/setup.rb +2 -8
  211. data/test/rubygems/rubygems_plugin.rb +0 -1
  212. data/test/rubygems/simple_gem.rb +1 -1
  213. data/test/rubygems/test_bundled_ca.rb +4 -7
  214. data/test/rubygems/test_config.rb +7 -2
  215. data/test/rubygems/test_gem.rb +161 -130
  216. data/test/rubygems/test_gem_command.rb +0 -1
  217. data/test/rubygems/test_gem_command_manager.rb +8 -3
  218. data/test/rubygems/test_gem_commands_build_command.rb +219 -15
  219. data/test/rubygems/test_gem_commands_cert_command.rb +69 -8
  220. data/test/rubygems/test_gem_commands_check_command.rb +1 -1
  221. data/test/rubygems/test_gem_commands_cleanup_command.rb +27 -1
  222. data/test/rubygems/test_gem_commands_contents_command.rb +1 -2
  223. data/test/rubygems/test_gem_commands_dependency_command.rb +33 -34
  224. data/test/rubygems/test_gem_commands_environment_command.rb +1 -0
  225. data/test/rubygems/test_gem_commands_fetch_command.rb +0 -1
  226. data/test/rubygems/test_gem_commands_generate_index_command.rb +0 -1
  227. data/test/rubygems/test_gem_commands_help_command.rb +7 -4
  228. data/test/rubygems/test_gem_commands_info_command.rb +44 -0
  229. data/test/rubygems/test_gem_commands_install_command.rb +79 -12
  230. data/test/rubygems/test_gem_commands_lock_command.rb +0 -1
  231. data/test/rubygems/test_gem_commands_open_command.rb +29 -0
  232. data/test/rubygems/test_gem_commands_outdated_command.rb +0 -1
  233. data/test/rubygems/test_gem_commands_owner_command.rb +93 -57
  234. data/test/rubygems/test_gem_commands_pristine_command.rb +65 -30
  235. data/test/rubygems/test_gem_commands_push_command.rb +39 -0
  236. data/test/rubygems/test_gem_commands_query_command.rb +102 -100
  237. data/test/rubygems/test_gem_commands_search_command.rb +0 -1
  238. data/test/rubygems/test_gem_commands_server_command.rb +0 -1
  239. data/test/rubygems/test_gem_commands_setup_command.rb +39 -8
  240. data/test/rubygems/test_gem_commands_signin_command.rb +1 -1
  241. data/test/rubygems/test_gem_commands_sources_command.rb +0 -1
  242. data/test/rubygems/test_gem_commands_specification_command.rb +2 -3
  243. data/test/rubygems/test_gem_commands_stale_command.rb +3 -2
  244. data/test/rubygems/test_gem_commands_uninstall_command.rb +81 -7
  245. data/test/rubygems/test_gem_commands_unpack_command.rb +17 -1
  246. data/test/rubygems/test_gem_commands_update_command.rb +19 -2
  247. data/test/rubygems/test_gem_commands_which_command.rb +0 -1
  248. data/test/rubygems/test_gem_commands_yank_command.rb +0 -1
  249. data/test/rubygems/test_gem_config_file.rb +4 -2
  250. data/test/rubygems/test_gem_dependency.rb +0 -1
  251. data/test/rubygems/test_gem_dependency_installer.rb +8 -5
  252. data/test/rubygems/test_gem_dependency_list.rb +6 -7
  253. data/test/rubygems/test_gem_dependency_resolution_error.rb +0 -1
  254. data/test/rubygems/test_gem_doctor.rb +1 -2
  255. data/test/rubygems/test_gem_ext_builder.rb +10 -23
  256. data/test/rubygems/test_gem_ext_cmake_builder.rb +5 -4
  257. data/test/rubygems/test_gem_ext_configure_builder.rb +3 -3
  258. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +8 -9
  259. data/test/rubygems/test_gem_ext_rake_builder.rb +20 -5
  260. data/test/rubygems/test_gem_gem_runner.rb +0 -1
  261. data/test/rubygems/test_gem_gemcutter_utilities.rb +32 -6
  262. data/test/rubygems/test_gem_impossible_dependencies_error.rb +0 -1
  263. data/test/rubygems/test_gem_indexer.rb +1 -2
  264. data/test/rubygems/test_gem_install_update_options.rb +1 -20
  265. data/test/rubygems/test_gem_installer.rb +69 -203
  266. data/test/rubygems/test_gem_local_remote_options.rb +3 -3
  267. data/test/rubygems/test_gem_name_tuple.rb +0 -1
  268. data/test/rubygems/test_gem_package.rb +59 -50
  269. data/test/rubygems/test_gem_package_old.rb +0 -1
  270. data/test/rubygems/test_gem_package_tar_header.rb +1 -2
  271. data/test/rubygems/test_gem_package_tar_reader.rb +0 -1
  272. data/test/rubygems/test_gem_package_tar_reader_entry.rb +11 -0
  273. data/test/rubygems/test_gem_package_tar_writer.rb +40 -7
  274. data/test/rubygems/test_gem_package_task.rb +2 -2
  275. data/test/rubygems/test_gem_path_support.rb +28 -11
  276. data/test/rubygems/test_gem_platform.rb +4 -5
  277. data/test/rubygems/test_gem_rdoc.rb +1 -2
  278. data/test/rubygems/test_gem_remote_fetcher.rb +111 -130
  279. data/test/rubygems/test_gem_request.rb +5 -5
  280. data/test/rubygems/test_gem_request_connection_pools.rb +24 -3
  281. data/test/rubygems/test_gem_request_set.rb +5 -5
  282. data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +2 -7
  283. data/test/rubygems/test_gem_request_set_lockfile.rb +1 -2
  284. data/test/rubygems/test_gem_request_set_lockfile_parser.rb +4 -9
  285. data/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb +1 -1
  286. data/test/rubygems/test_gem_requirement.rb +18 -4
  287. data/test/rubygems/test_gem_resolver.rb +13 -17
  288. data/test/rubygems/test_gem_resolver_activation_request.rb +0 -1
  289. data/test/rubygems/test_gem_resolver_api_set.rb +0 -1
  290. data/test/rubygems/test_gem_resolver_api_specification.rb +0 -1
  291. data/test/rubygems/test_gem_resolver_best_set.rb +0 -1
  292. data/test/rubygems/test_gem_resolver_composed_set.rb +0 -1
  293. data/test/rubygems/test_gem_resolver_conflict.rb +0 -1
  294. data/test/rubygems/test_gem_resolver_dependency_request.rb +0 -1
  295. data/test/rubygems/test_gem_resolver_git_set.rb +0 -1
  296. data/test/rubygems/test_gem_resolver_git_specification.rb +0 -1
  297. data/test/rubygems/test_gem_resolver_index_set.rb +0 -1
  298. data/test/rubygems/test_gem_resolver_index_specification.rb +0 -1
  299. data/test/rubygems/test_gem_resolver_installed_specification.rb +0 -1
  300. data/test/rubygems/test_gem_resolver_installer_set.rb +2 -3
  301. data/test/rubygems/test_gem_resolver_local_specification.rb +0 -1
  302. data/test/rubygems/test_gem_resolver_lock_set.rb +0 -1
  303. data/test/rubygems/test_gem_resolver_lock_specification.rb +0 -1
  304. data/test/rubygems/test_gem_resolver_requirement_list.rb +0 -1
  305. data/test/rubygems/test_gem_resolver_specification.rb +1 -2
  306. data/test/rubygems/test_gem_resolver_vendor_set.rb +0 -1
  307. data/test/rubygems/test_gem_resolver_vendor_specification.rb +0 -1
  308. data/test/rubygems/test_gem_security.rb +1 -3
  309. data/test/rubygems/test_gem_security_policy.rb +4 -5
  310. data/test/rubygems/test_gem_security_signer.rb +4 -3
  311. data/test/rubygems/test_gem_security_trust_dir.rb +1 -2
  312. data/test/rubygems/test_gem_server.rb +4 -4
  313. data/test/rubygems/test_gem_source.rb +0 -13
  314. data/test/rubygems/test_gem_source_fetch_problem.rb +0 -1
  315. data/test/rubygems/test_gem_source_git.rb +0 -1
  316. data/test/rubygems/test_gem_source_installed.rb +0 -1
  317. data/test/rubygems/test_gem_source_lock.rb +0 -1
  318. data/test/rubygems/test_gem_source_vendor.rb +0 -1
  319. data/test/rubygems/test_gem_spec_fetcher.rb +0 -1
  320. data/test/rubygems/test_gem_specification.rb +334 -198
  321. data/test/rubygems/test_gem_stream_ui.rb +13 -30
  322. data/test/rubygems/test_gem_stub_specification.rb +0 -2
  323. data/test/rubygems/test_gem_text.rb +4 -5
  324. data/test/rubygems/test_gem_uninstaller.rb +21 -1
  325. data/test/rubygems/test_gem_unsatisfiable_dependency_error.rb +0 -1
  326. data/test/rubygems/test_gem_uri_formatter.rb +0 -1
  327. data/test/rubygems/test_gem_util.rb +6 -11
  328. data/test/rubygems/test_gem_validator.rb +0 -1
  329. data/test/rubygems/test_gem_version.rb +11 -11
  330. data/test/rubygems/test_gem_version_option.rb +0 -1
  331. data/test/rubygems/test_remote_fetch_error.rb +0 -1
  332. data/test/rubygems/test_require.rb +67 -52
  333. data/util/CL2notes +1 -2
  334. data/util/ci +15 -12
  335. data/util/create_certs.rb +6 -7
  336. data/util/create_encrypted_key.rb +0 -1
  337. data/util/patch_with_prs.rb +1 -1
  338. data/util/rubocop +8 -0
  339. data/util/update_bundled_ca_certificates.rb +15 -14
  340. data/util/update_changelog.rb +1 -1
  341. metadata +67 -59
  342. data/.autotest +0 -71
  343. data/.document +0 -5
  344. data/CONTRIBUTING.rdoc +0 -130
  345. data/CVE-2013-4287.txt +0 -35
  346. data/CVE-2013-4363.txt +0 -45
  347. data/CVE-2015-3900.txt +0 -40
  348. data/POLICIES.rdoc +0 -74
  349. data/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA_R3.pem +0 -21
  350. data/test/rubygems/fix_openssl_warnings.rb +0 -13
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  require 'net/http'
3
- require 'thread'
4
3
  require 'time'
5
4
  require 'rubygems/user_interaction'
6
5
 
@@ -11,7 +10,7 @@ class Gem::Request
11
10
 
12
11
  ###
13
12
  # Legacy. This is used in tests.
14
- def self.create_with_proxy uri, request_class, last_modified, proxy # :nodoc:
13
+ def self.create_with_proxy(uri, request_class, last_modified, proxy) # :nodoc:
15
14
  cert_files = get_cert_files
16
15
  proxy ||= get_proxy_from_env(uri.scheme)
17
16
  pool = ConnectionPools.new proxy_uri(proxy), cert_files
@@ -19,7 +18,7 @@ class Gem::Request
19
18
  new(uri, request_class, last_modified, pool.pool_for(uri))
20
19
  end
21
20
 
22
- def self.proxy_uri proxy # :nodoc:
21
+ def self.proxy_uri(proxy) # :nodoc:
23
22
  case proxy
24
23
  when :no_proxy then nil
25
24
  when URI::HTTP then proxy
@@ -52,7 +51,7 @@ class Gem::Request
52
51
  Gem.configuration.ssl_verify_mode || OpenSSL::SSL::VERIFY_PEER
53
52
  store = OpenSSL::X509::Store.new
54
53
 
55
- if Gem.configuration.ssl_client_cert then
54
+ if Gem.configuration.ssl_client_cert
56
55
  pem = File.read Gem.configuration.ssl_client_cert
57
56
  connection.cert = OpenSSL::X509::Certificate.new pem
58
57
  connection.key = OpenSSL::PKey::RSA.new pem
@@ -86,7 +85,7 @@ class Gem::Request
86
85
  'Unable to require openssl, install OpenSSL and rebuild Ruby (preferred) or use non-HTTPS sources')
87
86
  end
88
87
 
89
- def self.verify_certificate store_context
88
+ def self.verify_certificate(store_context)
90
89
  depth = store_context.error_depth
91
90
  error = store_context.error_string
92
91
  number = store_context.error
@@ -99,7 +98,7 @@ class Gem::Request
99
98
  ui.alert_error extra_message if extra_message
100
99
  end
101
100
 
102
- def self.verify_certificate_message error_number, cert
101
+ def self.verify_certificate_message(error_number, cert)
103
102
  return unless cert
104
103
  case error_number
105
104
  when OpenSSL::X509::V_ERR_CERT_HAS_EXPIRED then
@@ -118,9 +117,11 @@ class Gem::Request
118
117
  "Certificate #{cert.subject} has an invalid purpose"
119
118
  when OpenSSL::X509::V_ERR_SELF_SIGNED_CERT_IN_CHAIN then
120
119
  "Root certificate is not trusted (#{cert.subject})"
121
- when OpenSSL::X509::V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY,
122
- OpenSSL::X509::V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE then
120
+ when OpenSSL::X509::V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY then
123
121
  "You must add #{cert.issuer} to your local trusted store"
122
+ when
123
+ OpenSSL::X509::V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE then
124
+ "Cannot verify certificate issued by #{cert.issuer}"
124
125
  end
125
126
  end
126
127
 
@@ -138,7 +139,7 @@ class Gem::Request
138
139
  def fetch
139
140
  request = @request_class.new @uri.request_uri
140
141
 
141
- unless @uri.nil? || @uri.user.nil? || @uri.user.empty? then
142
+ unless @uri.nil? || @uri.user.nil? || @uri.user.empty?
142
143
  request.basic_auth Gem::UriFormatter.new(@uri.user).unescape,
143
144
  Gem::UriFormatter.new(@uri.password).unescape
144
145
  end
@@ -147,7 +148,7 @@ class Gem::Request
147
148
  request.add_field 'Connection', 'keep-alive'
148
149
  request.add_field 'Keep-Alive', '30'
149
150
 
150
- if @last_modified then
151
+ if @last_modified
151
152
  request.add_field 'If-Modified-Since', @last_modified.httpdate
152
153
  end
153
154
 
@@ -160,7 +161,7 @@ class Gem::Request
160
161
  # Returns a proxy URI for the given +scheme+ if one is set in the
161
162
  # environment variables.
162
163
 
163
- def self.get_proxy_from_env scheme = 'http'
164
+ def self.get_proxy_from_env(scheme = 'http')
164
165
  _scheme = scheme.downcase
165
166
  _SCHEME = scheme.upcase
166
167
  env_proxy = ENV["#{_scheme}_proxy"] || ENV["#{_SCHEME}_PROXY"]
@@ -172,7 +173,7 @@ class Gem::Request
172
173
 
173
174
  uri = URI(Gem::UriFormatter.new(env_proxy).normalize)
174
175
 
175
- if uri and uri.user.nil? and uri.password.nil? then
176
+ if uri and uri.user.nil? and uri.password.nil?
176
177
  user = ENV["#{_scheme}_proxy_user"] || ENV["#{_SCHEME}_PROXY_USER"]
177
178
  password = ENV["#{_scheme}_proxy_pass"] || ENV["#{_SCHEME}_PROXY_PASS"]
178
179
 
@@ -183,7 +184,7 @@ class Gem::Request
183
184
  uri
184
185
  end
185
186
 
186
- def perform_request request # :nodoc:
187
+ def perform_request(request) # :nodoc:
187
188
  connection = connection_for @uri
188
189
 
189
190
  retried = false
@@ -275,9 +276,9 @@ class Gem::Request
275
276
  ruby_version += 'dev' if RUBY_PATCHLEVEL == -1
276
277
 
277
278
  ua << " Ruby/#{ruby_version} (#{RUBY_RELEASE_DATE}"
278
- if RUBY_PATCHLEVEL >= 0 then
279
+ if RUBY_PATCHLEVEL >= 0
279
280
  ua << " patchlevel #{RUBY_PATCHLEVEL}"
280
- elsif defined?(RUBY_REVISION) then
281
+ elsif defined?(RUBY_REVISION)
281
282
  ua << " revision #{RUBY_REVISION}"
282
283
  end
283
284
  ua << ")"
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- require 'thread'
3
2
 
4
3
  class Gem::Request::ConnectionPools # :nodoc:
5
4
 
@@ -9,19 +8,19 @@ class Gem::Request::ConnectionPools # :nodoc:
9
8
  attr_accessor :client
10
9
  end
11
10
 
12
- def initialize proxy_uri, cert_files
11
+ def initialize(proxy_uri, cert_files)
13
12
  @proxy_uri = proxy_uri
14
13
  @cert_files = cert_files
15
14
  @pools = {}
16
15
  @pool_mutex = Mutex.new
17
16
  end
18
17
 
19
- def pool_for uri
18
+ def pool_for(uri)
20
19
  http_args = net_http_args(uri, @proxy_uri)
21
20
  key = http_args + [https?(uri)]
22
21
  @pool_mutex.synchronize do
23
22
  @pools[key] ||=
24
- if https? uri then
23
+ if https? uri
25
24
  Gem::Request::HTTPSPool.new(http_args, @cert_files, @proxy_uri)
26
25
  else
27
26
  Gem::Request::HTTPPool.new(http_args, @cert_files, @proxy_uri)
@@ -46,22 +45,35 @@ class Gem::Request::ConnectionPools # :nodoc:
46
45
  env_no_proxy.split(/\s*,\s*/)
47
46
  end
48
47
 
49
- def https? uri
48
+ def https?(uri)
50
49
  uri.scheme.downcase == 'https'
51
50
  end
52
51
 
53
- def no_proxy? host, env_no_proxy
52
+ def no_proxy?(host, env_no_proxy)
54
53
  host = host.downcase
55
54
 
56
55
  env_no_proxy.any? do |pattern|
57
- pattern = pattern.downcase
56
+ env_no_proxy_pattern = pattern.downcase.dup
58
57
 
59
- host[-pattern.length, pattern.length] == pattern or
60
- (pattern.start_with? '.' and pattern[1..-1] == host)
58
+ # Remove dot in front of pattern for wildcard matching
59
+ env_no_proxy_pattern[0] = "" if env_no_proxy_pattern[0] == "."
60
+
61
+ host_tokens = host.split(".")
62
+ pattern_tokens = env_no_proxy_pattern.split(".")
63
+
64
+ intersection = (host_tokens - pattern_tokens) | (pattern_tokens - host_tokens)
65
+
66
+ # When we do the split into tokens we miss a dot character, so add it back if we need it
67
+ missing_dot = intersection.length > 0 ? 1 : 0
68
+ start = intersection.join(".").size + missing_dot
69
+
70
+ no_proxy_host = host[start..-1]
71
+
72
+ env_no_proxy_pattern == no_proxy_host
61
73
  end
62
74
  end
63
75
 
64
- def net_http_args uri, proxy_uri
76
+ def net_http_args(uri, proxy_uri)
65
77
  # URI::Generic#hostname was added in ruby 1.9.3, use it if exists, otherwise
66
78
  # don't support IPv6 literals and use host.
67
79
  hostname = uri.respond_to?(:hostname) ? uri.hostname : uri.host
@@ -69,7 +81,7 @@ class Gem::Request::ConnectionPools # :nodoc:
69
81
 
70
82
  no_proxy = get_no_proxy_from_env
71
83
 
72
- if proxy_uri and not no_proxy?(hostname, no_proxy) then
84
+ if proxy_uri and not no_proxy?(hostname, no_proxy)
73
85
  proxy_hostname = proxy_uri.respond_to?(:hostname) ? proxy_uri.hostname : proxy_uri.host
74
86
  net_http_args + [
75
87
  proxy_hostname,
@@ -77,7 +89,7 @@ class Gem::Request::ConnectionPools # :nodoc:
77
89
  Gem::UriFormatter.new(proxy_uri.user).unescape,
78
90
  Gem::UriFormatter.new(proxy_uri.password).unescape,
79
91
  ]
80
- elsif no_proxy? hostname, no_proxy then
92
+ elsif no_proxy? hostname, no_proxy
81
93
  net_http_args + [nil, nil]
82
94
  else
83
95
  net_http_args
@@ -85,4 +97,3 @@ class Gem::Request::ConnectionPools # :nodoc:
85
97
  end
86
98
 
87
99
  end
88
-
@@ -8,7 +8,7 @@
8
8
  class Gem::Request::HTTPPool # :nodoc:
9
9
  attr_reader :cert_files, :proxy_uri
10
10
 
11
- def initialize http_args, cert_files, proxy_uri
11
+ def initialize(http_args, cert_files, proxy_uri)
12
12
  @http_args = http_args
13
13
  @cert_files = cert_files
14
14
  @proxy_uri = proxy_uri
@@ -20,7 +20,7 @@ class Gem::Request::HTTPPool # :nodoc:
20
20
  @queue.pop || make_connection
21
21
  end
22
22
 
23
- def checkin connection
23
+ def checkin(connection)
24
24
  @queue.push connection
25
25
  end
26
26
 
@@ -39,10 +39,9 @@ class Gem::Request::HTTPPool # :nodoc:
39
39
  setup_connection Gem::Request::ConnectionPools.client.new(*@http_args)
40
40
  end
41
41
 
42
- def setup_connection connection
42
+ def setup_connection(connection)
43
43
  connection.start
44
44
  connection
45
45
  end
46
46
 
47
47
  end
48
-
@@ -2,10 +2,8 @@
2
2
  class Gem::Request::HTTPSPool < Gem::Request::HTTPPool # :nodoc:
3
3
  private
4
4
 
5
- def setup_connection connection
5
+ def setup_connection(connection)
6
6
  Gem::Request.configure_connection_for_https(connection, @cert_files)
7
7
  super
8
8
  end
9
9
  end
10
-
11
-
@@ -91,7 +91,7 @@ class Gem::RequestSet
91
91
  #
92
92
  # set = Gem::RequestSet.new nokogiri, pg
93
93
 
94
- def initialize *deps
94
+ def initialize(*deps)
95
95
  @dependencies = deps
96
96
 
97
97
  @always_install = []
@@ -119,8 +119,8 @@ class Gem::RequestSet
119
119
  ##
120
120
  # Declare that a gem of name +name+ with +reqs+ requirements is needed.
121
121
 
122
- def gem name, *reqs
123
- if dep = @dependency_names[name] then
122
+ def gem(name, *reqs)
123
+ if dep = @dependency_names[name]
124
124
  dep.requirement.concat reqs
125
125
  else
126
126
  dep = Gem::Dependency.new name, *reqs
@@ -132,7 +132,7 @@ class Gem::RequestSet
132
132
  ##
133
133
  # Add +deps+ Gem::Dependency objects to the set.
134
134
 
135
- def import deps
135
+ def import(deps)
136
136
  @dependencies.concat deps
137
137
  end
138
138
 
@@ -143,7 +143,7 @@ class Gem::RequestSet
143
143
  # The +installer+ will be +nil+ if a gem matching the request was already
144
144
  # installed.
145
145
 
146
- def install options, &block # :yields: request, installer
146
+ def install(options, &block) # :yields: request, installer
147
147
  if dir = options[:install_dir]
148
148
  requests = install_into dir, false, options, &block
149
149
  return requests
@@ -152,12 +152,39 @@ class Gem::RequestSet
152
152
  @prerelease = options[:prerelease]
153
153
 
154
154
  requests = []
155
+ download_queue = Queue.new
155
156
 
157
+ # Create a thread-safe list of gems to download
156
158
  sorted_requests.each do |req|
157
- if req.installed? then
159
+ download_queue << req
160
+ end
161
+
162
+ # Create N threads in a pool, have them download all the gems
163
+ threads = Gem.configuration.concurrent_downloads.times.map do
164
+ # When a thread pops this item, it knows to stop running. The symbol
165
+ # is queued here so that there will be one symbol per thread.
166
+ download_queue << :stop
167
+
168
+ Thread.new do
169
+ # The pop method will block waiting for items, so the only way
170
+ # to stop a thread from running is to provide a final item that
171
+ # means the thread should stop.
172
+ while req = download_queue.pop
173
+ break if req == :stop
174
+ req.spec.download options unless req.installed?
175
+ end
176
+ end
177
+ end
178
+
179
+ # Wait for all the downloads to finish before continuing
180
+ threads.each(&:value)
181
+
182
+ # Install requested gems after they have been downloaded
183
+ sorted_requests.each do |req|
184
+ if req.installed?
158
185
  req.spec.spec.build_extensions
159
186
 
160
- if @always_install.none? { |spec| spec == req.spec.spec } then
187
+ if @always_install.none? { |spec| spec == req.spec.spec }
161
188
  yield req, nil if block_given?
162
189
  next
163
190
  end
@@ -203,7 +230,7 @@ class Gem::RequestSet
203
230
  # If +:without_groups+ is given in the +options+, those groups in the gem
204
231
  # dependencies file are not used. See Gem::Installer for other +options+.
205
232
 
206
- def install_from_gemdeps options, &block
233
+ def install_from_gemdeps(options, &block)
207
234
  gemdeps = options[:gemdeps]
208
235
 
209
236
  @install_dir = options[:install_dir] || Gem.dir
@@ -228,7 +255,7 @@ class Gem::RequestSet
228
255
  else
229
256
  installed = install options, &block
230
257
 
231
- if options.fetch :lock, true then
258
+ if options.fetch :lock, true
232
259
  lockfile =
233
260
  Gem::RequestSet::Lockfile.build self, gemdeps, gem_deps_api.dependencies
234
261
  lockfile.write
@@ -238,7 +265,7 @@ class Gem::RequestSet
238
265
  end
239
266
  end
240
267
 
241
- def install_into dir, force = true, options = {}
268
+ def install_into(dir, force = true, options = {})
242
269
  gem_home, ENV['GEM_HOME'] = ENV['GEM_HOME'], dir
243
270
 
244
271
  existing = force ? [] : specs_in(dir)
@@ -256,7 +283,7 @@ class Gem::RequestSet
256
283
  sorted_requests.each do |request|
257
284
  spec = request.spec
258
285
 
259
- if existing.find { |s| s.full_name == spec.full_name } then
286
+ if existing.find { |s| s.full_name == spec.full_name }
260
287
  yield request, nil if block_given?
261
288
  next
262
289
  end
@@ -278,7 +305,7 @@ class Gem::RequestSet
278
305
  ##
279
306
  # Call hooks on installed gems
280
307
 
281
- def install_hooks requests, options
308
+ def install_hooks(requests, options)
282
309
  specs = requests.map do |request|
283
310
  case request
284
311
  when Gem::Resolver::ActivationRequest then
@@ -300,7 +327,7 @@ class Gem::RequestSet
300
327
  ##
301
328
  # Load a dependency management file.
302
329
 
303
- def load_gemdeps path, without_groups = [], installing = false
330
+ def load_gemdeps(path, without_groups = [], installing = false)
304
331
  @git_set = Gem::Resolver::GitSet.new
305
332
  @vendor_set = Gem::Resolver::VendorSet.new
306
333
  @source_set = Gem::Resolver::SourceSet.new
@@ -321,29 +348,29 @@ class Gem::RequestSet
321
348
  gf.load
322
349
  end
323
350
 
324
- def pretty_print q # :nodoc:
351
+ def pretty_print(q) # :nodoc:
325
352
  q.group 2, '[RequestSet:', ']' do
326
353
  q.breakable
327
354
 
328
- if @remote then
355
+ if @remote
329
356
  q.text 'remote'
330
357
  q.breakable
331
358
  end
332
359
 
333
- if @prerelease then
360
+ if @prerelease
334
361
  q.text 'prerelease'
335
362
  q.breakable
336
363
  end
337
364
 
338
- if @development_shallow then
365
+ if @development_shallow
339
366
  q.text 'shallow development'
340
367
  q.breakable
341
- elsif @development then
368
+ elsif @development
342
369
  q.text 'development'
343
370
  q.breakable
344
371
  end
345
372
 
346
- if @soft_missing then
373
+ if @soft_missing
347
374
  q.text 'soft missing'
348
375
  end
349
376
 
@@ -367,7 +394,7 @@ class Gem::RequestSet
367
394
  # Resolve the requested dependencies and return an Array of Specification
368
395
  # objects to be activated.
369
396
 
370
- def resolve set = Gem::Resolver::BestSet.new
397
+ def resolve(set = Gem::Resolver::BestSet.new)
371
398
  @sets << set
372
399
  @sets << @git_set
373
400
  @sets << @vendor_set
@@ -416,17 +443,17 @@ class Gem::RequestSet
416
443
  @specs ||= @requests.map { |r| r.full_spec }
417
444
  end
418
445
 
419
- def specs_in dir
420
- Dir["#{dir}/specifications/*.gemspec"].map do |g|
446
+ def specs_in(dir)
447
+ Gem::Util.glob_files_in_dir("*.gemspec", File.join(dir, "specifications")).map do |g|
421
448
  Gem::Specification.load g
422
449
  end
423
450
  end
424
451
 
425
- def tsort_each_node &block # :nodoc:
452
+ def tsort_each_node(&block) # :nodoc:
426
453
  @requests.each(&block)
427
454
  end
428
455
 
429
- def tsort_each_child node # :nodoc:
456
+ def tsort_each_child(node) # :nodoc:
430
457
  node.spec.dependencies.each do |dep|
431
458
  next if dep.type == :development and not @development
432
459
 
@@ -434,7 +461,7 @@ class Gem::RequestSet
434
461
  dep.match? r.spec.name, r.spec.version, @prerelease
435
462
  }
436
463
 
437
- unless match then
464
+ unless match
438
465
  next if dep.type == :development and @development_shallow
439
466
  next if @soft_missing
440
467
  raise Gem::DependencyError,