bundler 2.2.29 → 2.5.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (330) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1129 -4
  3. data/README.md +4 -8
  4. data/bundler.gemspec +11 -11
  5. data/exe/bundle +5 -26
  6. data/exe/bundler +1 -1
  7. data/lib/bundler/.document +1 -0
  8. data/lib/bundler/build_metadata.rb +4 -4
  9. data/lib/bundler/capistrano.rb +1 -1
  10. data/lib/bundler/checksum.rb +254 -0
  11. data/lib/bundler/ci_detector.rb +75 -0
  12. data/lib/bundler/cli/add.rb +4 -4
  13. data/lib/bundler/cli/binstubs.rb +10 -6
  14. data/lib/bundler/cli/cache.rb +1 -1
  15. data/lib/bundler/cli/check.rb +3 -3
  16. data/lib/bundler/cli/common.rb +13 -3
  17. data/lib/bundler/cli/config.rb +18 -8
  18. data/lib/bundler/cli/console.rb +5 -4
  19. data/lib/bundler/cli/doctor.rb +12 -5
  20. data/lib/bundler/cli/exec.rb +1 -1
  21. data/lib/bundler/cli/fund.rb +1 -1
  22. data/lib/bundler/cli/gem.rb +141 -48
  23. data/lib/bundler/cli/info.rb +27 -17
  24. data/lib/bundler/cli/init.rb +6 -2
  25. data/lib/bundler/cli/install.rb +22 -39
  26. data/lib/bundler/cli/issue.rb +5 -4
  27. data/lib/bundler/cli/lock.rb +36 -29
  28. data/lib/bundler/cli/open.rb +9 -9
  29. data/lib/bundler/cli/outdated.rb +19 -12
  30. data/lib/bundler/cli/platform.rb +8 -6
  31. data/lib/bundler/cli/plugin.rb +9 -15
  32. data/lib/bundler/cli/pristine.rb +38 -30
  33. data/lib/bundler/cli/show.rb +3 -3
  34. data/lib/bundler/cli/update.rb +12 -7
  35. data/lib/bundler/cli/viz.rb +1 -1
  36. data/lib/bundler/cli.rb +266 -285
  37. data/lib/bundler/compact_index_client/cache.rb +53 -67
  38. data/lib/bundler/compact_index_client/cache_file.rb +153 -0
  39. data/lib/bundler/compact_index_client/gem_parser.rb +7 -3
  40. data/lib/bundler/compact_index_client/parser.rb +84 -0
  41. data/lib/bundler/compact_index_client/updater.rb +83 -76
  42. data/lib/bundler/compact_index_client.rb +59 -87
  43. data/lib/bundler/constants.rb +9 -2
  44. data/lib/bundler/current_ruby.rb +12 -16
  45. data/lib/bundler/definition.rb +509 -319
  46. data/lib/bundler/dependency.rb +33 -71
  47. data/lib/bundler/digest.rb +71 -0
  48. data/lib/bundler/dsl.rb +88 -69
  49. data/lib/bundler/endpoint_specification.rb +32 -15
  50. data/lib/bundler/env.rb +5 -7
  51. data/lib/bundler/environment_preserver.rb +8 -22
  52. data/lib/bundler/errors.rb +101 -13
  53. data/lib/bundler/feature_flag.rb +0 -2
  54. data/lib/bundler/fetcher/base.rb +11 -11
  55. data/lib/bundler/fetcher/compact_index.rb +32 -52
  56. data/lib/bundler/fetcher/dependency.rb +3 -7
  57. data/lib/bundler/fetcher/downloader.rb +17 -16
  58. data/lib/bundler/fetcher/gem_remote_fetcher.rb +16 -0
  59. data/lib/bundler/fetcher/index.rb +2 -29
  60. data/lib/bundler/fetcher.rb +87 -79
  61. data/lib/bundler/force_platform.rb +18 -0
  62. data/lib/bundler/friendly_errors.rb +29 -40
  63. data/lib/bundler/gem_helper.rb +11 -23
  64. data/lib/bundler/gem_helpers.rb +30 -6
  65. data/lib/bundler/gem_version_promoter.rb +68 -109
  66. data/lib/bundler/graph.rb +9 -9
  67. data/lib/bundler/index.rb +71 -79
  68. data/lib/bundler/injector.rb +23 -11
  69. data/lib/bundler/inline.rb +11 -23
  70. data/lib/bundler/installer/gem_installer.rb +18 -11
  71. data/lib/bundler/installer/parallel_installer.rb +17 -65
  72. data/lib/bundler/installer/standalone.rb +56 -15
  73. data/lib/bundler/installer.rb +35 -61
  74. data/lib/bundler/lazy_specification.rb +92 -61
  75. data/lib/bundler/lockfile_generator.rb +12 -3
  76. data/lib/bundler/lockfile_parser.rb +137 -70
  77. data/lib/bundler/man/bundle-add.1 +19 -26
  78. data/lib/bundler/man/bundle-add.1.ronn +16 -4
  79. data/lib/bundler/man/bundle-binstubs.1 +4 -16
  80. data/lib/bundler/man/bundle-cache.1 +9 -24
  81. data/lib/bundler/man/bundle-cache.1.ronn +9 -2
  82. data/lib/bundler/man/bundle-check.1 +5 -12
  83. data/lib/bundler/man/bundle-check.1.ronn +3 -0
  84. data/lib/bundler/man/bundle-clean.1 +4 -11
  85. data/lib/bundler/man/bundle-clean.1.ronn +1 -1
  86. data/lib/bundler/man/bundle-config.1 +47 -224
  87. data/lib/bundler/man/bundle-config.1.ronn +40 -28
  88. data/lib/bundler/man/bundle-console.1 +35 -0
  89. data/lib/bundler/man/bundle-console.1.ronn +44 -0
  90. data/lib/bundler/man/bundle-doctor.1 +4 -18
  91. data/lib/bundler/man/bundle-exec.1 +16 -77
  92. data/lib/bundler/man/bundle-exec.1.ronn +8 -9
  93. data/lib/bundler/man/bundle-gem.1 +45 -72
  94. data/lib/bundler/man/bundle-gem.1.ronn +32 -5
  95. data/lib/bundler/man/bundle-help.1 +9 -0
  96. data/lib/bundler/man/bundle-help.1.ronn +12 -0
  97. data/lib/bundler/man/bundle-info.1 +5 -11
  98. data/lib/bundler/man/bundle-info.1.ronn +3 -3
  99. data/lib/bundler/man/bundle-init.1 +6 -11
  100. data/lib/bundler/man/bundle-init.1.ronn +2 -0
  101. data/lib/bundler/man/bundle-inject.1 +8 -18
  102. data/lib/bundler/man/bundle-inject.1.ronn +3 -1
  103. data/lib/bundler/man/bundle-install.1 +32 -155
  104. data/lib/bundler/man/bundle-install.1.ronn +11 -33
  105. data/lib/bundler/man/bundle-list.1 +4 -19
  106. data/lib/bundler/man/bundle-lock.1 +5 -29
  107. data/lib/bundler/man/bundle-open.1 +18 -18
  108. data/lib/bundler/man/bundle-open.1.ronn +9 -1
  109. data/lib/bundler/man/bundle-outdated.1 +17 -72
  110. data/lib/bundler/man/bundle-outdated.1.ronn +13 -18
  111. data/lib/bundler/man/bundle-platform.1 +16 -28
  112. data/lib/bundler/man/bundle-platform.1.ronn +14 -7
  113. data/lib/bundler/man/bundle-plugin.1 +58 -0
  114. data/lib/bundler/man/bundle-plugin.1.ronn +63 -0
  115. data/lib/bundler/man/bundle-pristine.1 +5 -16
  116. data/lib/bundler/man/bundle-remove.1 +4 -14
  117. data/lib/bundler/man/bundle-show.1 +3 -10
  118. data/lib/bundler/man/bundle-update.1 +19 -138
  119. data/lib/bundler/man/bundle-update.1.ronn +2 -1
  120. data/lib/bundler/man/bundle-version.1 +22 -0
  121. data/lib/bundler/man/bundle-version.1.ronn +24 -0
  122. data/lib/bundler/man/bundle-viz.1 +6 -15
  123. data/lib/bundler/man/bundle-viz.1.ronn +2 -0
  124. data/lib/bundler/man/bundle.1 +17 -51
  125. data/lib/bundler/man/bundle.1.ronn +12 -7
  126. data/lib/bundler/man/gemfile.5 +130 -346
  127. data/lib/bundler/man/gemfile.5.ronn +121 -86
  128. data/lib/bundler/man/index.txt +4 -0
  129. data/lib/bundler/match_metadata.rb +17 -0
  130. data/lib/bundler/match_platform.rb +1 -2
  131. data/lib/bundler/match_remote_metadata.rb +29 -0
  132. data/lib/bundler/mirror.rb +8 -10
  133. data/lib/bundler/plugin/api/source.rb +9 -13
  134. data/lib/bundler/plugin/index.rb +13 -5
  135. data/lib/bundler/plugin/installer/git.rb +0 -4
  136. data/lib/bundler/plugin/installer/path.rb +18 -0
  137. data/lib/bundler/plugin/installer/rubygems.rb +0 -8
  138. data/lib/bundler/plugin/installer.rb +42 -19
  139. data/lib/bundler/plugin/source_list.rb +4 -4
  140. data/lib/bundler/plugin.rb +16 -7
  141. data/lib/bundler/process_lock.rb +1 -1
  142. data/lib/bundler/remote_specification.rb +11 -5
  143. data/lib/bundler/resolver/base.rb +111 -0
  144. data/lib/bundler/resolver/candidate.rb +82 -0
  145. data/lib/bundler/resolver/incompatibility.rb +15 -0
  146. data/lib/bundler/resolver/package.rb +81 -0
  147. data/lib/bundler/resolver/root.rb +25 -0
  148. data/lib/bundler/resolver/spec_group.rb +53 -66
  149. data/lib/bundler/resolver.rb +419 -307
  150. data/lib/bundler/retry.rb +1 -1
  151. data/lib/bundler/ruby_dsl.rb +42 -7
  152. data/lib/bundler/ruby_version.rb +16 -22
  153. data/lib/bundler/rubygems_ext.rb +250 -64
  154. data/lib/bundler/rubygems_gem_installer.rb +90 -64
  155. data/lib/bundler/rubygems_integration.rb +81 -190
  156. data/lib/bundler/runtime.rb +8 -13
  157. data/lib/bundler/safe_marshal.rb +31 -0
  158. data/lib/bundler/self_manager.rb +206 -0
  159. data/lib/bundler/settings.rb +139 -57
  160. data/lib/bundler/setup.rb +13 -1
  161. data/lib/bundler/shared_helpers.rb +67 -36
  162. data/lib/bundler/source/git/git_proxy.rb +285 -82
  163. data/lib/bundler/source/git.rb +81 -41
  164. data/lib/bundler/source/metadata.rb +17 -16
  165. data/lib/bundler/source/path/installer.rb +1 -22
  166. data/lib/bundler/source/path.rb +13 -25
  167. data/lib/bundler/source/rubygems/remote.rb +1 -1
  168. data/lib/bundler/source/rubygems.rb +164 -234
  169. data/lib/bundler/source/rubygems_aggregate.rb +1 -1
  170. data/lib/bundler/source.rb +7 -6
  171. data/lib/bundler/source_list.rb +40 -32
  172. data/lib/bundler/source_map.rb +15 -2
  173. data/lib/bundler/spec_set.rb +156 -46
  174. data/lib/bundler/stub_specification.rb +18 -5
  175. data/lib/bundler/templates/Executable +3 -5
  176. data/lib/bundler/templates/Executable.bundler +7 -12
  177. data/lib/bundler/templates/Executable.standalone +4 -4
  178. data/lib/bundler/templates/Gemfile +0 -2
  179. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +77 -29
  180. data/lib/bundler/templates/newgem/Cargo.toml.tt +7 -0
  181. data/lib/bundler/templates/newgem/Gemfile.tt +8 -2
  182. data/lib/bundler/templates/newgem/README.md.tt +7 -11
  183. data/lib/bundler/templates/newgem/Rakefile.tt +28 -4
  184. data/lib/bundler/templates/newgem/bin/console.tt +0 -4
  185. data/lib/bundler/templates/newgem/circleci/config.yml.tt +12 -0
  186. data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +15 -0
  187. data/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt +10 -0
  188. data/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
  189. data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +1 -1
  190. data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +12 -0
  191. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +13 -3
  192. data/lib/bundler/templates/newgem/gitignore.tt +3 -0
  193. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +13 -4
  194. data/lib/bundler/templates/newgem/newgem.gemspec.tt +25 -17
  195. data/lib/bundler/templates/newgem/rubocop.yml.tt +0 -5
  196. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  197. data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  198. data/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
  199. data/lib/bundler/ui/rg_proxy.rb +1 -1
  200. data/lib/bundler/ui/shell.rb +38 -15
  201. data/lib/bundler/ui/silent.rb +21 -5
  202. data/lib/bundler/uri_credentials_filter.rb +2 -2
  203. data/lib/bundler/uri_normalizer.rb +23 -0
  204. data/lib/bundler/vendor/.document +1 -0
  205. data/lib/bundler/vendor/connection_pool/.document +1 -0
  206. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  207. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
  208. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  209. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +56 -0
  210. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +92 -78
  211. data/lib/bundler/vendor/fileutils/.document +1 -0
  212. data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  213. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1340 -410
  214. data/lib/bundler/vendor/net-http-persistent/.document +1 -0
  215. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  216. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +4 -3
  217. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +23 -11
  218. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +1 -1
  219. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +57 -57
  220. data/lib/bundler/vendor/pub_grub/.document +1 -0
  221. data/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
  222. data/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
  223. data/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +189 -0
  224. data/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
  225. data/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +150 -0
  226. data/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
  227. data/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
  228. data/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
  229. data/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
  230. data/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +61 -0
  231. data/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
  232. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
  233. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +129 -0
  234. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +411 -0
  235. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +248 -0
  236. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
  237. data/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
  238. data/lib/bundler/vendor/thor/.document +1 -0
  239. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  240. data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +3 -2
  241. data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +1 -1
  242. data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +1 -1
  243. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +12 -14
  244. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +16 -6
  245. data/lib/bundler/vendor/thor/lib/thor/actions.rb +21 -17
  246. data/lib/bundler/vendor/thor/lib/thor/base.rb +140 -14
  247. data/lib/bundler/vendor/thor/lib/thor/command.rb +13 -4
  248. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +10 -0
  249. data/lib/bundler/vendor/thor/lib/thor/error.rb +16 -20
  250. data/lib/bundler/vendor/thor/lib/thor/group.rb +1 -1
  251. data/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -1
  252. data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +2 -2
  253. data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +20 -1
  254. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +33 -17
  255. data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +27 -8
  256. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +63 -7
  257. data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +2 -2
  258. data/lib/bundler/vendor/thor/lib/thor/runner.rb +40 -30
  259. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +48 -154
  260. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +1 -46
  261. data/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb +29 -0
  262. data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +0 -45
  263. data/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +134 -0
  264. data/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb +42 -0
  265. data/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb +38 -0
  266. data/lib/bundler/vendor/thor/lib/thor/shell.rb +2 -2
  267. data/lib/bundler/vendor/thor/lib/thor/util.rb +9 -8
  268. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  269. data/lib/bundler/vendor/thor/lib/thor.rb +155 -8
  270. data/lib/bundler/vendor/tsort/.document +1 -0
  271. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  272. data/lib/bundler/vendor/tsort/lib/tsort.rb +455 -0
  273. data/lib/bundler/vendor/uri/.document +1 -0
  274. data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  275. data/lib/bundler/vendor/uri/lib/uri/common.rb +316 -207
  276. data/lib/bundler/vendor/uri/lib/uri/file.rb +7 -1
  277. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +2 -2
  278. data/lib/bundler/vendor/uri/lib/uri/generic.rb +33 -13
  279. data/lib/bundler/vendor/uri/lib/uri/http.rb +40 -3
  280. data/lib/bundler/vendor/uri/lib/uri/https.rb +2 -2
  281. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +2 -2
  282. data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +2 -1
  283. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +2 -3
  284. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +16 -23
  285. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +105 -47
  286. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  287. data/lib/bundler/vendor/uri/lib/uri/ws.rb +83 -0
  288. data/lib/bundler/vendor/uri/lib/uri/wss.rb +23 -0
  289. data/lib/bundler/vendor/uri/lib/uri.rb +3 -3
  290. data/lib/bundler/vendored_net_http.rb +23 -0
  291. data/lib/bundler/vendored_persistent.rb +0 -36
  292. data/lib/bundler/{vendored_molinillo.rb → vendored_pub_grub.rb} +1 -1
  293. data/lib/bundler/vendored_timeout.rb +12 -0
  294. data/lib/bundler/{vendored_tmpdir.rb → vendored_tsort.rb} +1 -1
  295. data/lib/bundler/vendored_uri.rb +18 -1
  296. data/lib/bundler/version.rb +5 -1
  297. data/lib/bundler/vlad.rb +1 -1
  298. data/lib/bundler/worker.rb +7 -9
  299. data/lib/bundler/yaml_serializer.rb +21 -12
  300. data/lib/bundler.rb +114 -121
  301. metadata +87 -41
  302. data/lib/bundler/dep_proxy.rb +0 -55
  303. data/lib/bundler/gemdeps.rb +0 -29
  304. data/lib/bundler/psyched_yaml.rb +0 -22
  305. data/lib/bundler/templates/gems.rb +0 -8
  306. data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +0 -5
  307. data/lib/bundler/templates/newgem/travis.yml.tt +0 -6
  308. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
  309. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
  310. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +0 -88
  311. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +0 -36
  312. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +0 -66
  313. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +0 -62
  314. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +0 -63
  315. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +0 -61
  316. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +0 -126
  317. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +0 -46
  318. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +0 -36
  319. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +0 -164
  320. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -255
  321. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +0 -143
  322. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +0 -6
  323. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +0 -112
  324. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +0 -67
  325. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +0 -839
  326. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +0 -46
  327. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +0 -58
  328. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -11
  329. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +0 -154
  330. data/lib/bundler/version_ranges.rb +0 -122
@@ -3,7 +3,6 @@
3
3
  # = uri/common.rb
4
4
  #
5
5
  # Author:: Akira Yamada <akira@ruby-lang.org>
6
- # Revision:: $Id$
7
6
  # License::
8
7
  # You can redistribute it and/or modify it under the same term as Ruby.
9
8
  #
@@ -14,9 +13,12 @@ require_relative "rfc2396_parser"
14
13
  require_relative "rfc3986_parser"
15
14
 
16
15
  module Bundler::URI
16
+ include RFC2396_REGEXP
17
+
17
18
  REGEXP = RFC2396_REGEXP
18
19
  Parser = RFC2396_Parser
19
20
  RFC3986_PARSER = RFC3986_Parser.new
21
+ Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor)
20
22
 
21
23
  # Bundler::URI::Parser.new
22
24
  DEFAULT_PARSER = Parser.new
@@ -28,6 +30,7 @@ module Bundler::URI
28
30
  DEFAULT_PARSER.regexp.each_pair do |sym, str|
29
31
  const_set(sym, str)
30
32
  end
33
+ Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor)
31
34
 
32
35
  module Util # :nodoc:
33
36
  def make_components_hash(klass, array_hash)
@@ -61,88 +64,72 @@ module Bundler::URI
61
64
  module_function :make_components_hash
62
65
  end
63
66
 
64
- # Module for escaping unsafe characters with codes.
65
- module Escape
66
- #
67
- # == Synopsis
68
- #
69
- # Bundler::URI.escape(str [, unsafe])
70
- #
71
- # == Args
72
- #
73
- # +str+::
74
- # String to replaces in.
75
- # +unsafe+::
76
- # Regexp that matches all symbols that must be replaced with codes.
77
- # By default uses <tt>UNSAFE</tt>.
78
- # When this argument is a String, it represents a character set.
79
- #
80
- # == Description
81
- #
82
- # Escapes the string, replacing all unsafe characters with codes.
83
- #
84
- # This method is obsolete and should not be used. Instead, use
85
- # CGI.escape, Bundler::URI.encode_www_form or Bundler::URI.encode_www_form_component
86
- # depending on your specific use case.
87
- #
88
- # == Usage
89
- #
90
- # require 'bundler/vendor/uri/lib/uri'
91
- #
92
- # enc_uri = Bundler::URI.escape("http://example.com/?a=\11\15")
93
- # # => "http://example.com/?a=%09%0D"
94
- #
95
- # Bundler::URI.unescape(enc_uri)
96
- # # => "http://example.com/?a=\t\r"
97
- #
98
- # Bundler::URI.escape("@?@!", "!?")
99
- # # => "@%3F@%21"
100
- #
101
- def escape(*arg)
102
- warn "Bundler::URI.escape is obsolete", uplevel: 1
103
- DEFAULT_PARSER.escape(*arg)
104
- end
105
- alias encode escape
106
- #
107
- # == Synopsis
108
- #
109
- # Bundler::URI.unescape(str)
110
- #
111
- # == Args
112
- #
113
- # +str+::
114
- # String to unescape.
115
- #
116
- # == Description
117
- #
118
- # This method is obsolete and should not be used. Instead, use
119
- # CGI.unescape, Bundler::URI.decode_www_form or Bundler::URI.decode_www_form_component
120
- # depending on your specific use case.
121
- #
122
- # == Usage
123
- #
124
- # require 'bundler/vendor/uri/lib/uri'
125
- #
126
- # enc_uri = Bundler::URI.escape("http://example.com/?a=\11\15")
127
- # # => "http://example.com/?a=%09%0D"
128
- #
129
- # Bundler::URI.unescape(enc_uri)
130
- # # => "http://example.com/?a=\t\r"
131
- #
132
- def unescape(*arg)
133
- warn "Bundler::URI.unescape is obsolete", uplevel: 1
134
- DEFAULT_PARSER.unescape(*arg)
135
- end
136
- alias decode unescape
137
- end # module Escape
67
+ module Schemes
68
+ end
69
+ private_constant :Schemes
138
70
 
139
- extend Escape
140
- include REGEXP
71
+ # Registers the given +klass+ as the class to be instantiated
72
+ # when parsing a \Bundler::URI with the given +scheme+:
73
+ #
74
+ # Bundler::URI.register_scheme('MS_SEARCH', Bundler::URI::Generic) # => Bundler::URI::Generic
75
+ # Bundler::URI.scheme_list['MS_SEARCH'] # => Bundler::URI::Generic
76
+ #
77
+ # Note that after calling String#upcase on +scheme+, it must be a valid
78
+ # constant name.
79
+ def self.register_scheme(scheme, klass)
80
+ Schemes.const_set(scheme.to_s.upcase, klass)
81
+ end
141
82
 
142
- @@schemes = {}
143
- # Returns a Hash of the defined schemes.
83
+ # Returns a hash of the defined schemes:
84
+ #
85
+ # Bundler::URI.scheme_list
86
+ # # =>
87
+ # {"MAILTO"=>Bundler::URI::MailTo,
88
+ # "LDAPS"=>Bundler::URI::LDAPS,
89
+ # "WS"=>Bundler::URI::WS,
90
+ # "HTTP"=>Bundler::URI::HTTP,
91
+ # "HTTPS"=>Bundler::URI::HTTPS,
92
+ # "LDAP"=>Bundler::URI::LDAP,
93
+ # "FILE"=>Bundler::URI::File,
94
+ # "FTP"=>Bundler::URI::FTP}
95
+ #
96
+ # Related: Bundler::URI.register_scheme.
144
97
  def self.scheme_list
145
- @@schemes
98
+ Schemes.constants.map { |name|
99
+ [name.to_s.upcase, Schemes.const_get(name)]
100
+ }.to_h
101
+ end
102
+
103
+ INITIAL_SCHEMES = scheme_list
104
+ private_constant :INITIAL_SCHEMES
105
+ Ractor.make_shareable(INITIAL_SCHEMES) if defined?(Ractor)
106
+
107
+ # Returns a new object constructed from the given +scheme+, +arguments+,
108
+ # and +default+:
109
+ #
110
+ # - The new object is an instance of <tt>Bundler::URI.scheme_list[scheme.upcase]</tt>.
111
+ # - The object is initialized by calling the class initializer
112
+ # using +scheme+ and +arguments+.
113
+ # See Bundler::URI::Generic.new.
114
+ #
115
+ # Examples:
116
+ #
117
+ # values = ['john.doe', 'www.example.com', '123', nil, '/forum/questions/', nil, 'tag=networking&order=newest', 'top']
118
+ # Bundler::URI.for('https', *values)
119
+ # # => #<Bundler::URI::HTTPS https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
120
+ # Bundler::URI.for('foo', *values, default: Bundler::URI::HTTP)
121
+ # # => #<Bundler::URI::HTTP foo://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
122
+ #
123
+ def self.for(scheme, *arguments, default: Generic)
124
+ const_name = scheme.to_s.upcase
125
+
126
+ uri_class = INITIAL_SCHEMES[const_name]
127
+ uri_class ||= if /\A[A-Z]\w*\z/.match?(const_name) && Schemes.const_defined?(const_name, false)
128
+ Schemes.const_get(const_name, false)
129
+ end
130
+ uri_class ||= default
131
+
132
+ return uri_class.new(scheme, *arguments)
146
133
  end
147
134
 
148
135
  #
@@ -162,95 +149,49 @@ module Bundler::URI
162
149
  #
163
150
  class BadURIError < Error; end
164
151
 
165
- #
166
- # == Synopsis
167
- #
168
- # Bundler::URI::split(uri)
169
- #
170
- # == Args
171
- #
172
- # +uri+::
173
- # String with Bundler::URI.
174
- #
175
- # == Description
176
- #
177
- # Splits the string on following parts and returns array with result:
178
- #
179
- # * Scheme
180
- # * Userinfo
181
- # * Host
182
- # * Port
183
- # * Registry
184
- # * Path
185
- # * Opaque
186
- # * Query
187
- # * Fragment
188
- #
189
- # == Usage
190
- #
191
- # require 'bundler/vendor/uri/lib/uri'
192
- #
193
- # Bundler::URI.split("http://www.ruby-lang.org/")
194
- # # => ["http", nil, "www.ruby-lang.org", nil, nil, "/", nil, nil, nil]
152
+ # Returns a 9-element array representing the parts of the \Bundler::URI
153
+ # formed from the string +uri+;
154
+ # each array element is a string or +nil+:
155
+ #
156
+ # names = %w[scheme userinfo host port registry path opaque query fragment]
157
+ # values = Bundler::URI.split('https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
158
+ # names.zip(values)
159
+ # # =>
160
+ # [["scheme", "https"],
161
+ # ["userinfo", "john.doe"],
162
+ # ["host", "www.example.com"],
163
+ # ["port", "123"],
164
+ # ["registry", nil],
165
+ # ["path", "/forum/questions/"],
166
+ # ["opaque", nil],
167
+ # ["query", "tag=networking&order=newest"],
168
+ # ["fragment", "top"]]
195
169
  #
196
170
  def self.split(uri)
197
171
  RFC3986_PARSER.split(uri)
198
172
  end
199
173
 
174
+ # Returns a new \Bundler::URI object constructed from the given string +uri+:
200
175
  #
201
- # == Synopsis
202
- #
203
- # Bundler::URI::parse(uri_str)
204
- #
205
- # == Args
206
- #
207
- # +uri_str+::
208
- # String with Bundler::URI.
209
- #
210
- # == Description
211
- #
212
- # Creates one of the Bundler::URI's subclasses instance from the string.
176
+ # Bundler::URI.parse('https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
177
+ # # => #<Bundler::URI::HTTPS https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
178
+ # Bundler::URI.parse('http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
179
+ # # => #<Bundler::URI::HTTP http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
213
180
  #
214
- # == Raises
215
- #
216
- # Bundler::URI::InvalidURIError::
217
- # Raised if Bundler::URI given is not a correct one.
218
- #
219
- # == Usage
220
- #
221
- # require 'bundler/vendor/uri/lib/uri'
222
- #
223
- # uri = Bundler::URI.parse("http://www.ruby-lang.org/")
224
- # # => #<Bundler::URI::HTTP http://www.ruby-lang.org/>
225
- # uri.scheme
226
- # # => "http"
227
- # uri.host
228
- # # => "www.ruby-lang.org"
229
- #
230
- # It's recommended to first ::escape the provided +uri_str+ if there are any
231
- # invalid Bundler::URI characters.
181
+ # It's recommended to first ::escape string +uri+
182
+ # if it may contain invalid Bundler::URI characters.
232
183
  #
233
184
  def self.parse(uri)
234
185
  RFC3986_PARSER.parse(uri)
235
186
  end
236
187
 
188
+ # Merges the given Bundler::URI strings +str+
189
+ # per {RFC 2396}[https://www.rfc-editor.org/rfc/rfc2396.html].
237
190
  #
238
- # == Synopsis
191
+ # Each string in +str+ is converted to an
192
+ # {RFC3986 Bundler::URI}[https://www.rfc-editor.org/rfc/rfc3986.html] before being merged.
239
193
  #
240
- # Bundler::URI::join(str[, str, ...])
241
- #
242
- # == Args
243
- #
244
- # +str+::
245
- # String(s) to work with, will be converted to RFC3986 URIs before merging.
246
- #
247
- # == Description
248
- #
249
- # Joins URIs.
250
- #
251
- # == Usage
252
- #
253
- # require 'bundler/vendor/uri/lib/uri'
194
+ # Examples:
254
195
  #
255
196
  # Bundler::URI.join("http://example.com/","main.rbx")
256
197
  # # => #<Bundler::URI::HTTP http://example.com/main.rbx>
@@ -295,7 +236,7 @@ module Bundler::URI
295
236
  # Bundler::URI.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.")
296
237
  # # => ["http://foo.example.com/bla", "mailto:test@example.com"]
297
238
  #
298
- def self.extract(str, schemes = nil, &block)
239
+ def self.extract(str, schemes = nil, &block) # :nodoc:
299
240
  warn "Bundler::URI.extract is obsolete", uplevel: 1 if $VERBOSE
300
241
  DEFAULT_PARSER.extract(str, schemes, &block)
301
242
  end
@@ -315,7 +256,7 @@ module Bundler::URI
315
256
  #
316
257
  # Returns a Regexp object which matches to Bundler::URI-like strings.
317
258
  # The Regexp object returned by this method includes arbitrary
318
- # number of capture group (parentheses). Never rely on it's number.
259
+ # number of capture group (parentheses). Never rely on its number.
319
260
  #
320
261
  # == Usage
321
262
  #
@@ -332,7 +273,7 @@ module Bundler::URI
332
273
  # p $&
333
274
  # end
334
275
  #
335
- def self.regexp(schemes = nil)
276
+ def self.regexp(schemes = nil)# :nodoc:
336
277
  warn "Bundler::URI.regexp is obsolete", uplevel: 1 if $VERBOSE
337
278
  DEFAULT_PARSER.make_regexp(schemes)
338
279
  end
@@ -341,6 +282,7 @@ module Bundler::URI
341
282
  256.times do |i|
342
283
  TBLENCWWWCOMP_[-i.chr] = -('%%%02X' % i)
343
284
  end
285
+ TBLENCURICOMP_ = TBLENCWWWCOMP_.dup.freeze
344
286
  TBLENCWWWCOMP_[' '] = '+'
345
287
  TBLENCWWWCOMP_.freeze
346
288
  TBLDECWWWCOMP_ = {} # :nodoc:
@@ -354,18 +296,91 @@ module Bundler::URI
354
296
  TBLDECWWWCOMP_['+'] = ' '
355
297
  TBLDECWWWCOMP_.freeze
356
298
 
357
- # Encodes given +str+ to URL-encoded form data.
299
+ # Returns a URL-encoded string derived from the given string +str+.
300
+ #
301
+ # The returned string:
302
+ #
303
+ # - Preserves:
304
+ #
305
+ # - Characters <tt>'*'</tt>, <tt>'.'</tt>, <tt>'-'</tt>, and <tt>'_'</tt>.
306
+ # - Character in ranges <tt>'a'..'z'</tt>, <tt>'A'..'Z'</tt>,
307
+ # and <tt>'0'..'9'</tt>.
308
+ #
309
+ # Example:
358
310
  #
359
- # This method doesn't convert *, -, ., 0-9, A-Z, _, a-z, but does convert SP
360
- # (ASCII space) to + and converts others to %XX.
311
+ # Bundler::URI.encode_www_form_component('*.-_azAZ09')
312
+ # # => "*.-_azAZ09"
361
313
  #
362
- # If +enc+ is given, convert +str+ to the encoding before percent encoding.
314
+ # - Converts:
363
315
  #
364
- # This is an implementation of
365
- # http://www.w3.org/TR/2013/CR-html5-20130806/forms.html#url-encoded-form-data.
316
+ # - Character <tt>' '</tt> to character <tt>'+'</tt>.
317
+ # - Any other character to "percent notation";
318
+ # the percent notation for character <i>c</i> is <tt>'%%%X' % c.ord</tt>.
366
319
  #
367
- # See Bundler::URI.decode_www_form_component, Bundler::URI.encode_www_form.
320
+ # Example:
321
+ #
322
+ # Bundler::URI.encode_www_form_component('Here are some punctuation characters: ,;?:')
323
+ # # => "Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A"
324
+ #
325
+ # Encoding:
326
+ #
327
+ # - If +str+ has encoding Encoding::ASCII_8BIT, argument +enc+ is ignored.
328
+ # - Otherwise +str+ is converted first to Encoding::UTF_8
329
+ # (with suitable character replacements),
330
+ # and then to encoding +enc+.
331
+ #
332
+ # In either case, the returned string has forced encoding Encoding::US_ASCII.
333
+ #
334
+ # Related: Bundler::URI.encode_uri_component (encodes <tt>' '</tt> as <tt>'%20'</tt>).
368
335
  def self.encode_www_form_component(str, enc=nil)
336
+ _encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCWWWCOMP_, str, enc)
337
+ end
338
+
339
+ # Returns a string decoded from the given \URL-encoded string +str+.
340
+ #
341
+ # The given string is first encoded as Encoding::ASCII-8BIT (using String#b),
342
+ # then decoded (as below), and finally force-encoded to the given encoding +enc+.
343
+ #
344
+ # The returned string:
345
+ #
346
+ # - Preserves:
347
+ #
348
+ # - Characters <tt>'*'</tt>, <tt>'.'</tt>, <tt>'-'</tt>, and <tt>'_'</tt>.
349
+ # - Character in ranges <tt>'a'..'z'</tt>, <tt>'A'..'Z'</tt>,
350
+ # and <tt>'0'..'9'</tt>.
351
+ #
352
+ # Example:
353
+ #
354
+ # Bundler::URI.decode_www_form_component('*.-_azAZ09')
355
+ # # => "*.-_azAZ09"
356
+ #
357
+ # - Converts:
358
+ #
359
+ # - Character <tt>'+'</tt> to character <tt>' '</tt>.
360
+ # - Each "percent notation" to an ASCII character.
361
+ #
362
+ # Example:
363
+ #
364
+ # Bundler::URI.decode_www_form_component('Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A')
365
+ # # => "Here are some punctuation characters: ,;?:"
366
+ #
367
+ # Related: Bundler::URI.decode_uri_component (preserves <tt>'+'</tt>).
368
+ def self.decode_www_form_component(str, enc=Encoding::UTF_8)
369
+ _decode_uri_component(/\+|%\h\h/, str, enc)
370
+ end
371
+
372
+ # Like Bundler::URI.encode_www_form_component, except that <tt>' '</tt> (space)
373
+ # is encoded as <tt>'%20'</tt> (instead of <tt>'+'</tt>).
374
+ def self.encode_uri_component(str, enc=nil)
375
+ _encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCURICOMP_, str, enc)
376
+ end
377
+
378
+ # Like Bundler::URI.decode_www_form_component, except that <tt>'+'</tt> is preserved.
379
+ def self.decode_uri_component(str, enc=Encoding::UTF_8)
380
+ _decode_uri_component(/%\h\h/, str, enc)
381
+ end
382
+
383
+ def self._encode_uri_component(regexp, table, str, enc)
369
384
  str = str.to_s.dup
370
385
  if str.encoding != Encoding::ASCII_8BIT
371
386
  if enc && enc != Encoding::ASCII_8BIT
@@ -374,47 +389,115 @@ module Bundler::URI
374
389
  end
375
390
  str.force_encoding(Encoding::ASCII_8BIT)
376
391
  end
377
- str.gsub!(/[^*\-.0-9A-Z_a-z]/, TBLENCWWWCOMP_)
392
+ str.gsub!(regexp, table)
378
393
  str.force_encoding(Encoding::US_ASCII)
379
394
  end
395
+ private_class_method :_encode_uri_component
380
396
 
381
- # Decodes given +str+ of URL-encoded form data.
382
- #
383
- # This decodes + to SP.
384
- #
385
- # See Bundler::URI.encode_www_form_component, Bundler::URI.decode_www_form.
386
- def self.decode_www_form_component(str, enc=Encoding::UTF_8)
387
- raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/ =~ str
388
- str.b.gsub(/\+|%\h\h/, TBLDECWWWCOMP_).force_encoding(enc)
397
+ def self._decode_uri_component(regexp, str, enc)
398
+ raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/.match?(str)
399
+ str.b.gsub(regexp, TBLDECWWWCOMP_).force_encoding(enc)
389
400
  end
401
+ private_class_method :_decode_uri_component
390
402
 
391
- # Generates URL-encoded form data from given +enum+.
403
+ # Returns a URL-encoded string derived from the given
404
+ # {Enumerable}[https://docs.ruby-lang.org/en/master/Enumerable.html#module-Enumerable-label-Enumerable+in+Ruby+Classes]
405
+ # +enum+.
406
+ #
407
+ # The result is suitable for use as form data
408
+ # for an \HTTP request whose <tt>Content-Type</tt> is
409
+ # <tt>'application/x-www-form-urlencoded'</tt>.
410
+ #
411
+ # The returned string consists of the elements of +enum+,
412
+ # each converted to one or more URL-encoded strings,
413
+ # and all joined with character <tt>'&'</tt>.
414
+ #
415
+ # Simple examples:
392
416
  #
393
- # This generates application/x-www-form-urlencoded data defined in HTML5
394
- # from given an Enumerable object.
417
+ # Bundler::URI.encode_www_form([['foo', 0], ['bar', 1], ['baz', 2]])
418
+ # # => "foo=0&bar=1&baz=2"
419
+ # Bundler::URI.encode_www_form({foo: 0, bar: 1, baz: 2})
420
+ # # => "foo=0&bar=1&baz=2"
395
421
  #
396
- # This internally uses Bundler::URI.encode_www_form_component(str).
422
+ # The returned string is formed using method Bundler::URI.encode_www_form_component,
423
+ # which converts certain characters:
397
424
  #
398
- # This method doesn't convert the encoding of given items, so convert them
399
- # before calling this method if you want to send data as other than original
400
- # encoding or mixed encoding data. (Strings which are encoded in an HTML5
401
- # ASCII incompatible encoding are converted to UTF-8.)
425
+ # Bundler::URI.encode_www_form('f#o': '/', 'b-r': '$', 'b z': '@')
426
+ # # => "f%23o=%2F&b-r=%24&b+z=%40"
402
427
  #
403
- # This method doesn't handle files. When you send a file, use
404
- # multipart/form-data.
428
+ # When +enum+ is Array-like, each element +ele+ is converted to a field:
405
429
  #
406
- # This refers http://url.spec.whatwg.org/#concept-urlencoded-serializer
430
+ # - If +ele+ is an array of two or more elements,
431
+ # the field is formed from its first two elements
432
+ # (and any additional elements are ignored):
407
433
  #
408
- # Bundler::URI.encode_www_form([["q", "ruby"], ["lang", "en"]])
409
- # #=> "q=ruby&lang=en"
410
- # Bundler::URI.encode_www_form("q" => "ruby", "lang" => "en")
411
- # #=> "q=ruby&lang=en"
412
- # Bundler::URI.encode_www_form("q" => ["ruby", "perl"], "lang" => "en")
413
- # #=> "q=ruby&q=perl&lang=en"
414
- # Bundler::URI.encode_www_form([["q", "ruby"], ["q", "perl"], ["lang", "en"]])
415
- # #=> "q=ruby&q=perl&lang=en"
434
+ # name = Bundler::URI.encode_www_form_component(ele[0], enc)
435
+ # value = Bundler::URI.encode_www_form_component(ele[1], enc)
436
+ # "#{name}=#{value}"
437
+ #
438
+ # Examples:
439
+ #
440
+ # Bundler::URI.encode_www_form([%w[foo bar], %w[baz bat bah]])
441
+ # # => "foo=bar&baz=bat"
442
+ # Bundler::URI.encode_www_form([['foo', 0], ['bar', :baz, 'bat']])
443
+ # # => "foo=0&bar=baz"
444
+ #
445
+ # - If +ele+ is an array of one element,
446
+ # the field is formed from <tt>ele[0]</tt>:
447
+ #
448
+ # Bundler::URI.encode_www_form_component(ele[0])
449
+ #
450
+ # Example:
451
+ #
452
+ # Bundler::URI.encode_www_form([['foo'], [:bar], [0]])
453
+ # # => "foo&bar&0"
454
+ #
455
+ # - Otherwise the field is formed from +ele+:
456
+ #
457
+ # Bundler::URI.encode_www_form_component(ele)
458
+ #
459
+ # Example:
460
+ #
461
+ # Bundler::URI.encode_www_form(['foo', :bar, 0])
462
+ # # => "foo&bar&0"
463
+ #
464
+ # The elements of an Array-like +enum+ may be mixture:
465
+ #
466
+ # Bundler::URI.encode_www_form([['foo', 0], ['bar', 1, 2], ['baz'], :bat])
467
+ # # => "foo=0&bar=1&baz&bat"
468
+ #
469
+ # When +enum+ is Hash-like,
470
+ # each +key+/+value+ pair is converted to one or more fields:
471
+ #
472
+ # - If +value+ is
473
+ # {Array-convertible}[https://docs.ruby-lang.org/en/master/implicit_conversion_rdoc.html#label-Array-Convertible+Objects],
474
+ # each element +ele+ in +value+ is paired with +key+ to form a field:
475
+ #
476
+ # name = Bundler::URI.encode_www_form_component(key, enc)
477
+ # value = Bundler::URI.encode_www_form_component(ele, enc)
478
+ # "#{name}=#{value}"
479
+ #
480
+ # Example:
481
+ #
482
+ # Bundler::URI.encode_www_form({foo: [:bar, 1], baz: [:bat, :bam, 2]})
483
+ # # => "foo=bar&foo=1&baz=bat&baz=bam&baz=2"
484
+ #
485
+ # - Otherwise, +key+ and +value+ are paired to form a field:
486
+ #
487
+ # name = Bundler::URI.encode_www_form_component(key, enc)
488
+ # value = Bundler::URI.encode_www_form_component(value, enc)
489
+ # "#{name}=#{value}"
490
+ #
491
+ # Example:
492
+ #
493
+ # Bundler::URI.encode_www_form({foo: 0, bar: 1, baz: 2})
494
+ # # => "foo=0&bar=1&baz=2"
495
+ #
496
+ # The elements of a Hash-like +enum+ may be mixture:
497
+ #
498
+ # Bundler::URI.encode_www_form({foo: [0, 1], bar: 2})
499
+ # # => "foo=0&foo=1&bar=2"
416
500
  #
417
- # See Bundler::URI.encode_www_form_component, Bundler::URI.decode_www_form.
418
501
  def self.encode_www_form(enum, enc=nil)
419
502
  enum.map do |k,v|
420
503
  if v.nil?
@@ -435,22 +518,39 @@ module Bundler::URI
435
518
  end.join('&')
436
519
  end
437
520
 
438
- # Decodes URL-encoded form data from given +str+.
521
+ # Returns name/value pairs derived from the given string +str+,
522
+ # which must be an ASCII string.
523
+ #
524
+ # The method may be used to decode the body of Net::HTTPResponse object +res+
525
+ # for which <tt>res['Content-Type']</tt> is <tt>'application/x-www-form-urlencoded'</tt>.
439
526
  #
440
- # This decodes application/x-www-form-urlencoded data
441
- # and returns an array of key-value arrays.
527
+ # The returned data is an array of 2-element subarrays;
528
+ # each subarray is a name/value pair (both are strings).
529
+ # Each returned string has encoding +enc+,
530
+ # and has had invalid characters removed via
531
+ # {String#scrub}[https://docs.ruby-lang.org/en/master/String.html#method-i-scrub].
442
532
  #
443
- # This refers http://url.spec.whatwg.org/#concept-urlencoded-parser,
444
- # so this supports only &-separator, and doesn't support ;-separator.
533
+ # A simple example:
445
534
  #
446
- # ary = Bundler::URI.decode_www_form("a=1&a=2&b=3")
447
- # ary #=> [['a', '1'], ['a', '2'], ['b', '3']]
448
- # ary.assoc('a').last #=> '1'
449
- # ary.assoc('b').last #=> '3'
450
- # ary.rassoc('a').last #=> '2'
451
- # Hash[ary] #=> {"a"=>"2", "b"=>"3"}
535
+ # Bundler::URI.decode_www_form('foo=0&bar=1&baz')
536
+ # # => [["foo", "0"], ["bar", "1"], ["baz", ""]]
537
+ #
538
+ # The returned strings have certain conversions,
539
+ # similar to those performed in Bundler::URI.decode_www_form_component:
540
+ #
541
+ # Bundler::URI.decode_www_form('f%23o=%2F&b-r=%24&b+z=%40')
542
+ # # => [["f#o", "/"], ["b-r", "$"], ["b z", "@"]]
543
+ #
544
+ # The given string may contain consecutive separators:
545
+ #
546
+ # Bundler::URI.decode_www_form('foo=0&&bar=1&&baz=2')
547
+ # # => [["foo", "0"], ["", ""], ["bar", "1"], ["", ""], ["baz", "2"]]
548
+ #
549
+ # A different separator may be specified:
550
+ #
551
+ # Bundler::URI.decode_www_form('foo=0--bar=1--baz', separator: '--')
552
+ # # => [["foo", "0"], ["bar", "1"], ["baz", ""]]
452
553
  #
453
- # See Bundler::URI.decode_www_form_component, Bundler::URI.encode_www_form.
454
554
  def self.decode_www_form(str, enc=Encoding::UTF_8, separator: '&', use__charset_: false, isindex: false)
455
555
  raise ArgumentError, "the input of #{self.name}.#{__method__} must be ASCII only string" unless str.ascii_only?
456
556
  ary = []
@@ -716,6 +816,7 @@ module Bundler::URI
716
816
  "utf-16"=>"utf-16le",
717
817
  "utf-16le"=>"utf-16le",
718
818
  } # :nodoc:
819
+ Ractor.make_shareable(WEB_ENCODINGS_) if defined?(Ractor)
719
820
 
720
821
  # :nodoc:
721
822
  # return encoding or nil
@@ -728,7 +829,15 @@ end # module Bundler::URI
728
829
  module Bundler
729
830
 
730
831
  #
731
- # Returns +uri+ converted to an Bundler::URI object.
832
+ # Returns a \Bundler::URI object derived from the given +uri+,
833
+ # which may be a \Bundler::URI string or an existing \Bundler::URI object:
834
+ #
835
+ # # Returns a new Bundler::URI.
836
+ # uri = Bundler::URI('http://github.com/ruby/ruby')
837
+ # # => #<Bundler::URI::HTTP http://github.com/ruby/ruby>
838
+ # # Returns the given Bundler::URI.
839
+ # Bundler::URI(uri)
840
+ # # => #<Bundler::URI::HTTP http://github.com/ruby/ruby>
732
841
  #
733
842
  def URI(uri)
734
843
  if uri.is_a?(Bundler::URI::Generic)
@@ -33,6 +33,9 @@ module Bundler::URI
33
33
  # If an Array is used, the components must be passed in the
34
34
  # order <code>[host, path]</code>.
35
35
  #
36
+ # A path from e.g. the File class should be escaped before
37
+ # being passed.
38
+ #
36
39
  # Examples:
37
40
  #
38
41
  # require 'bundler/vendor/uri/lib/uri'
@@ -44,6 +47,9 @@ module Bundler::URI
44
47
  # :path => '/ruby/src'})
45
48
  # uri2.to_s # => "file://host.example.com/ruby/src"
46
49
  #
50
+ # uri3 = Bundler::URI::File.build({:path => Bundler::URI::escape('/path/my file.txt')})
51
+ # uri3.to_s # => "file:///path/my%20file.txt"
52
+ #
47
53
  def self.build(args)
48
54
  tmp = Util::make_components_hash(self, args)
49
55
  super(tmp)
@@ -90,5 +96,5 @@ module Bundler::URI
90
96
  end
91
97
  end
92
98
 
93
- @@schemes['FILE'] = File
99
+ register_scheme 'FILE', File
94
100
  end