bundler 1.9.0 → 1.17.3

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

Potentially problematic release.


This version of bundler might be problematic. Click here for more details.

Files changed (328) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +1157 -6
  3. data/README.md +33 -6
  4. data/bundler.gemspec +51 -18
  5. data/exe/bundle +31 -0
  6. data/{bin → exe}/bundle_ruby +10 -6
  7. data/exe/bundler +4 -0
  8. data/lib/bundler.rb +326 -207
  9. data/lib/bundler/build_metadata.rb +53 -0
  10. data/lib/bundler/capistrano.rb +9 -3
  11. data/lib/bundler/cli.rb +522 -141
  12. data/lib/bundler/cli/add.rb +35 -0
  13. data/lib/bundler/cli/binstubs.rb +22 -11
  14. data/lib/bundler/cli/cache.rb +7 -6
  15. data/lib/bundler/cli/check.rb +11 -8
  16. data/lib/bundler/cli/clean.rb +7 -8
  17. data/lib/bundler/cli/common.rb +53 -7
  18. data/lib/bundler/cli/config.rb +84 -49
  19. data/lib/bundler/cli/console.rb +13 -8
  20. data/lib/bundler/cli/doctor.rb +140 -0
  21. data/lib/bundler/cli/exec.rb +77 -16
  22. data/lib/bundler/cli/gem.rb +120 -52
  23. data/lib/bundler/cli/info.rb +50 -0
  24. data/lib/bundler/cli/init.rb +21 -7
  25. data/lib/bundler/cli/inject.rb +37 -10
  26. data/lib/bundler/cli/install.rb +139 -78
  27. data/lib/bundler/cli/issue.rb +40 -0
  28. data/lib/bundler/cli/list.rb +58 -0
  29. data/lib/bundler/cli/lock.rb +63 -0
  30. data/lib/bundler/cli/open.rb +9 -6
  31. data/lib/bundler/cli/outdated.rb +221 -35
  32. data/lib/bundler/cli/package.rb +11 -7
  33. data/lib/bundler/cli/platform.rb +7 -4
  34. data/lib/bundler/cli/plugin.rb +24 -0
  35. data/lib/bundler/cli/pristine.rb +47 -0
  36. data/lib/bundler/cli/remove.rb +18 -0
  37. data/lib/bundler/cli/show.rb +11 -10
  38. data/lib/bundler/cli/update.rb +47 -29
  39. data/lib/bundler/cli/viz.rb +12 -8
  40. data/lib/bundler/compact_index_client.rb +109 -0
  41. data/lib/bundler/compact_index_client/cache.rb +118 -0
  42. data/lib/bundler/compact_index_client/updater.rb +116 -0
  43. data/lib/bundler/compatibility_guard.rb +14 -0
  44. data/lib/bundler/constants.rb +3 -1
  45. data/lib/bundler/current_ruby.rb +47 -137
  46. data/lib/bundler/definition.rb +599 -230
  47. data/lib/bundler/dep_proxy.rb +15 -10
  48. data/lib/bundler/dependency.rb +54 -25
  49. data/lib/bundler/deployment.rb +12 -2
  50. data/lib/bundler/deprecate.rb +33 -4
  51. data/lib/bundler/dsl.rb +383 -99
  52. data/lib/bundler/endpoint_specification.rb +72 -7
  53. data/lib/bundler/env.rb +121 -41
  54. data/lib/bundler/environment_preserver.rb +59 -0
  55. data/lib/bundler/errors.rb +158 -0
  56. data/lib/bundler/feature_flag.rb +74 -0
  57. data/lib/bundler/fetcher.rb +171 -280
  58. data/lib/bundler/fetcher/base.rb +52 -0
  59. data/lib/bundler/fetcher/compact_index.rb +126 -0
  60. data/lib/bundler/fetcher/dependency.rb +82 -0
  61. data/lib/bundler/fetcher/downloader.rb +84 -0
  62. data/lib/bundler/fetcher/index.rb +52 -0
  63. data/lib/bundler/friendly_errors.rb +113 -58
  64. data/lib/bundler/gem_helper.rb +73 -46
  65. data/lib/bundler/gem_helpers.rb +85 -9
  66. data/lib/bundler/gem_remote_fetcher.rb +43 -0
  67. data/lib/bundler/gem_tasks.rb +6 -1
  68. data/lib/bundler/gem_version_promoter.rb +190 -0
  69. data/lib/bundler/gemdeps.rb +29 -0
  70. data/lib/bundler/graph.rb +32 -49
  71. data/lib/bundler/index.rb +79 -67
  72. data/lib/bundler/injector.rb +219 -30
  73. data/lib/bundler/inline.rb +74 -0
  74. data/lib/bundler/installer.rb +191 -206
  75. data/lib/bundler/installer/gem_installer.rb +85 -0
  76. data/lib/bundler/installer/parallel_installer.rb +233 -0
  77. data/lib/bundler/installer/standalone.rb +53 -0
  78. data/lib/bundler/lazy_specification.rb +53 -13
  79. data/lib/bundler/lockfile_generator.rb +95 -0
  80. data/lib/bundler/lockfile_parser.rb +157 -62
  81. data/lib/bundler/match_platform.rb +15 -4
  82. data/lib/bundler/mirror.rb +223 -0
  83. data/lib/bundler/plugin.rb +292 -0
  84. data/lib/bundler/plugin/api.rb +81 -0
  85. data/lib/bundler/plugin/api/source.rb +306 -0
  86. data/lib/bundler/plugin/dsl.rb +53 -0
  87. data/lib/bundler/plugin/events.rb +61 -0
  88. data/lib/bundler/plugin/index.rb +162 -0
  89. data/lib/bundler/plugin/installer.rb +96 -0
  90. data/lib/bundler/plugin/installer/git.rb +38 -0
  91. data/lib/bundler/plugin/installer/rubygems.rb +27 -0
  92. data/lib/bundler/plugin/source_list.rb +27 -0
  93. data/lib/bundler/process_lock.rb +24 -0
  94. data/lib/bundler/psyched_yaml.rb +17 -6
  95. data/lib/bundler/remote_specification.rb +68 -11
  96. data/lib/bundler/resolver.rb +263 -229
  97. data/lib/bundler/resolver/spec_group.rb +106 -0
  98. data/lib/bundler/retry.rb +25 -19
  99. data/lib/bundler/ruby_dsl.rb +9 -2
  100. data/lib/bundler/ruby_version.rb +101 -66
  101. data/lib/bundler/rubygems_ext.rb +77 -37
  102. data/lib/bundler/rubygems_gem_installer.rb +106 -0
  103. data/lib/bundler/rubygems_integration.rb +450 -163
  104. data/lib/bundler/runtime.rb +133 -103
  105. data/lib/bundler/settings.rb +344 -83
  106. data/lib/bundler/settings/validator.rb +102 -0
  107. data/lib/bundler/setup.rb +7 -3
  108. data/lib/bundler/shared_helpers.rb +284 -54
  109. data/lib/bundler/similarity_detector.rb +21 -21
  110. data/lib/bundler/source.rb +68 -15
  111. data/lib/bundler/source/gemspec.rb +18 -0
  112. data/lib/bundler/source/git.rb +90 -55
  113. data/lib/bundler/source/git/git_proxy.rb +135 -35
  114. data/lib/bundler/source/metadata.rb +62 -0
  115. data/lib/bundler/source/path.rb +84 -61
  116. data/lib/bundler/source/path/installer.rb +53 -17
  117. data/lib/bundler/source/rubygems.rb +282 -122
  118. data/lib/bundler/source/rubygems/remote.rb +69 -0
  119. data/lib/bundler/source_list.rb +107 -22
  120. data/lib/bundler/spec_set.rb +83 -45
  121. data/lib/bundler/ssl_certs/certificate_manager.rb +8 -7
  122. data/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +21 -0
  123. data/lib/bundler/ssl_certs/{DigiCertHighAssuranceEVRootCA.pem → rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem} +0 -0
  124. data/lib/bundler/ssl_certs/{AddTrustExternalCARoot-2048.pem → rubygems.org/AddTrustExternalCARoot.pem} +0 -0
  125. data/lib/bundler/stub_specification.rb +108 -0
  126. data/lib/bundler/templates/.document +1 -0
  127. data/lib/bundler/templates/Executable +19 -6
  128. data/lib/bundler/templates/Executable.bundler +105 -0
  129. data/lib/bundler/templates/Executable.standalone +6 -4
  130. data/lib/bundler/templates/Gemfile +4 -1
  131. data/lib/bundler/templates/gems.rb +8 -0
  132. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +68 -7
  133. data/lib/bundler/templates/newgem/Gemfile.tt +4 -2
  134. data/lib/bundler/templates/newgem/LICENSE.txt.tt +1 -1
  135. data/lib/bundler/templates/newgem/README.md.tt +19 -11
  136. data/lib/bundler/templates/newgem/Rakefile.tt +10 -6
  137. data/lib/bundler/templates/newgem/bin/console.tt +1 -1
  138. data/lib/bundler/templates/newgem/bin/setup.tt +2 -1
  139. data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +4 -4
  140. data/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +3 -3
  141. data/lib/bundler/templates/newgem/gitignore.tt +5 -1
  142. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +7 -6
  143. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +4 -4
  144. data/lib/bundler/templates/newgem/newgem.gemspec.tt +31 -15
  145. data/lib/bundler/templates/newgem/rspec.tt +1 -0
  146. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +3 -5
  147. data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +14 -2
  148. data/lib/bundler/templates/newgem/test/{test_newgem.rb.tt → newgem_test.rb.tt} +2 -2
  149. data/lib/bundler/templates/newgem/test/test_helper.rb.tt +4 -0
  150. data/lib/bundler/templates/newgem/travis.yml.tt +7 -0
  151. data/lib/bundler/ui.rb +5 -3
  152. data/lib/bundler/ui/rg_proxy.rb +5 -7
  153. data/lib/bundler/ui/shell.rb +69 -18
  154. data/lib/bundler/ui/silent.rb +26 -1
  155. data/lib/bundler/uri_credentials_filter.rb +37 -0
  156. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1638 -0
  157. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +12 -0
  158. data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +26 -0
  159. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +57 -0
  160. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +81 -0
  161. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +223 -0
  162. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +36 -0
  163. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +66 -0
  164. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +62 -0
  165. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +63 -0
  166. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +61 -0
  167. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +126 -0
  168. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +46 -0
  169. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +36 -0
  170. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +136 -0
  171. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +143 -0
  172. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +6 -0
  173. data/lib/bundler/vendor/{Molinillo-0.2.1 → molinillo}/lib/molinillo/modules/specification_provider.rb +11 -0
  174. data/lib/bundler/vendor/{Molinillo-0.2.1 → molinillo}/lib/molinillo/modules/ui.rb +6 -2
  175. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +837 -0
  176. data/lib/bundler/vendor/{Molinillo-0.2.1 → molinillo}/lib/molinillo/resolver.rb +6 -3
  177. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +58 -0
  178. data/lib/bundler/vendor/{net → net-http-persistent/lib/net}/http/faster.rb +1 -0
  179. data/lib/bundler/vendor/{net → net-http-persistent/lib/net}/http/persistent.rb +27 -24
  180. data/lib/bundler/vendor/{net → net-http-persistent/lib/net}/http/persistent/ssl_reuse.rb +2 -1
  181. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor.rb +47 -22
  182. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/actions.rb +31 -29
  183. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/actions/create_file.rb +3 -2
  184. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/actions/create_link.rb +3 -2
  185. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/actions/directory.rb +3 -3
  186. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/actions/empty_directory.rb +16 -8
  187. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/actions/file_manipulation.rb +66 -18
  188. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/actions/inject_into_file.rb +18 -16
  189. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/base.rb +67 -44
  190. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/command.rb +13 -11
  191. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/core_ext/hash_with_indifferent_access.rb +21 -1
  192. data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +12 -0
  193. data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +129 -0
  194. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/error.rb +3 -3
  195. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/group.rb +14 -14
  196. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/invocation.rb +4 -5
  197. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/line_editor.rb +2 -2
  198. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/line_editor/basic.rb +2 -0
  199. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/line_editor/readline.rb +0 -0
  200. data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -0
  201. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/parser/argument.rb +4 -7
  202. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/parser/arguments.rb +16 -16
  203. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/parser/option.rb +42 -21
  204. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/parser/options.rb +13 -10
  205. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/rake_compat.rb +1 -1
  206. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/runner.rb +35 -33
  207. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/shell.rb +4 -4
  208. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/shell/basic.rb +49 -33
  209. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/shell/color.rb +2 -2
  210. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/shell/html.rb +5 -5
  211. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/util.rb +8 -7
  212. data/lib/bundler/vendor/{thor-0.19.1 → thor}/lib/thor/version.rb +1 -1
  213. data/lib/bundler/vendored_fileutils.rb +9 -0
  214. data/lib/bundler/vendored_molinillo.rb +4 -5
  215. data/lib/bundler/vendored_persistent.rb +45 -4
  216. data/lib/bundler/vendored_thor.rb +8 -5
  217. data/lib/bundler/version.rb +23 -1
  218. data/lib/bundler/version_ranges.rb +76 -0
  219. data/lib/bundler/vlad.rb +8 -2
  220. data/lib/bundler/worker.rb +39 -6
  221. data/lib/bundler/yaml_serializer.rb +90 -0
  222. data/man/bundle-add.1 +58 -0
  223. data/man/bundle-add.1.txt +52 -0
  224. data/man/bundle-add.ronn +40 -0
  225. data/man/bundle-binstubs.1 +40 -0
  226. data/man/bundle-binstubs.1.txt +48 -0
  227. data/man/bundle-binstubs.ronn +43 -0
  228. data/man/bundle-check.1 +31 -0
  229. data/man/bundle-check.1.txt +33 -0
  230. data/man/bundle-check.ronn +26 -0
  231. data/man/bundle-clean.1 +24 -0
  232. data/man/bundle-clean.1.txt +26 -0
  233. data/man/bundle-clean.ronn +18 -0
  234. data/man/bundle-config.1 +497 -0
  235. data/man/bundle-config.1.txt +529 -0
  236. data/man/bundle-config.ronn +256 -31
  237. data/man/bundle-doctor.1 +44 -0
  238. data/man/bundle-doctor.1.txt +44 -0
  239. data/man/bundle-doctor.ronn +33 -0
  240. data/man/bundle-exec.1 +165 -0
  241. data/man/bundle-exec.1.txt +178 -0
  242. data/man/bundle-exec.ronn +19 -3
  243. data/man/bundle-gem.1 +80 -0
  244. data/man/bundle-gem.1.txt +91 -0
  245. data/man/bundle-gem.ronn +78 -0
  246. data/man/bundle-info.1 +20 -0
  247. data/man/bundle-info.1.txt +21 -0
  248. data/man/bundle-info.ronn +17 -0
  249. data/man/bundle-init.1 +25 -0
  250. data/man/bundle-init.1.txt +34 -0
  251. data/man/bundle-init.ronn +29 -0
  252. data/man/bundle-inject.1 +33 -0
  253. data/man/bundle-inject.1.txt +32 -0
  254. data/man/bundle-inject.ronn +22 -0
  255. data/man/bundle-install.1 +308 -0
  256. data/man/bundle-install.1.txt +396 -0
  257. data/man/bundle-install.ronn +64 -67
  258. data/man/bundle-list.1 +50 -0
  259. data/man/bundle-list.1.txt +43 -0
  260. data/man/bundle-list.ronn +33 -0
  261. data/man/bundle-lock.1 +84 -0
  262. data/man/bundle-lock.1.txt +93 -0
  263. data/man/bundle-lock.ronn +94 -0
  264. data/man/bundle-open.1 +32 -0
  265. data/man/bundle-open.1.txt +29 -0
  266. data/man/bundle-open.ronn +19 -0
  267. data/man/bundle-outdated.1 +155 -0
  268. data/man/bundle-outdated.1.txt +131 -0
  269. data/man/bundle-outdated.ronn +111 -0
  270. data/man/bundle-package.1 +55 -0
  271. data/man/bundle-package.1.txt +79 -0
  272. data/man/bundle-package.ronn +14 -8
  273. data/man/bundle-platform.1 +61 -0
  274. data/man/bundle-platform.1.txt +57 -0
  275. data/man/bundle-platform.ronn +1 -1
  276. data/man/bundle-pristine.1 +34 -0
  277. data/man/bundle-pristine.1.txt +44 -0
  278. data/man/bundle-pristine.ronn +34 -0
  279. data/man/bundle-remove.1 +31 -0
  280. data/man/bundle-remove.1.txt +34 -0
  281. data/man/bundle-remove.ronn +23 -0
  282. data/man/bundle-show.1 +23 -0
  283. data/man/bundle-show.1.txt +27 -0
  284. data/man/bundle-show.ronn +21 -0
  285. data/man/bundle-update.1 +394 -0
  286. data/man/bundle-update.1.txt +391 -0
  287. data/man/bundle-update.ronn +180 -18
  288. data/man/bundle-viz.1 +39 -0
  289. data/man/bundle-viz.1.txt +39 -0
  290. data/man/bundle-viz.ronn +30 -0
  291. data/man/bundle.1 +136 -0
  292. data/man/bundle.1.txt +116 -0
  293. data/man/bundle.ronn +46 -33
  294. data/man/gemfile.5 +689 -0
  295. data/man/gemfile.5.ronn +127 -79
  296. data/man/gemfile.5.txt +653 -0
  297. data/man/index.txt +25 -7
  298. metadata +242 -95
  299. data/.gitignore +0 -16
  300. data/.rspec +0 -3
  301. data/.travis.yml +0 -110
  302. data/CODE_OF_CONDUCT.md +0 -40
  303. data/CONTRIBUTING.md +0 -32
  304. data/DEVELOPMENT.md +0 -119
  305. data/ISSUES.md +0 -96
  306. data/Rakefile +0 -302
  307. data/UPGRADING.md +0 -103
  308. data/bin/bundle +0 -21
  309. data/bin/bundler +0 -21
  310. data/lib/bundler/anonymizable_uri.rb +0 -32
  311. data/lib/bundler/environment.rb +0 -42
  312. data/lib/bundler/gem_installer.rb +0 -9
  313. data/lib/bundler/gem_path_manipulation.rb +0 -8
  314. data/lib/bundler/ssl_certs/AddTrustExternalCARoot.pem +0 -32
  315. data/lib/bundler/ssl_certs/Class3PublicPrimaryCertificationAuthority.pem +0 -14
  316. data/lib/bundler/ssl_certs/EntrustnetSecureServerCertificationAuthority.pem +0 -28
  317. data/lib/bundler/ssl_certs/GeoTrustGlobalCA.pem +0 -20
  318. data/lib/bundler/templates/newgem/.travis.yml.tt +0 -3
  319. data/lib/bundler/templates/newgem/test/minitest_helper.rb.tt +0 -4
  320. data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo.rb +0 -5
  321. data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/dependency_graph.rb +0 -266
  322. data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/errors.rb +0 -69
  323. data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/gem_metadata.rb +0 -3
  324. data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/resolution.rb +0 -412
  325. data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/state.rb +0 -43
  326. data/lib/bundler/vendor/thor-0.19.1/lib/thor/core_ext/io_binary_read.rb +0 -10
  327. data/lib/bundler/vendor/thor-0.19.1/lib/thor/core_ext/ordered_hash.rb +0 -98
  328. data/lib/bundler/vendor/thor-0.19.1/lib/thor/parser.rb +0 -4
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ class FeatureFlag
5
+ def self.settings_flag(flag, &default)
6
+ unless Bundler::Settings::BOOL_KEYS.include?(flag.to_s)
7
+ raise "Cannot use `#{flag}` as a settings feature flag since it isn't a bool key"
8
+ end
9
+
10
+ settings_method("#{flag}?", flag, &default)
11
+ end
12
+ private_class_method :settings_flag
13
+
14
+ def self.settings_option(key, &default)
15
+ settings_method(key, key, &default)
16
+ end
17
+ private_class_method :settings_option
18
+
19
+ def self.settings_method(name, key, &default)
20
+ define_method(name) do
21
+ value = Bundler.settings[key]
22
+ value = instance_eval(&default) if value.nil? && !default.nil?
23
+ value
24
+ end
25
+ end
26
+ private_class_method :settings_method
27
+
28
+ (1..10).each {|v| define_method("bundler_#{v}_mode?") { major_version >= v } }
29
+
30
+ settings_flag(:allow_bundler_dependency_conflicts) { bundler_2_mode? }
31
+ settings_flag(:allow_offline_install) { bundler_2_mode? }
32
+ settings_flag(:auto_clean_without_path) { bundler_2_mode? }
33
+ settings_flag(:auto_config_jobs) { bundler_2_mode? }
34
+ settings_flag(:cache_all) { bundler_2_mode? }
35
+ settings_flag(:cache_command_is_package) { bundler_2_mode? }
36
+ settings_flag(:console_command) { !bundler_2_mode? }
37
+ settings_flag(:default_install_uses_path) { bundler_2_mode? }
38
+ settings_flag(:deployment_means_frozen) { bundler_2_mode? }
39
+ settings_flag(:disable_multisource) { bundler_2_mode? }
40
+ settings_flag(:error_on_stderr) { bundler_2_mode? }
41
+ settings_flag(:forget_cli_options) { bundler_2_mode? }
42
+ settings_flag(:global_path_appends_ruby_scope) { bundler_2_mode? }
43
+ settings_flag(:global_gem_cache) { bundler_2_mode? }
44
+ settings_flag(:init_gems_rb) { bundler_2_mode? }
45
+ settings_flag(:list_command) { bundler_2_mode? }
46
+ settings_flag(:lockfile_uses_separate_rubygems_sources) { bundler_2_mode? }
47
+ settings_flag(:only_update_to_newer_versions) { bundler_2_mode? }
48
+ settings_flag(:path_relative_to_cwd) { bundler_2_mode? }
49
+ settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") }
50
+ settings_flag(:prefer_gems_rb) { bundler_2_mode? }
51
+ settings_flag(:print_only_version_number) { bundler_2_mode? }
52
+ settings_flag(:setup_makes_kernel_gem_public) { !bundler_2_mode? }
53
+ settings_flag(:skip_default_git_sources) { bundler_2_mode? }
54
+ settings_flag(:specific_platform) { bundler_2_mode? }
55
+ settings_flag(:suppress_install_using_messages) { bundler_2_mode? }
56
+ settings_flag(:unlock_source_unlocks_spec) { !bundler_2_mode? }
57
+ settings_flag(:update_requires_all_flag) { bundler_2_mode? }
58
+ settings_flag(:use_gem_version_promoter_for_major_updates) { bundler_2_mode? }
59
+ settings_flag(:viz_command) { !bundler_2_mode? }
60
+
61
+ settings_option(:default_cli_command) { bundler_2_mode? ? :cli_help : :install }
62
+
63
+ settings_method(:github_https?, "github.https") { bundler_2_mode? }
64
+
65
+ def initialize(bundler_version)
66
+ @bundler_version = Gem::Version.create(bundler_version)
67
+ end
68
+
69
+ def major_version
70
+ @bundler_version.segments.first
71
+ end
72
+ private :major_version
73
+ end
74
+ end
@@ -1,11 +1,18 @@
1
- require 'bundler/vendored_persistent'
2
- require 'securerandom'
3
- require 'cgi'
1
+ # frozen_string_literal: true
4
2
 
5
- module Bundler
3
+ require "bundler/vendored_persistent"
4
+ require "cgi"
5
+ require "securerandom"
6
+ require "zlib"
6
7
 
8
+ module Bundler
7
9
  # Handles all the fetching with the rubygems server
8
10
  class Fetcher
11
+ autoload :CompactIndex, "bundler/fetcher/compact_index"
12
+ autoload :Downloader, "bundler/fetcher/downloader"
13
+ autoload :Dependency, "bundler/fetcher/dependency"
14
+ autoload :Index, "bundler/fetcher/index"
15
+
9
16
  # This error is raised when it looks like the network is down
10
17
  class NetworkDownError < HTTPError; end
11
18
  # This error is raised if the API returns a 413 (only printed in verbose)
@@ -13,11 +20,12 @@ module Bundler
13
20
  # This is the error raised if OpenSSL fails the cert verification
14
21
  class CertificateFailureError < HTTPError
15
22
  def initialize(remote_uri)
23
+ remote_uri = filter_uri(remote_uri)
16
24
  super "Could not verify the SSL certificate for #{remote_uri}.\nThere" \
17
25
  " is a chance you are experiencing a man-in-the-middle attack, but" \
18
26
  " most likely your system doesn't have the CA certificates needed" \
19
27
  " for verification. For information about OpenSSL certificates, see" \
20
- " bit.ly/ruby-ssl. To connect without using SSL, edit your Gemfile" \
28
+ " http://bit.ly/ruby-ssl. To connect without using SSL, edit your Gemfile" \
21
29
  " sources and change 'https' to 'http'."
22
30
  end
23
31
  end
@@ -33,6 +41,7 @@ module Bundler
33
41
  # This error is raised if HTTP authentication is required, but not provided.
34
42
  class AuthenticationRequiredError < HTTPError
35
43
  def initialize(remote_uri)
44
+ remote_uri = filter_uri(remote_uri)
36
45
  super "Authentication is required for #{remote_uri}.\n" \
37
46
  "Please supply credentials for this source. You can do this by running:\n" \
38
47
  " bundle config #{remote_uri} username:password"
@@ -41,6 +50,7 @@ module Bundler
41
50
  # This error is raised if HTTP authentication is provided, but incorrect.
42
51
  class BadAuthenticationError < HTTPError
43
52
  def initialize(remote_uri)
53
+ remote_uri = filter_uri(remote_uri)
44
54
  super "Bad username or password for #{remote_uri}.\n" \
45
55
  "Please double-check your credentials and correct them."
46
56
  end
@@ -48,207 +58,154 @@ module Bundler
48
58
 
49
59
  # Exceptions classes that should bypass retry attempts. If your password didn't work the
50
60
  # first time, it's not going to the third time.
51
- AUTH_ERRORS = [AuthenticationRequiredError, BadAuthenticationError]
61
+ NET_ERRORS = [:HTTPBadGateway, :HTTPBadRequest, :HTTPFailedDependency,
62
+ :HTTPForbidden, :HTTPInsufficientStorage, :HTTPMethodNotAllowed,
63
+ :HTTPMovedPermanently, :HTTPNoContent, :HTTPNotFound,
64
+ :HTTPNotImplemented, :HTTPPreconditionFailed, :HTTPRequestEntityTooLarge,
65
+ :HTTPRequestURITooLong, :HTTPUnauthorized, :HTTPUnprocessableEntity,
66
+ :HTTPUnsupportedMediaType, :HTTPVersionNotSupported].freeze
67
+ FAIL_ERRORS = begin
68
+ fail_errors = [AuthenticationRequiredError, BadAuthenticationError, FallbackError]
69
+ fail_errors << Gem::Requirement::BadRequirementError if defined?(Gem::Requirement::BadRequirementError)
70
+ fail_errors.concat(NET_ERRORS.map {|e| SharedHelpers.const_get_safely(e, Net) }.compact)
71
+ end.freeze
52
72
 
53
73
  class << self
54
74
  attr_accessor :disable_endpoint, :api_timeout, :redirect_limit, :max_retries
55
-
56
- def download_gem_from_uri(spec, uri)
57
- spec.fetch_platform
58
-
59
- download_path = Bundler.requires_sudo? ? Bundler.tmp(spec.full_name) : Bundler.rubygems.gem_dir
60
- gem_path = "#{Bundler.rubygems.gem_dir}/cache/#{spec.full_name}.gem"
61
-
62
- FileUtils.mkdir_p("#{download_path}/cache")
63
- Bundler.rubygems.download_gem(spec, uri, download_path)
64
-
65
- if Bundler.requires_sudo?
66
- Bundler.mkdir_p "#{Bundler.rubygems.gem_dir}/cache"
67
- Bundler.sudo "mv #{Bundler.tmp(spec.full_name)}/cache/#{spec.full_name}.gem #{gem_path}"
68
- end
69
-
70
- gem_path
71
- end
72
-
73
- def user_agent
74
- @user_agent ||= begin
75
- ruby = Bundler.ruby_version
76
-
77
- agent = "bundler/#{Bundler::VERSION}"
78
- agent << " rubygems/#{Gem::VERSION}"
79
- agent << " ruby/#{ruby.version}"
80
- agent << " (#{ruby.host})"
81
- agent << " command/#{ARGV.first}"
82
-
83
- if ruby.engine != "ruby"
84
- # engine_version raises on unknown engines
85
- engine_version = ruby.engine_version rescue "???"
86
- agent << " #{ruby.engine}/#{engine_version}"
87
- end
88
-
89
- agent << " options/#{Bundler.settings.all.join(",")}"
90
-
91
- # add a random ID so we can consolidate runs server-side
92
- agent << " " << SecureRandom.hex(8)
93
-
94
- # add any user agent strings set in the config
95
- extra_ua = Bundler.settings[:user_agent]
96
- agent << " " << extra_ua if extra_ua
97
-
98
- agent
99
- end
100
- end
101
-
102
75
  end
103
76
 
104
- def initialize(remote_uri)
105
- @redirect_limit = 5 # How many redirects to allow in one request
106
- @api_timeout = 10 # How long to wait for each API call
107
- @max_retries = 3 # How many retries for the API call
77
+ self.redirect_limit = Bundler.settings[:redirect] # How many redirects to allow in one request
78
+ self.api_timeout = Bundler.settings[:timeout] # How long to wait for each API call
79
+ self.max_retries = Bundler.settings[:retry] # How many retries for the API call
108
80
 
109
- @anonymizable_uri = configured_uri_for(remote_uri)
81
+ def initialize(remote)
82
+ @remote = remote
110
83
 
111
84
  Socket.do_not_reverse_lookup = true
112
85
  connection # create persistent connection
113
86
  end
114
87
 
115
- def connection
116
- @connection ||= begin
117
- needs_ssl = remote_uri.scheme == "https" ||
118
- Bundler.settings[:ssl_verify_mode] ||
119
- Bundler.settings[:ssl_client_cert]
120
- raise SSLError if needs_ssl && !defined?(OpenSSL::SSL)
121
-
122
- con = Net::HTTP::Persistent.new 'bundler', :ENV
123
-
124
- if remote_uri.scheme == "https"
125
- con.verify_mode = (Bundler.settings[:ssl_verify_mode] ||
126
- OpenSSL::SSL::VERIFY_PEER)
127
- con.cert_store = bundler_cert_store
128
- end
129
-
130
- if Bundler.settings[:ssl_client_cert]
131
- pem = File.read(Bundler.settings[:ssl_client_cert])
132
- con.cert = OpenSSL::X509::Certificate.new(pem)
133
- con.key = OpenSSL::PKey::RSA.new(pem)
134
- end
135
-
136
- con.read_timeout = @api_timeout
137
- con.override_headers["User-Agent"] = self.class.user_agent
138
- con
139
- end
140
- end
141
-
142
88
  def uri
143
- @anonymizable_uri.without_credentials
89
+ @remote.anonymized_uri
144
90
  end
145
91
 
146
92
  # fetch a gem specification
147
93
  def fetch_spec(spec)
148
- spec = spec - [nil, 'ruby', '']
149
- spec_file_name = "#{spec.join '-'}.gemspec"
94
+ spec -= [nil, "ruby", ""]
95
+ spec_file_name = "#{spec.join "-"}.gemspec"
150
96
 
151
97
  uri = URI.parse("#{remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}.rz")
152
- if uri.scheme == 'file'
153
- Bundler.load_marshal Gem.inflate(Gem.read_binary(uri.path))
98
+ if uri.scheme == "file"
99
+ Bundler.load_marshal Bundler.rubygems.inflate(Gem.read_binary(uri.path))
154
100
  elsif cached_spec_path = gemspec_cached_path(spec_file_name)
155
101
  Bundler.load_gemspec(cached_spec_path)
156
102
  else
157
- Bundler.load_marshal Gem.inflate(fetch(uri))
103
+ Bundler.load_marshal Bundler.rubygems.inflate(downloader.fetch(uri).body)
158
104
  end
159
105
  rescue MarshalError
160
106
  raise HTTPError, "Gemspec #{spec} contained invalid data.\n" \
161
107
  "Your network or your gem server is probably having issues right now."
162
108
  end
163
109
 
164
- # cached gem specification path, if one exists
165
- def gemspec_cached_path spec_file_name
166
- paths = Bundler.rubygems.spec_cache_dirs.map { |dir| File.join(dir, spec_file_name) }
167
- paths = paths.select {|path| File.file? path }
168
- paths.first
110
+ # return the specs in the bundler format as an index with retries
111
+ def specs_with_retry(gem_names, source)
112
+ Bundler::Retry.new("fetcher", FAIL_ERRORS).attempts do
113
+ specs(gem_names, source)
114
+ end
169
115
  end
170
116
 
171
117
  # return the specs in the bundler format as an index
172
118
  def specs(gem_names, source)
173
119
  old = Bundler.rubygems.sources
174
- index = Index.new
175
-
176
- if gem_names && use_api
177
- specs = fetch_remote_specs(gem_names)
178
- end
120
+ index = Bundler::Index.new
179
121
 
180
- if specs.nil?
181
- # API errors mean we should treat this as a non-API source
122
+ if Bundler::Fetcher.disable_endpoint
182
123
  @use_api = false
183
-
184
- specs = Bundler::Retry.new("source fetch", AUTH_ERRORS).attempts do
185
- fetch_all_remote_specs
124
+ specs = fetchers.last.specs(gem_names)
125
+ else
126
+ specs = []
127
+ fetchers.shift until fetchers.first.available? || fetchers.empty?
128
+ fetchers.dup.each do |f|
129
+ break unless f.api_fetcher? && !gem_names || !specs = f.specs(gem_names)
130
+ fetchers.delete(f)
186
131
  end
132
+ @use_api = false if fetchers.none?(&:api_fetcher?)
187
133
  end
188
134
 
189
- specs[remote_uri].each do |name, version, platform, dependencies|
190
- next if name == 'bundler'
191
- spec = nil
192
- if dependencies
193
- spec = EndpointSpecification.new(name, version, platform, dependencies)
135
+ specs.each do |name, version, platform, dependencies, metadata|
136
+ next if name == "bundler"
137
+ spec = if dependencies
138
+ EndpointSpecification.new(name, version, platform, dependencies, metadata)
194
139
  else
195
- spec = RemoteSpecification.new(name, version, platform, self)
140
+ RemoteSpecification.new(name, version, platform, self)
196
141
  end
197
142
  spec.source = source
198
- spec.source_uri = @anonymizable_uri
143
+ spec.remote = @remote
199
144
  index << spec
200
145
  end
201
146
 
202
147
  index
203
- rescue CertificateFailureError => e
148
+ rescue CertificateFailureError
204
149
  Bundler.ui.info "" if gem_names && use_api # newline after dots
205
- raise e
150
+ raise
206
151
  ensure
207
152
  Bundler.rubygems.sources = old
208
153
  end
209
154
 
210
- # fetch index
211
- def fetch_remote_specs(gem_names, full_dependency_list = [], last_spec_list = [])
212
- query_list = gem_names - full_dependency_list
155
+ def use_api
156
+ return @use_api if defined?(@use_api)
157
+
158
+ fetchers.shift until fetchers.first.available?
213
159
 
214
- # only display the message on the first run
215
- if Bundler.ui.debug?
216
- Bundler.ui.debug "Query List: #{query_list.inspect}"
160
+ @use_api = if remote_uri.scheme == "file" || Bundler::Fetcher.disable_endpoint
161
+ false
217
162
  else
218
- Bundler.ui.info ".", false
163
+ fetchers.first.api_fetcher?
219
164
  end
165
+ end
220
166
 
221
- return {remote_uri => last_spec_list} if query_list.empty?
167
+ def user_agent
168
+ @user_agent ||= begin
169
+ ruby = Bundler::RubyVersion.system
170
+
171
+ agent = String.new("bundler/#{Bundler::VERSION}")
172
+ agent << " rubygems/#{Gem::VERSION}"
173
+ agent << " ruby/#{ruby.versions_string(ruby.versions)}"
174
+ agent << " (#{ruby.host})"
175
+ agent << " command/#{ARGV.first}"
176
+
177
+ if ruby.engine != "ruby"
178
+ # engine_version raises on unknown engines
179
+ engine_version = begin
180
+ ruby.engine_versions
181
+ rescue RuntimeError
182
+ "???"
183
+ end
184
+ agent << " #{ruby.engine}/#{ruby.versions_string(engine_version)}"
185
+ end
222
186
 
223
- remote_specs = Bundler::Retry.new("dependency api", AUTH_ERRORS).attempts do
224
- fetch_dependency_remote_specs(query_list)
225
- end
187
+ agent << " options/#{Bundler.settings.all.join(",")}"
226
188
 
227
- spec_list, deps_list = remote_specs
228
- returned_gems = spec_list.map {|spec| spec.first }.uniq
229
- fetch_remote_specs(deps_list, full_dependency_list + returned_gems, spec_list + last_spec_list)
230
- rescue HTTPError, MarshalError, GemspecError
231
- Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
232
- Bundler.ui.debug "could not fetch from the dependency API, trying the full index"
233
- @use_api = false
234
- return nil
235
- end
189
+ agent << " ci/#{cis.join(",")}" if cis.any?
236
190
 
237
- def use_api
238
- return @use_api if defined?(@use_api)
191
+ # add a random ID so we can consolidate runs server-side
192
+ agent << " " << SecureRandom.hex(8)
239
193
 
240
- if remote_uri.scheme == "file" || Bundler::Fetcher.disable_endpoint
241
- @use_api = false
242
- elsif fetch(dependency_api_uri)
243
- @use_api = true
194
+ # add any user agent strings set in the config
195
+ extra_ua = Bundler.settings[:user_agent]
196
+ agent << " " << extra_ua if extra_ua
197
+
198
+ agent
244
199
  end
245
- rescue NetworkDownError => e
246
- raise HTTPError, e.message
247
- rescue AuthenticationRequiredError
248
- # We got a 401 from the server. Don't fall back to the full index, just fail.
249
- raise
250
- rescue HTTPError
251
- @use_api = false
200
+ end
201
+
202
+ def fetchers
203
+ @fetchers ||= FETCHERS.map {|f| f.new(downloader, @remote, uri) }
204
+ end
205
+
206
+ def http_proxy
207
+ return unless uri = connection.proxy_uri
208
+ uri.to_s
252
209
  end
253
210
 
254
211
  def inspect
@@ -257,165 +214,99 @@ module Bundler
257
214
 
258
215
  private
259
216
 
260
- HTTP_ERRORS = [
261
- Timeout::Error, EOFError, SocketError, Errno::ENETDOWN,
262
- Errno::EINVAL, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::EAGAIN,
263
- Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError,
264
- Net::HTTP::Persistent::Error
265
- ]
266
-
267
- def fetch(uri, counter = 0)
268
- raise HTTPError, "Too many redirects" if counter >= @redirect_limit
269
-
270
- response = request(uri)
271
- Bundler.ui.debug("HTTP #{response.code} #{response.message}")
272
-
273
- case response
274
- when Net::HTTPRedirection
275
- new_uri = URI.parse(response["location"])
276
- if new_uri.host == uri.host
277
- new_uri.user = uri.user
278
- new_uri.password = uri.password
279
- end
280
- fetch(new_uri, counter + 1)
281
- when Net::HTTPSuccess
282
- response.body
283
- when Net::HTTPRequestEntityTooLarge
284
- raise FallbackError, response.body
285
- when Net::HTTPUnauthorized
286
- raise AuthenticationRequiredError, remote_uri.host
287
- else
288
- raise HTTPError, "#{response.class}: #{response.body}"
289
- end
290
- end
291
-
292
- def request(uri)
293
- Bundler.ui.debug "HTTP GET #{uri}"
294
- req = Net::HTTP::Get.new uri.request_uri
295
- if uri.user
296
- user = CGI.unescape(uri.user)
297
- password = uri.password ? CGI.unescape(uri.password) : nil
298
- req.basic_auth(user, password)
299
- end
300
- connection.request(uri, req)
301
- rescue OpenSSL::SSL::SSLError
302
- raise CertificateFailureError.new(uri)
303
- rescue *HTTP_ERRORS => e
304
- Bundler.ui.trace e
305
- case e.message
306
- when /host down:/, /getaddrinfo: nodename nor servname provided/
307
- raise NetworkDownError, "Could not reach host #{uri.host}. Check your network " \
308
- "connection and try again."
309
- else
310
- raise HTTPError, "Network error while fetching #{uri}"
311
- end
217
+ FETCHERS = [CompactIndex, Dependency, Index].freeze
218
+
219
+ def cis
220
+ env_cis = {
221
+ "TRAVIS" => "travis",
222
+ "CIRCLECI" => "circle",
223
+ "SEMAPHORE" => "semaphore",
224
+ "JENKINS_URL" => "jenkins",
225
+ "BUILDBOX" => "buildbox",
226
+ "GO_SERVER_URL" => "go",
227
+ "SNAP_CI" => "snap",
228
+ "CI_NAME" => ENV["CI_NAME"],
229
+ "CI" => "ci"
230
+ }
231
+ env_cis.find_all {|env, _| ENV[env] }.map {|_, ci| ci }
312
232
  end
313
233
 
314
- def dependency_api_uri(gem_names = [])
315
- uri = fetch_uri + "api/v1/dependencies"
316
- uri.query = "gems=#{URI.encode(gem_names.join(","))}" if gem_names.any?
317
- uri
318
- end
234
+ def connection
235
+ @connection ||= begin
236
+ needs_ssl = remote_uri.scheme == "https" ||
237
+ Bundler.settings[:ssl_verify_mode] ||
238
+ Bundler.settings[:ssl_client_cert]
239
+ raise SSLError if needs_ssl && !defined?(OpenSSL::SSL)
319
240
 
320
- # fetch from Gemcutter Dependency Endpoint API
321
- def fetch_dependency_remote_specs(gem_names)
322
- Bundler.ui.debug "Query Gemcutter Dependency Endpoint API: #{gem_names.join(',')}"
323
- gem_list = []
324
- deps_list = []
241
+ con = PersistentHTTP.new "bundler", :ENV
242
+ if gem_proxy = Bundler.rubygems.configuration[:http_proxy]
243
+ con.proxy = URI.parse(gem_proxy) if gem_proxy != :no_proxy
244
+ end
325
245
 
326
- gem_names.each_slice(Source::Rubygems::API_REQUEST_SIZE) do |names|
327
- marshalled_deps = fetch dependency_api_uri(names)
328
- gem_list += Bundler.load_marshal(marshalled_deps)
329
- end
246
+ if remote_uri.scheme == "https"
247
+ con.verify_mode = (Bundler.settings[:ssl_verify_mode] ||
248
+ OpenSSL::SSL::VERIFY_PEER)
249
+ con.cert_store = bundler_cert_store
250
+ end
330
251
 
331
- spec_list = gem_list.map do |s|
332
- dependencies = s[:dependencies].map do |name, requirement|
333
- dep = well_formed_dependency(name, requirement.split(", "))
334
- deps_list << dep.name
335
- dep
252
+ ssl_client_cert = Bundler.settings[:ssl_client_cert] ||
253
+ (Bundler.rubygems.configuration.ssl_client_cert if
254
+ Bundler.rubygems.configuration.respond_to?(:ssl_client_cert))
255
+ if ssl_client_cert
256
+ pem = File.read(ssl_client_cert)
257
+ con.cert = OpenSSL::X509::Certificate.new(pem)
258
+ con.key = OpenSSL::PKey::RSA.new(pem)
336
259
  end
337
260
 
338
- [s[:name], Gem::Version.new(s[:number]), s[:platform], dependencies]
261
+ con.read_timeout = Fetcher.api_timeout
262
+ con.open_timeout = Fetcher.api_timeout
263
+ con.override_headers["User-Agent"] = user_agent
264
+ con.override_headers["X-Gemfile-Source"] = @remote.original_uri.to_s if @remote.original_uri
265
+ con
339
266
  end
340
-
341
- [spec_list, deps_list.uniq]
342
267
  end
343
268
 
344
- # fetch from modern index: specs.4.8.gz
345
- def fetch_all_remote_specs
346
- old_sources = Bundler.rubygems.sources
347
- Bundler.rubygems.sources = [remote_uri.to_s]
348
- Bundler.rubygems.fetch_all_remote_specs
349
- rescue Gem::RemoteFetcher::FetchError, OpenSSL::SSL::SSLError => e
350
- case e.message
351
- when /certificate verify failed/
352
- raise CertificateFailureError.new(uri)
353
- when /401/
354
- raise AuthenticationRequiredError, remote_uri
355
- when /403/
356
- if remote_uri.userinfo
357
- raise BadAuthenticationError, remote_uri
358
- else
359
- raise AuthenticationRequiredError, remote_uri
360
- end
361
- else
362
- Bundler.ui.trace e
363
- raise HTTPError, "Could not fetch specs from #{uri}"
364
- end
365
- ensure
366
- Bundler.rubygems.sources = old_sources
269
+ # cached gem specification path, if one exists
270
+ def gemspec_cached_path(spec_file_name)
271
+ paths = Bundler.rubygems.spec_cache_dirs.map {|dir| File.join(dir, spec_file_name) }
272
+ paths = paths.select {|path| File.file? path }
273
+ paths.first
367
274
  end
368
275
 
369
- def well_formed_dependency(name, *requirements)
370
- Gem::Dependency.new(name, *requirements)
371
- rescue ArgumentError => e
372
- illformed = 'Ill-formed requirement ["#<YAML::Syck::DefaultKey'
373
- raise e unless e.message.include?(illformed)
374
- puts # we shouldn't print the error message on the "fetching info" status line
375
- raise GemspecError,
376
- "Unfortunately, the gem #{s[:name]} (#{s[:number]}) has an invalid " \
377
- "gemspec. \nPlease ask the gem author to yank the bad version to fix " \
378
- "this issue. For more information, see http://bit.ly/syck-defaultkey."
379
- end
276
+ HTTP_ERRORS = [
277
+ Timeout::Error, EOFError, SocketError, Errno::ENETDOWN, Errno::ENETUNREACH,
278
+ Errno::EINVAL, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::EAGAIN,
279
+ Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError,
280
+ PersistentHTTP::Error, Zlib::BufError, Errno::EHOSTUNREACH
281
+ ].freeze
380
282
 
381
283
  def bundler_cert_store
382
284
  store = OpenSSL::X509::Store.new
383
- if Bundler.settings[:ssl_ca_cert]
384
- if File.directory? Bundler.settings[:ssl_ca_cert]
385
- store.add_path Bundler.settings[:ssl_ca_cert]
285
+ ssl_ca_cert = Bundler.settings[:ssl_ca_cert] ||
286
+ (Bundler.rubygems.configuration.ssl_ca_cert if
287
+ Bundler.rubygems.configuration.respond_to?(:ssl_ca_cert))
288
+ if ssl_ca_cert
289
+ if File.directory? ssl_ca_cert
290
+ store.add_path ssl_ca_cert
386
291
  else
387
- store.add_file Bundler.settings[:ssl_ca_cert]
292
+ store.add_file ssl_ca_cert
388
293
  end
389
294
  else
390
295
  store.set_default_paths
391
- certs = File.expand_path("../ssl_certs/*.pem", __FILE__)
392
- Dir.glob(certs).each { |c| store.add_file c }
296
+ certs = File.expand_path("../ssl_certs/*/*.pem", __FILE__)
297
+ Dir.glob(certs).each {|c| store.add_file c }
393
298
  end
394
299
  store
395
300
  end
396
301
 
397
302
  private
398
303
 
399
- def configured_uri_for(uri)
400
- uri = Bundler::Source.mirror_for(uri)
401
- config_auth = Bundler.settings[uri.to_s] || Bundler.settings[uri.host]
402
- AnonymizableURI.new(uri, config_auth)
403
- end
404
-
405
- def fetch_uri
406
- @fetch_uri ||= begin
407
- if remote_uri.host == "rubygems.org"
408
- uri = remote_uri.dup
409
- uri.host = "bundler.rubygems.org"
410
- uri
411
- else
412
- remote_uri
413
- end
414
- end
304
+ def remote_uri
305
+ @remote.uri
415
306
  end
416
307
 
417
- def remote_uri
418
- @anonymizable_uri.original_uri
308
+ def downloader
309
+ @downloader ||= Downloader.new(connection, self.class.redirect_limit)
419
310
  end
420
311
  end
421
312
  end