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
@@ -2,13 +2,20 @@
2
2
 
3
3
  module Bundler
4
4
  class Injector
5
+ INJECTED_GEMS = "injected gems".freeze
6
+
5
7
  def self.inject(new_deps, options = {})
6
8
  injector = new(new_deps, options)
7
9
  injector.inject(Bundler.default_gemfile, Bundler.default_lockfile)
8
10
  end
9
11
 
10
- def initialize(new_deps, options = {})
11
- @new_deps = new_deps
12
+ def self.remove(gems, options = {})
13
+ injector = new(gems, options)
14
+ injector.remove(Bundler.default_gemfile, Bundler.default_lockfile)
15
+ end
16
+
17
+ def initialize(deps, options = {})
18
+ @deps = deps
12
19
  @options = options
13
20
  end
14
21
 
@@ -28,18 +35,19 @@ module Bundler
28
35
  builder.eval_gemfile(gemfile_path)
29
36
 
30
37
  # don't inject any gems that are already in the Gemfile
31
- @new_deps -= builder.dependencies
38
+ @deps -= builder.dependencies
32
39
 
33
40
  # add new deps to the end of the in-memory Gemfile
34
- # Set conservative versioning to false because we want to let the resolver resolve the version first
35
- builder.eval_gemfile("injected gems", build_gem_lines(false)) if @new_deps.any?
41
+ # Set conservative versioning to false because
42
+ # we want to let the resolver resolve the version first
43
+ builder.eval_gemfile(INJECTED_GEMS, build_gem_lines(false)) if @deps.any?
36
44
 
37
45
  # resolve to see if the new deps broke anything
38
46
  @definition = builder.to_definition(lockfile_path, {})
39
47
  @definition.resolve_remotely!
40
48
 
41
49
  # since nothing broke, we can add those gems to the gemfile
42
- append_to(gemfile_path, build_gem_lines(@options[:conservative_versioning])) if @new_deps.any?
50
+ append_to(gemfile_path, build_gem_lines(@options[:conservative_versioning])) if @deps.any?
43
51
 
44
52
  # since we resolved successfully, write out the lockfile
45
53
  @definition.lock(Bundler.default_lockfile)
@@ -48,7 +56,21 @@ module Bundler
48
56
  Bundler.reset_paths!
49
57
 
50
58
  # return an array of the deps that we added
51
- @new_deps
59
+ @deps
60
+ end
61
+ end
62
+
63
+ # @param [Pathname] gemfile_path The Gemfile from which to remove dependencies.
64
+ # @param [Pathname] lockfile_path The lockfile from which to remove dependencies.
65
+ # @return [Array]
66
+ def remove(gemfile_path, lockfile_path)
67
+ # remove gems from each gemfiles we have
68
+ Bundler.definition.gemfiles.each do |path|
69
+ deps = remove_deps(path)
70
+
71
+ show_warning("No gems were removed from the gemfile.") if deps.empty?
72
+
73
+ deps.each {|dep| Bundler.ui.confirm "#{SharedHelpers.pretty_dependency(dep, false)} was removed." }
52
74
  end
53
75
  end
54
76
 
@@ -61,11 +83,21 @@ module Bundler
61
83
  seg_end_index = version >= Gem::Version.new("1.0") ? 1 : 2
62
84
 
63
85
  prerelease_suffix = version.to_s.gsub(version.release.to_s, "") if version.prerelease?
64
- "~> #{segments[0..seg_end_index].join(".")}#{prerelease_suffix}"
86
+ "#{version_prefix}#{segments[0..seg_end_index].join(".")}#{prerelease_suffix}"
87
+ end
88
+
89
+ def version_prefix
90
+ if @options[:strict]
91
+ "= "
92
+ elsif @options[:optimistic]
93
+ ">= "
94
+ else
95
+ "~> "
96
+ end
65
97
  end
66
98
 
67
99
  def build_gem_lines(conservative_versioning)
68
- @new_deps.map do |d|
100
+ @deps.map do |d|
69
101
  name = d.name.dump
70
102
 
71
103
  requirement = if conservative_versioning
@@ -90,5 +122,132 @@ module Bundler
90
122
  f.puts new_gem_lines
91
123
  end
92
124
  end
125
+
126
+ # evalutes a gemfile to remove the specified gem
127
+ # from it.
128
+ def remove_deps(gemfile_path)
129
+ initial_gemfile = IO.readlines(gemfile_path)
130
+
131
+ Bundler.ui.info "Removing gems from #{gemfile_path}"
132
+
133
+ # evaluate the Gemfile we have
134
+ builder = Dsl.new
135
+ builder.eval_gemfile(gemfile_path)
136
+
137
+ removed_deps = remove_gems_from_dependencies(builder, @deps, gemfile_path)
138
+
139
+ # abort the opertion if no gems were removed
140
+ # no need to operate on gemfile furthur
141
+ return [] if removed_deps.empty?
142
+
143
+ cleaned_gemfile = remove_gems_from_gemfile(@deps, gemfile_path)
144
+
145
+ SharedHelpers.write_to_gemfile(gemfile_path, cleaned_gemfile)
146
+
147
+ # check for errors
148
+ # including extra gems being removed
149
+ # or some gems not being removed
150
+ # and return the actual removed deps
151
+ cross_check_for_errors(gemfile_path, builder.dependencies, removed_deps, initial_gemfile)
152
+ end
153
+
154
+ # @param [Dsl] builder Dsl object of current Gemfile.
155
+ # @param [Array] gems Array of names of gems to be removed.
156
+ # @param [Pathname] path of the Gemfile
157
+ # @return [Array] removed_deps Array of removed dependencies.
158
+ def remove_gems_from_dependencies(builder, gems, gemfile_path)
159
+ removed_deps = []
160
+
161
+ gems.each do |gem_name|
162
+ deleted_dep = builder.dependencies.find {|d| d.name == gem_name }
163
+
164
+ if deleted_dep.nil?
165
+ raise GemfileError, "`#{gem_name}` is not specified in #{gemfile_path} so it could not be removed."
166
+ end
167
+
168
+ builder.dependencies.delete(deleted_dep)
169
+
170
+ removed_deps << deleted_dep
171
+ end
172
+
173
+ removed_deps
174
+ end
175
+
176
+ # @param [Array] gems Array of names of gems to be removed.
177
+ # @param [Pathname] gemfile_path The Gemfile from which to remove dependencies.
178
+ def remove_gems_from_gemfile(gems, gemfile_path)
179
+ patterns = /gem\s+(['"])#{Regexp.union(gems)}\1|gem\s*\((['"])#{Regexp.union(gems)}\2\)/
180
+
181
+ # remove lines which match the regex
182
+ new_gemfile = IO.readlines(gemfile_path).reject {|line| line.match(patterns) }
183
+
184
+ # remove lone \n and append them with other strings
185
+ new_gemfile.each_with_index do |_line, index|
186
+ if new_gemfile[index + 1] == "\n"
187
+ new_gemfile[index] += new_gemfile[index + 1]
188
+ new_gemfile.delete_at(index + 1)
189
+ end
190
+ end
191
+
192
+ %w[group source env install_if].each {|block| remove_nested_blocks(new_gemfile, block) }
193
+
194
+ new_gemfile.join.chomp
195
+ end
196
+
197
+ # @param [Array] gemfile Array of gemfile contents.
198
+ # @param [String] block_name Name of block name to look for.
199
+ def remove_nested_blocks(gemfile, block_name)
200
+ nested_blocks = 0
201
+
202
+ # count number of nested blocks
203
+ gemfile.each_with_index {|line, index| nested_blocks += 1 if !gemfile[index + 1].nil? && gemfile[index + 1].include?(block_name) && line.include?(block_name) }
204
+
205
+ while nested_blocks >= 0
206
+ nested_blocks -= 1
207
+
208
+ gemfile.each_with_index do |line, index|
209
+ next unless !line.nil? && line.include?(block_name)
210
+ if gemfile[index + 1] =~ /^\s*end\s*$/
211
+ gemfile[index] = nil
212
+ gemfile[index + 1] = nil
213
+ end
214
+ end
215
+
216
+ gemfile.compact!
217
+ end
218
+ end
219
+
220
+ # @param [Pathname] gemfile_path The Gemfile from which to remove dependencies.
221
+ # @param [Array] original_deps Array of original dependencies.
222
+ # @param [Array] removed_deps Array of removed dependencies.
223
+ # @param [Array] initial_gemfile Contents of original Gemfile before any operation.
224
+ def cross_check_for_errors(gemfile_path, original_deps, removed_deps, initial_gemfile)
225
+ # evalute the new gemfile to look for any failure cases
226
+ builder = Dsl.new
227
+ builder.eval_gemfile(gemfile_path)
228
+
229
+ # record gems which were removed but not requested
230
+ extra_removed_gems = original_deps - builder.dependencies
231
+
232
+ # if some extra gems were removed then raise error
233
+ # and revert Gemfile to original
234
+ unless extra_removed_gems.empty?
235
+ SharedHelpers.write_to_gemfile(gemfile_path, initial_gemfile.join)
236
+
237
+ raise InvalidOption, "Gems could not be removed. #{extra_removed_gems.join(", ")} would also have been removed. Bundler cannot continue."
238
+ end
239
+
240
+ # record gems which could not be removed due to some reasons
241
+ errored_deps = builder.dependencies.select {|d| d.gemfile == gemfile_path } & removed_deps.select {|d| d.gemfile == gemfile_path }
242
+
243
+ show_warning "#{errored_deps.map(&:name).join(", ")} could not be removed." unless errored_deps.empty?
244
+
245
+ # return actual removed dependencies
246
+ removed_deps - errored_deps
247
+ end
248
+
249
+ def show_warning(message)
250
+ Bundler.ui.info Bundler.ui.add_color(message, :yellow)
251
+ end
93
252
  end
94
253
  end
@@ -21,8 +21,9 @@ module Bundler
21
21
  # For more information see the #run method on this class.
22
22
  def self.install(root, definition, options = {})
23
23
  installer = new(root, definition)
24
- Plugin.hook("before-install-all", definition.dependencies)
24
+ Plugin.hook(Plugin::Events::GEM_BEFORE_INSTALL_ALL, definition.dependencies)
25
25
  installer.run(options)
26
+ Plugin.hook(Plugin::Events::GEM_AFTER_INSTALL_ALL, definition.dependencies)
26
27
  installer
27
28
  end
28
29
 
@@ -192,14 +193,36 @@ module Bundler
192
193
  # installation is SO MUCH FASTER. so we let people opt in.
193
194
  def install(options)
194
195
  force = options["force"]
195
- jobs = options.delete(:jobs) do
196
- if can_install_in_parallel?
197
- [Bundler.settings[:jobs].to_i - 1, 1].max
196
+ jobs = installation_parallelization(options)
197
+ install_in_parallel jobs, options[:standalone], force
198
+ end
199
+
200
+ def installation_parallelization(options)
201
+ if jobs = options.delete(:jobs)
202
+ return jobs
203
+ end
204
+
205
+ return 1 unless can_install_in_parallel?
206
+
207
+ auto_config_jobs = Bundler.feature_flag.auto_config_jobs?
208
+ if jobs = Bundler.settings[:jobs]
209
+ if auto_config_jobs
210
+ jobs
198
211
  else
199
- 1
212
+ [jobs.pred, 1].max
200
213
  end
214
+ elsif auto_config_jobs
215
+ processor_count
216
+ else
217
+ 1
201
218
  end
202
- install_in_parallel jobs, options[:standalone], force
219
+ end
220
+
221
+ def processor_count
222
+ require "etc"
223
+ Etc.nprocessors
224
+ rescue
225
+ 1
203
226
  end
204
227
 
205
228
  def load_plugins
@@ -87,6 +87,7 @@ module Bundler
87
87
  @force = force
88
88
  @specs = all_specs.map {|s| SpecInstallation.new(s) }
89
89
  @spec_set = all_specs
90
+ @rake = @specs.find {|s| s.name == "rake" }
90
91
  end
91
92
 
92
93
  def call
@@ -155,6 +156,7 @@ module Bundler
155
156
  end
156
157
 
157
158
  def do_install(spec_install, worker_num)
159
+ Plugin.hook(Plugin::Events::GEM_BEFORE_INSTALL, spec_install)
158
160
  gem_installer = Bundler::GemInstaller.new(
159
161
  spec_install.spec, @installer, @standalone, worker_num, @force
160
162
  )
@@ -170,6 +172,7 @@ module Bundler
170
172
  spec_install.state = :failed
171
173
  spec_install.error = "#{message}\n\n#{require_tree_for_spec(spec_install.spec)}"
172
174
  end
175
+ Plugin.hook(Plugin::Events::GEM_AFTER_INSTALL, spec_install)
173
176
  spec_install
174
177
  end
175
178
 
@@ -218,6 +221,8 @@ module Bundler
218
221
  # are installed.
219
222
  def enqueue_specs
220
223
  @specs.select(&:ready_to_enqueue?).each do |spec|
224
+ next if @rake && !@rake.installed? && spec.name != @rake.name
225
+
221
226
  if spec.dependencies_installed? @specs
222
227
  spec.state = :enqueued
223
228
  worker_pool.enq spec
@@ -5,6 +5,7 @@ require "bundler/plugin/api"
5
5
  module Bundler
6
6
  module Plugin
7
7
  autoload :DSL, "bundler/plugin/dsl"
8
+ autoload :Events, "bundler/plugin/events"
8
9
  autoload :Index, "bundler/plugin/index"
9
10
  autoload :Installer, "bundler/plugin/installer"
10
11
  autoload :SourceList, "bundler/plugin/source_list"
@@ -80,8 +81,8 @@ module Bundler
80
81
 
81
82
  # The directory root for all plugin related data
82
83
  #
83
- # Points to root in app_config_path if ran in an app else points to the one
84
- # in user_bundle_path
84
+ # If run in an app, points to local root, in app_config_path
85
+ # Otherwise, points to global root, in Bundler.user_bundle_path("plugin")
85
86
  def root
86
87
  @root ||= if SharedHelpers.in_bundle?
87
88
  local_root
@@ -96,7 +97,7 @@ module Bundler
96
97
 
97
98
  # The global directory root for all plugin related data
98
99
  def global_root
99
- Bundler.user_bundle_path.join("plugin")
100
+ Bundler.user_bundle_path("plugin")
100
101
  end
101
102
 
102
103
  # The cache directory for plugin stuffs
@@ -155,6 +156,9 @@ module Bundler
155
156
  # To be called via the API to register a hooks and corresponding block that
156
157
  # will be called to handle the hook
157
158
  def add_hook(event, &block)
159
+ unless Events.defined_event?(event)
160
+ raise ArgumentError, "Event '#{event}' not defined in Bundler::Plugin::Events"
161
+ end
158
162
  @hooks_by_event[event.to_s] << block
159
163
  end
160
164
 
@@ -166,6 +170,9 @@ module Bundler
166
170
  # @param [String] event
167
171
  def hook(event, *args, &arg_blk)
168
172
  return unless Bundler.feature_flag.plugins?
173
+ unless Events.defined_event?(event)
174
+ raise ArgumentError, "Event '#{event}' not defined in Bundler::Plugin::Events"
175
+ end
169
176
 
170
177
  plugins = index.hook_plugins(event)
171
178
  return unless plugins.any?
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ module Plugin
5
+ module Events
6
+ def self.define(const, event)
7
+ const = const.to_sym.freeze
8
+ if const_defined?(const) && const_get(const) != event
9
+ raise ArgumentError, "Attempting to reassign #{const} to a different value"
10
+ end
11
+ const_set(const, event) unless const_defined?(const)
12
+ @events ||= {}
13
+ @events[event] = const
14
+ end
15
+ private_class_method :define
16
+
17
+ def self.reset
18
+ @events.each_value do |const|
19
+ remove_const(const)
20
+ end
21
+ @events = nil
22
+ end
23
+ private_class_method :reset
24
+
25
+ # Check if an event has been defined
26
+ # @param event [String] An event to check
27
+ # @return [Boolean] A boolean indicating if the event has been defined
28
+ def self.defined_event?(event)
29
+ @events ||= {}
30
+ @events.key?(event)
31
+ end
32
+
33
+ # @!parse
34
+ # A hook called before each individual gem is installed
35
+ # Includes a Bundler::ParallelInstaller::SpecInstallation.
36
+ # No state, error, post_install_message will be present as nothing has installed yet
37
+ # GEM_BEFORE_INSTALL = "before-install"
38
+ define :GEM_BEFORE_INSTALL, "before-install"
39
+
40
+ # @!parse
41
+ # A hook called after each individual gem is installed
42
+ # Includes a Bundler::ParallelInstaller::SpecInstallation.
43
+ # - If state is failed, an error will be present.
44
+ # - If state is success, a post_install_message may be present.
45
+ # GEM_AFTER_INSTALL = "after-install"
46
+ define :GEM_AFTER_INSTALL, "after-install"
47
+
48
+ # @!parse
49
+ # A hook called before any gems install
50
+ # Includes an Array of Bundler::Dependency objects
51
+ # GEM_BEFORE_INSTALL_ALL = "before-install-all"
52
+ define :GEM_BEFORE_INSTALL_ALL, "before-install-all"
53
+
54
+ # @!parse
55
+ # A hook called after any gems install
56
+ # Includes an Array of Bundler::Dependency objects
57
+ # GEM_AFTER_INSTALL_ALL = "after-install-all"
58
+ define :GEM_AFTER_INSTALL_ALL, "after-install-all"
59
+ end
60
+ end
61
+ end
@@ -39,7 +39,7 @@ module Bundler
39
39
  @gem_version_promoter = gem_version_promoter
40
40
  @allow_bundler_dependency_conflicts = Bundler.feature_flag.allow_bundler_dependency_conflicts?
41
41
  @lockfile_uses_separate_rubygems_sources = Bundler.feature_flag.lockfile_uses_separate_rubygems_sources?
42
- @use_gvp = !@gem_version_promoter.major?
42
+ @use_gvp = Bundler.feature_flag.use_gem_version_promoter_for_major_updates? || !@gem_version_promoter.major?
43
43
  end
44
44
 
45
45
  def start(requirements)
@@ -137,7 +137,7 @@ module Bundler
137
137
  end
138
138
  # GVP handles major itself, but it's still a bit risky to trust it with it
139
139
  # until we get it settled with new behavior. For 2.x it can take over all cases.
140
- if @gem_version_promoter.major?
140
+ if !@use_gvp
141
141
  spec_groups
142
142
  else
143
143
  @gem_version_promoter.sort_versions(dependency, spec_groups)
@@ -163,6 +163,7 @@ module Bundler
163
163
  gem_dirs = Dir["#{Gem.dir}/gems/*"]
164
164
  gem_files = Dir["#{Gem.dir}/cache/*.gem"]
165
165
  gemspec_files = Dir["#{Gem.dir}/specifications/*.gemspec"]
166
+ extension_dirs = Dir["#{Gem.dir}/extensions/*/*/*"]
166
167
  spec_gem_paths = []
167
168
  # need to keep git sources around
168
169
  spec_git_paths = @definition.spec_git_paths
@@ -170,6 +171,7 @@ module Bundler
170
171
  spec_gem_executables = []
171
172
  spec_cache_paths = []
172
173
  spec_gemspec_paths = []
174
+ spec_extension_paths = []
173
175
  specs.each do |spec|
174
176
  spec_gem_paths << spec.full_gem_path
175
177
  # need to check here in case gems are nested like for the rails git repo
@@ -181,6 +183,7 @@ module Bundler
181
183
  end
182
184
  spec_cache_paths << spec.cache_file
183
185
  spec_gemspec_paths << spec.spec_file
186
+ spec_extension_paths << spec.extension_dir if spec.respond_to?(:extension_dir)
184
187
  spec_git_cache_dirs << spec.source.cache_path.to_s if spec.source.is_a?(Bundler::Source::Git)
185
188
  end
186
189
  spec_gem_paths.uniq!
@@ -192,6 +195,7 @@ module Bundler
192
195
  stale_gem_dirs = gem_dirs - spec_gem_paths
193
196
  stale_gem_files = gem_files - spec_cache_paths
194
197
  stale_gemspec_files = gemspec_files - spec_gemspec_paths
198
+ stale_extension_dirs = extension_dirs - spec_extension_paths
195
199
 
196
200
  removed_stale_gem_dirs = stale_gem_dirs.collect {|dir| remove_dir(dir, dry_run) }
197
201
  removed_stale_git_dirs = stale_git_dirs.collect {|dir| remove_dir(dir, dry_run) }
@@ -204,8 +208,10 @@ module Bundler
204
208
  FileUtils.rm(file) if File.exist?(file)
205
209
  end
206
210
  end
207
- stale_git_cache_dirs.each do |cache_dir|
208
- SharedHelpers.filesystem_access(cache_dir) do |dir|
211
+
212
+ stale_dirs = stale_git_cache_dirs + stale_extension_dirs
213
+ stale_dirs.each do |stale_dir|
214
+ SharedHelpers.filesystem_access(stale_dir) do |dir|
209
215
  FileUtils.rm_rf(dir) if File.exist?(dir)
210
216
  end
211
217
  end