bundler-clone 4.0.15

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 (350) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +5670 -0
  3. data/LICENSE.md +22 -0
  4. data/README.md +58 -0
  5. data/bundler.gemspec +46 -0
  6. data/exe/bundle +29 -0
  7. data/exe/bundler +4 -0
  8. data/lib/bundler/.document +1 -0
  9. data/lib/bundler/build_metadata.rb +44 -0
  10. data/lib/bundler/capistrano.rb +4 -0
  11. data/lib/bundler/checksum.rb +270 -0
  12. data/lib/bundler/ci_detector.rb +75 -0
  13. data/lib/bundler/cli/add.rb +62 -0
  14. data/lib/bundler/cli/binstubs.rb +57 -0
  15. data/lib/bundler/cli/cache.rb +32 -0
  16. data/lib/bundler/cli/check.rb +40 -0
  17. data/lib/bundler/cli/clean.rb +25 -0
  18. data/lib/bundler/cli/common.rb +161 -0
  19. data/lib/bundler/cli/config.rb +208 -0
  20. data/lib/bundler/cli/console.rb +47 -0
  21. data/lib/bundler/cli/doctor/diagnose.rb +167 -0
  22. data/lib/bundler/cli/doctor/ssl.rb +249 -0
  23. data/lib/bundler/cli/doctor.rb +33 -0
  24. data/lib/bundler/cli/exec.rb +114 -0
  25. data/lib/bundler/cli/fund.rb +36 -0
  26. data/lib/bundler/cli/gem.rb +493 -0
  27. data/lib/bundler/cli/info.rb +83 -0
  28. data/lib/bundler/cli/init.rb +51 -0
  29. data/lib/bundler/cli/install.rb +127 -0
  30. data/lib/bundler/cli/issue.rb +41 -0
  31. data/lib/bundler/cli/list.rb +97 -0
  32. data/lib/bundler/cli/lock.rb +94 -0
  33. data/lib/bundler/cli/open.rb +29 -0
  34. data/lib/bundler/cli/outdated.rb +337 -0
  35. data/lib/bundler/cli/platform.rb +48 -0
  36. data/lib/bundler/cli/plugin.rb +39 -0
  37. data/lib/bundler/cli/pristine.rb +64 -0
  38. data/lib/bundler/cli/remove.rb +17 -0
  39. data/lib/bundler/cli/show.rb +71 -0
  40. data/lib/bundler/cli/update.rb +125 -0
  41. data/lib/bundler/cli.rb +829 -0
  42. data/lib/bundler/compact_index_client/cache.rb +96 -0
  43. data/lib/bundler/compact_index_client/cache_file.rb +148 -0
  44. data/lib/bundler/compact_index_client/parser.rb +87 -0
  45. data/lib/bundler/compact_index_client/updater.rb +105 -0
  46. data/lib/bundler/compact_index_client.rb +92 -0
  47. data/lib/bundler/constants.rb +14 -0
  48. data/lib/bundler/current_ruby.rb +94 -0
  49. data/lib/bundler/definition.rb +1304 -0
  50. data/lib/bundler/dependency.rb +151 -0
  51. data/lib/bundler/deployment.rb +6 -0
  52. data/lib/bundler/deprecate.rb +44 -0
  53. data/lib/bundler/digest.rb +71 -0
  54. data/lib/bundler/dsl.rb +642 -0
  55. data/lib/bundler/endpoint_specification.rb +184 -0
  56. data/lib/bundler/env.rb +148 -0
  57. data/lib/bundler/environment_preserver.rb +69 -0
  58. data/lib/bundler/errors.rb +277 -0
  59. data/lib/bundler/feature_flag.rb +20 -0
  60. data/lib/bundler/fetcher/base.rb +55 -0
  61. data/lib/bundler/fetcher/compact_index.rb +133 -0
  62. data/lib/bundler/fetcher/dependency.rb +85 -0
  63. data/lib/bundler/fetcher/downloader.rb +116 -0
  64. data/lib/bundler/fetcher/gem_remote_fetcher.rb +24 -0
  65. data/lib/bundler/fetcher/index.rb +25 -0
  66. data/lib/bundler/fetcher.rb +365 -0
  67. data/lib/bundler/force_platform.rb +16 -0
  68. data/lib/bundler/friendly_errors.rb +127 -0
  69. data/lib/bundler/gem_helper.rb +237 -0
  70. data/lib/bundler/gem_tasks.rb +7 -0
  71. data/lib/bundler/gem_version_promoter.rb +147 -0
  72. data/lib/bundler/index.rb +203 -0
  73. data/lib/bundler/injector.rb +284 -0
  74. data/lib/bundler/inline.rb +106 -0
  75. data/lib/bundler/installer/gem_installer.rb +88 -0
  76. data/lib/bundler/installer/parallel_installer.rb +280 -0
  77. data/lib/bundler/installer/standalone.rb +113 -0
  78. data/lib/bundler/installer.rb +241 -0
  79. data/lib/bundler/lazy_specification.rb +270 -0
  80. data/lib/bundler/lockfile_generator.rb +119 -0
  81. data/lib/bundler/lockfile_parser.rb +328 -0
  82. data/lib/bundler/man/.document +1 -0
  83. data/lib/bundler/man/bundle-add.1 +79 -0
  84. data/lib/bundler/man/bundle-add.1.ronn +92 -0
  85. data/lib/bundler/man/bundle-binstubs.1 +30 -0
  86. data/lib/bundler/man/bundle-binstubs.1.ronn +42 -0
  87. data/lib/bundler/man/bundle-cache.1 +56 -0
  88. data/lib/bundler/man/bundle-cache.1.ronn +95 -0
  89. data/lib/bundler/man/bundle-check.1 +21 -0
  90. data/lib/bundler/man/bundle-check.1.ronn +26 -0
  91. data/lib/bundler/man/bundle-clean.1 +17 -0
  92. data/lib/bundler/man/bundle-clean.1.ronn +18 -0
  93. data/lib/bundler/man/bundle-config.1 +339 -0
  94. data/lib/bundler/man/bundle-config.1.ronn +455 -0
  95. data/lib/bundler/man/bundle-console.1 +33 -0
  96. data/lib/bundler/man/bundle-console.1.ronn +39 -0
  97. data/lib/bundler/man/bundle-doctor.1 +69 -0
  98. data/lib/bundler/man/bundle-doctor.1.ronn +77 -0
  99. data/lib/bundler/man/bundle-env.1 +9 -0
  100. data/lib/bundler/man/bundle-env.1.ronn +10 -0
  101. data/lib/bundler/man/bundle-exec.1 +104 -0
  102. data/lib/bundler/man/bundle-exec.1.ronn +150 -0
  103. data/lib/bundler/man/bundle-fund.1 +22 -0
  104. data/lib/bundler/man/bundle-fund.1.ronn +25 -0
  105. data/lib/bundler/man/bundle-gem.1 +107 -0
  106. data/lib/bundler/man/bundle-gem.1.ronn +150 -0
  107. data/lib/bundler/man/bundle-help.1 +9 -0
  108. data/lib/bundler/man/bundle-help.1.ronn +12 -0
  109. data/lib/bundler/man/bundle-info.1 +17 -0
  110. data/lib/bundler/man/bundle-info.1.ronn +21 -0
  111. data/lib/bundler/man/bundle-init.1 +20 -0
  112. data/lib/bundler/man/bundle-init.1.ronn +32 -0
  113. data/lib/bundler/man/bundle-install.1 +178 -0
  114. data/lib/bundler/man/bundle-install.1.ronn +314 -0
  115. data/lib/bundler/man/bundle-issue.1 +45 -0
  116. data/lib/bundler/man/bundle-issue.1.ronn +37 -0
  117. data/lib/bundler/man/bundle-licenses.1 +9 -0
  118. data/lib/bundler/man/bundle-licenses.1.ronn +10 -0
  119. data/lib/bundler/man/bundle-list.1 +40 -0
  120. data/lib/bundler/man/bundle-list.1.ronn +41 -0
  121. data/lib/bundler/man/bundle-lock.1 +75 -0
  122. data/lib/bundler/man/bundle-lock.1.ronn +115 -0
  123. data/lib/bundler/man/bundle-open.1 +32 -0
  124. data/lib/bundler/man/bundle-open.1.ronn +28 -0
  125. data/lib/bundler/man/bundle-outdated.1 +106 -0
  126. data/lib/bundler/man/bundle-outdated.1.ronn +117 -0
  127. data/lib/bundler/man/bundle-platform.1 +49 -0
  128. data/lib/bundler/man/bundle-platform.1.ronn +49 -0
  129. data/lib/bundler/man/bundle-plugin.1 +76 -0
  130. data/lib/bundler/man/bundle-plugin.1.ronn +84 -0
  131. data/lib/bundler/man/bundle-pristine.1 +23 -0
  132. data/lib/bundler/man/bundle-pristine.1.ronn +34 -0
  133. data/lib/bundler/man/bundle-remove.1 +15 -0
  134. data/lib/bundler/man/bundle-remove.1.ronn +16 -0
  135. data/lib/bundler/man/bundle-show.1 +16 -0
  136. data/lib/bundler/man/bundle-show.1.ronn +21 -0
  137. data/lib/bundler/man/bundle-update.1 +284 -0
  138. data/lib/bundler/man/bundle-update.1.ronn +367 -0
  139. data/lib/bundler/man/bundle-version.1 +22 -0
  140. data/lib/bundler/man/bundle-version.1.ronn +24 -0
  141. data/lib/bundler/man/bundle.1 +93 -0
  142. data/lib/bundler/man/bundle.1.ronn +107 -0
  143. data/lib/bundler/man/gemfile.5 +503 -0
  144. data/lib/bundler/man/gemfile.5.ronn +586 -0
  145. data/lib/bundler/man/index.txt +31 -0
  146. data/lib/bundler/match_metadata.rb +30 -0
  147. data/lib/bundler/match_platform.rb +42 -0
  148. data/lib/bundler/match_remote_metadata.rb +29 -0
  149. data/lib/bundler/materialization.rb +59 -0
  150. data/lib/bundler/mirror.rb +221 -0
  151. data/lib/bundler/plugin/api/source.rb +330 -0
  152. data/lib/bundler/plugin/api.rb +81 -0
  153. data/lib/bundler/plugin/dsl.rb +53 -0
  154. data/lib/bundler/plugin/events.rb +85 -0
  155. data/lib/bundler/plugin/index.rb +203 -0
  156. data/lib/bundler/plugin/installer/git.rb +34 -0
  157. data/lib/bundler/plugin/installer/path.rb +26 -0
  158. data/lib/bundler/plugin/installer/rubygems.rb +19 -0
  159. data/lib/bundler/plugin/installer.rb +123 -0
  160. data/lib/bundler/plugin/source_list.rb +31 -0
  161. data/lib/bundler/plugin/unloaded_source.rb +25 -0
  162. data/lib/bundler/plugin.rb +387 -0
  163. data/lib/bundler/process_lock.rb +20 -0
  164. data/lib/bundler/remote_specification.rb +126 -0
  165. data/lib/bundler/resolver/base.rb +127 -0
  166. data/lib/bundler/resolver/candidate.rb +85 -0
  167. data/lib/bundler/resolver/incompatibility.rb +15 -0
  168. data/lib/bundler/resolver/package.rb +95 -0
  169. data/lib/bundler/resolver/root.rb +25 -0
  170. data/lib/bundler/resolver/spec_group.rb +74 -0
  171. data/lib/bundler/resolver/strategy.rb +43 -0
  172. data/lib/bundler/resolver.rb +603 -0
  173. data/lib/bundler/retry.rb +92 -0
  174. data/lib/bundler/ruby_dsl.rb +67 -0
  175. data/lib/bundler/ruby_version.rb +135 -0
  176. data/lib/bundler/rubygems_ext.rb +503 -0
  177. data/lib/bundler/rubygems_gem_installer.rb +206 -0
  178. data/lib/bundler/rubygems_integration.rb +456 -0
  179. data/lib/bundler/runtime.rb +331 -0
  180. data/lib/bundler/safe_marshal.rb +31 -0
  181. data/lib/bundler/self_manager.rb +197 -0
  182. data/lib/bundler/settings/validator.rb +86 -0
  183. data/lib/bundler/settings.rb +585 -0
  184. data/lib/bundler/setup.rb +39 -0
  185. data/lib/bundler/shared_helpers.rb +392 -0
  186. data/lib/bundler/source/gemspec.rb +19 -0
  187. data/lib/bundler/source/git/git_proxy.rb +509 -0
  188. data/lib/bundler/source/git.rb +451 -0
  189. data/lib/bundler/source/metadata.rb +67 -0
  190. data/lib/bundler/source/path/installer.rb +53 -0
  191. data/lib/bundler/source/path.rb +256 -0
  192. data/lib/bundler/source/rubygems/remote.rb +86 -0
  193. data/lib/bundler/source/rubygems.rb +606 -0
  194. data/lib/bundler/source/rubygems_aggregate.rb +71 -0
  195. data/lib/bundler/source.rb +120 -0
  196. data/lib/bundler/source_list.rb +240 -0
  197. data/lib/bundler/source_map.rb +72 -0
  198. data/lib/bundler/spec_set.rb +390 -0
  199. data/lib/bundler/stub_specification.rb +147 -0
  200. data/lib/bundler/templates/.document +1 -0
  201. data/lib/bundler/templates/Executable +16 -0
  202. data/lib/bundler/templates/Executable.standalone +14 -0
  203. data/lib/bundler/templates/Gemfile +5 -0
  204. data/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
  205. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +10 -0
  206. data/lib/bundler/templates/newgem/Cargo.toml.tt +13 -0
  207. data/lib/bundler/templates/newgem/Gemfile.tt +24 -0
  208. data/lib/bundler/templates/newgem/LICENSE.txt.tt +21 -0
  209. data/lib/bundler/templates/newgem/README.md.tt +49 -0
  210. data/lib/bundler/templates/newgem/Rakefile.tt +72 -0
  211. data/lib/bundler/templates/newgem/bin/console.tt +11 -0
  212. data/lib/bundler/templates/newgem/bin/setup.tt +8 -0
  213. data/lib/bundler/templates/newgem/circleci/config.yml.tt +37 -0
  214. data/lib/bundler/templates/newgem/exe/newgem.tt +3 -0
  215. data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +22 -0
  216. data/lib/bundler/templates/newgem/ext/newgem/build.rs.tt +5 -0
  217. data/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt +10 -0
  218. data/lib/bundler/templates/newgem/ext/newgem/extconf-go.rb.tt +11 -0
  219. data/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
  220. data/lib/bundler/templates/newgem/ext/newgem/go.mod.tt +5 -0
  221. data/lib/bundler/templates/newgem/ext/newgem/newgem-go.c.tt +2 -0
  222. data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +9 -0
  223. data/lib/bundler/templates/newgem/ext/newgem/newgem.go.tt +31 -0
  224. data/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +6 -0
  225. data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +23 -0
  226. data/lib/bundler/templates/newgem/github/workflows/build-gems.yml.tt +69 -0
  227. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +48 -0
  228. data/lib/bundler/templates/newgem/gitignore.tt +23 -0
  229. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +27 -0
  230. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +9 -0
  231. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +15 -0
  232. data/lib/bundler/templates/newgem/newgem.gemspec.tt +58 -0
  233. data/lib/bundler/templates/newgem/rspec.tt +3 -0
  234. data/lib/bundler/templates/newgem/rubocop.yml.tt +8 -0
  235. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  236. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +19 -0
  237. data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +15 -0
  238. data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  239. data/lib/bundler/templates/newgem/test/minitest/test_helper.rb.tt +6 -0
  240. data/lib/bundler/templates/newgem/test/minitest/test_newgem.rb.tt +19 -0
  241. data/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
  242. data/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
  243. data/lib/bundler/ui/rg_proxy.rb +19 -0
  244. data/lib/bundler/ui/shell.rb +191 -0
  245. data/lib/bundler/ui/silent.rb +96 -0
  246. data/lib/bundler/ui.rb +9 -0
  247. data/lib/bundler/uri_credentials_filter.rb +43 -0
  248. data/lib/bundler/uri_normalizer.rb +23 -0
  249. data/lib/bundler/vendor/.document +1 -0
  250. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  251. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +227 -0
  252. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +3 -0
  253. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +56 -0
  254. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +230 -0
  255. data/lib/bundler/vendor/fileutils/COPYING +56 -0
  256. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +2701 -0
  257. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  258. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +41 -0
  259. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +65 -0
  260. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +80 -0
  261. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1153 -0
  262. data/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
  263. data/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
  264. data/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +169 -0
  265. data/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
  266. data/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +150 -0
  267. data/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
  268. data/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
  269. data/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
  270. data/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
  271. data/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +61 -0
  272. data/lib/bundler/vendor/pub_grub/lib/pub_grub/strategy.rb +42 -0
  273. data/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
  274. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
  275. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +129 -0
  276. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +423 -0
  277. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +236 -0
  278. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
  279. data/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
  280. data/lib/bundler/vendor/securerandom/COPYING +56 -0
  281. data/lib/bundler/vendor/securerandom/lib/securerandom.rb +102 -0
  282. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  283. data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +105 -0
  284. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +61 -0
  285. data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +108 -0
  286. data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +143 -0
  287. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +407 -0
  288. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +130 -0
  289. data/lib/bundler/vendor/thor/lib/thor/actions.rb +340 -0
  290. data/lib/bundler/vendor/thor/lib/thor/base.rb +825 -0
  291. data/lib/bundler/vendor/thor/lib/thor/command.rb +151 -0
  292. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +107 -0
  293. data/lib/bundler/vendor/thor/lib/thor/error.rb +106 -0
  294. data/lib/bundler/vendor/thor/lib/thor/group.rb +292 -0
  295. data/lib/bundler/vendor/thor/lib/thor/invocation.rb +178 -0
  296. data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +37 -0
  297. data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +88 -0
  298. data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +17 -0
  299. data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
  300. data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +86 -0
  301. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +195 -0
  302. data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +178 -0
  303. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +294 -0
  304. data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -0
  305. data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +72 -0
  306. data/lib/bundler/vendor/thor/lib/thor/runner.rb +335 -0
  307. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +384 -0
  308. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +112 -0
  309. data/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb +29 -0
  310. data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +81 -0
  311. data/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +118 -0
  312. data/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb +42 -0
  313. data/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb +38 -0
  314. data/lib/bundler/vendor/thor/lib/thor/shell.rb +81 -0
  315. data/lib/bundler/vendor/thor/lib/thor/util.rb +285 -0
  316. data/lib/bundler/vendor/thor/lib/thor/version.rb +3 -0
  317. data/lib/bundler/vendor/thor/lib/thor.rb +674 -0
  318. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  319. data/lib/bundler/vendor/tsort/lib/tsort.rb +455 -0
  320. data/lib/bundler/vendor/uri/COPYING +56 -0
  321. data/lib/bundler/vendor/uri/lib/uri/common.rb +922 -0
  322. data/lib/bundler/vendor/uri/lib/uri/file.rb +100 -0
  323. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +267 -0
  324. data/lib/bundler/vendor/uri/lib/uri/generic.rb +1592 -0
  325. data/lib/bundler/vendor/uri/lib/uri/http.rb +137 -0
  326. data/lib/bundler/vendor/uri/lib/uri/https.rb +23 -0
  327. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +261 -0
  328. data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +22 -0
  329. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +293 -0
  330. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +547 -0
  331. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +206 -0
  332. data/lib/bundler/vendor/uri/lib/uri/version.rb +6 -0
  333. data/lib/bundler/vendor/uri/lib/uri/ws.rb +83 -0
  334. data/lib/bundler/vendor/uri/lib/uri/wss.rb +23 -0
  335. data/lib/bundler/vendor/uri/lib/uri.rb +104 -0
  336. data/lib/bundler/vendored_fileutils.rb +4 -0
  337. data/lib/bundler/vendored_net_http.rb +23 -0
  338. data/lib/bundler/vendored_persistent.rb +11 -0
  339. data/lib/bundler/vendored_pub_grub.rb +4 -0
  340. data/lib/bundler/vendored_securerandom.rb +12 -0
  341. data/lib/bundler/vendored_thor.rb +8 -0
  342. data/lib/bundler/vendored_timeout.rb +12 -0
  343. data/lib/bundler/vendored_tsort.rb +4 -0
  344. data/lib/bundler/vendored_uri.rb +21 -0
  345. data/lib/bundler/version.rb +21 -0
  346. data/lib/bundler/vlad.rb +4 -0
  347. data/lib/bundler/worker.rb +125 -0
  348. data/lib/bundler/yaml_serializer.rb +98 -0
  349. data/lib/bundler.rb +691 -0
  350. metadata +409 -0
@@ -0,0 +1,922 @@
1
+ # frozen_string_literal: true
2
+ #--
3
+ # = uri/common.rb
4
+ #
5
+ # Author:: Akira Yamada <akira@ruby-lang.org>
6
+ # License::
7
+ # You can redistribute it and/or modify it under the same term as Ruby.
8
+ #
9
+ # See Bundler::URI for general documentation
10
+ #
11
+
12
+ require_relative "rfc2396_parser"
13
+ require_relative "rfc3986_parser"
14
+
15
+ module Bundler::URI
16
+ # The default parser instance for RFC 2396.
17
+ RFC2396_PARSER = RFC2396_Parser.new
18
+ Ractor.make_shareable(RFC2396_PARSER) if defined?(Ractor)
19
+
20
+ # The default parser instance for RFC 3986.
21
+ RFC3986_PARSER = RFC3986_Parser.new
22
+ Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor)
23
+
24
+ # The default parser instance.
25
+ DEFAULT_PARSER = RFC3986_PARSER
26
+ Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor)
27
+
28
+ # Set the default parser instance.
29
+ def self.parser=(parser = RFC3986_PARSER)
30
+ remove_const(:Parser) if defined?(::Bundler::URI::Parser)
31
+ const_set("Parser", parser.class)
32
+
33
+ remove_const(:PARSER) if defined?(::Bundler::URI::PARSER)
34
+ const_set("PARSER", parser)
35
+
36
+ remove_const(:REGEXP) if defined?(::Bundler::URI::REGEXP)
37
+ remove_const(:PATTERN) if defined?(::Bundler::URI::PATTERN)
38
+ if Parser == RFC2396_Parser
39
+ const_set("REGEXP", Bundler::URI::RFC2396_REGEXP)
40
+ const_set("PATTERN", Bundler::URI::RFC2396_REGEXP::PATTERN)
41
+ end
42
+
43
+ Parser.new.regexp.each_pair do |sym, str|
44
+ remove_const(sym) if const_defined?(sym, false)
45
+ const_set(sym, str)
46
+ end
47
+ end
48
+ self.parser = RFC3986_PARSER
49
+
50
+ def self.const_missing(const) # :nodoc:
51
+ if const == :REGEXP
52
+ warn "Bundler::URI::REGEXP is obsolete. Use Bundler::URI::RFC2396_REGEXP explicitly.", uplevel: 1 if $VERBOSE
53
+ Bundler::URI::RFC2396_REGEXP
54
+ elsif value = RFC2396_PARSER.regexp[const]
55
+ warn "Bundler::URI::#{const} is obsolete. Use Bundler::URI::RFC2396_PARSER.regexp[#{const.inspect}] explicitly.", uplevel: 1 if $VERBOSE
56
+ value
57
+ elsif value = RFC2396_Parser.const_get(const)
58
+ warn "Bundler::URI::#{const} is obsolete. Use Bundler::URI::RFC2396_Parser::#{const} explicitly.", uplevel: 1 if $VERBOSE
59
+ value
60
+ else
61
+ super
62
+ end
63
+ end
64
+
65
+ module Util # :nodoc:
66
+ def make_components_hash(klass, array_hash)
67
+ tmp = {}
68
+ if array_hash.kind_of?(Array) &&
69
+ array_hash.size == klass.component.size - 1
70
+ klass.component[1..-1].each_index do |i|
71
+ begin
72
+ tmp[klass.component[i + 1]] = array_hash[i].clone
73
+ rescue TypeError
74
+ tmp[klass.component[i + 1]] = array_hash[i]
75
+ end
76
+ end
77
+
78
+ elsif array_hash.kind_of?(Hash)
79
+ array_hash.each do |key, value|
80
+ begin
81
+ tmp[key] = value.clone
82
+ rescue TypeError
83
+ tmp[key] = value
84
+ end
85
+ end
86
+ else
87
+ raise ArgumentError,
88
+ "expected Array of or Hash of components of #{klass} (#{klass.component[1..-1].join(', ')})"
89
+ end
90
+ tmp[:scheme] = klass.to_s.sub(/\A.*::/, '').downcase
91
+
92
+ return tmp
93
+ end
94
+ module_function :make_components_hash
95
+ end
96
+
97
+ module Schemes # :nodoc:
98
+ class << self
99
+ ReservedChars = ".+-"
100
+ EscapedChars = "\u01C0\u01C1\u01C2"
101
+ # Use Lo category chars as escaped chars for TruffleRuby, which
102
+ # does not allow Symbol categories as identifiers.
103
+
104
+ def escape(name)
105
+ unless name and name.ascii_only?
106
+ return nil
107
+ end
108
+ name.upcase.tr(ReservedChars, EscapedChars)
109
+ end
110
+
111
+ def unescape(name)
112
+ name.tr(EscapedChars, ReservedChars).encode(Encoding::US_ASCII).upcase
113
+ end
114
+
115
+ def find(name)
116
+ const_get(name, false) if name and const_defined?(name, false)
117
+ end
118
+
119
+ def register(name, klass)
120
+ unless scheme = escape(name)
121
+ raise ArgumentError, "invalid character as scheme - #{name}"
122
+ end
123
+ const_set(scheme, klass)
124
+ end
125
+
126
+ def list
127
+ constants.map { |name|
128
+ [unescape(name.to_s), const_get(name)]
129
+ }.to_h
130
+ end
131
+ end
132
+ end
133
+ private_constant :Schemes
134
+
135
+ # Registers the given +klass+ as the class to be instantiated
136
+ # when parsing a \Bundler::URI with the given +scheme+:
137
+ #
138
+ # Bundler::URI.register_scheme('MS_SEARCH', Bundler::URI::Generic) # => Bundler::URI::Generic
139
+ # Bundler::URI.scheme_list['MS_SEARCH'] # => Bundler::URI::Generic
140
+ #
141
+ # Note that after calling String#upcase on +scheme+, it must be a valid
142
+ # constant name.
143
+ def self.register_scheme(scheme, klass)
144
+ Schemes.register(scheme, klass)
145
+ end
146
+
147
+ # Returns a hash of the defined schemes:
148
+ #
149
+ # Bundler::URI.scheme_list
150
+ # # =>
151
+ # {"MAILTO"=>Bundler::URI::MailTo,
152
+ # "LDAPS"=>Bundler::URI::LDAPS,
153
+ # "WS"=>Bundler::URI::WS,
154
+ # "HTTP"=>Bundler::URI::HTTP,
155
+ # "HTTPS"=>Bundler::URI::HTTPS,
156
+ # "LDAP"=>Bundler::URI::LDAP,
157
+ # "FILE"=>Bundler::URI::File,
158
+ # "FTP"=>Bundler::URI::FTP}
159
+ #
160
+ # Related: Bundler::URI.register_scheme.
161
+ def self.scheme_list
162
+ Schemes.list
163
+ end
164
+
165
+ # :stopdoc:
166
+ INITIAL_SCHEMES = scheme_list
167
+ private_constant :INITIAL_SCHEMES
168
+ Ractor.make_shareable(INITIAL_SCHEMES) if defined?(Ractor)
169
+ # :startdoc:
170
+
171
+ # Returns a new object constructed from the given +scheme+, +arguments+,
172
+ # and +default+:
173
+ #
174
+ # - The new object is an instance of <tt>Bundler::URI.scheme_list[scheme.upcase]</tt>.
175
+ # - The object is initialized by calling the class initializer
176
+ # using +scheme+ and +arguments+.
177
+ # See Bundler::URI::Generic.new.
178
+ #
179
+ # Examples:
180
+ #
181
+ # values = ['john.doe', 'www.example.com', '123', nil, '/forum/questions/', nil, 'tag=networking&order=newest', 'top']
182
+ # Bundler::URI.for('https', *values)
183
+ # # => #<Bundler::URI::HTTPS https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
184
+ # Bundler::URI.for('foo', *values, default: Bundler::URI::HTTP)
185
+ # # => #<Bundler::URI::HTTP foo://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
186
+ #
187
+ def self.for(scheme, *arguments, default: Generic)
188
+ const_name = Schemes.escape(scheme)
189
+
190
+ uri_class = INITIAL_SCHEMES[const_name]
191
+ uri_class ||= Schemes.find(const_name)
192
+ uri_class ||= default
193
+
194
+ return uri_class.new(scheme, *arguments)
195
+ end
196
+
197
+ #
198
+ # Base class for all Bundler::URI exceptions.
199
+ #
200
+ class Error < StandardError; end
201
+ #
202
+ # Not a Bundler::URI.
203
+ #
204
+ class InvalidURIError < Error; end
205
+ #
206
+ # Not a Bundler::URI component.
207
+ #
208
+ class InvalidComponentError < Error; end
209
+ #
210
+ # Bundler::URI is valid, bad usage is not.
211
+ #
212
+ class BadURIError < Error; end
213
+
214
+ # Returns a 9-element array representing the parts of the \Bundler::URI
215
+ # formed from the string +uri+;
216
+ # each array element is a string or +nil+:
217
+ #
218
+ # names = %w[scheme userinfo host port registry path opaque query fragment]
219
+ # values = Bundler::URI.split('https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
220
+ # names.zip(values)
221
+ # # =>
222
+ # [["scheme", "https"],
223
+ # ["userinfo", "john.doe"],
224
+ # ["host", "www.example.com"],
225
+ # ["port", "123"],
226
+ # ["registry", nil],
227
+ # ["path", "/forum/questions/"],
228
+ # ["opaque", nil],
229
+ # ["query", "tag=networking&order=newest"],
230
+ # ["fragment", "top"]]
231
+ #
232
+ def self.split(uri)
233
+ PARSER.split(uri)
234
+ end
235
+
236
+ # Returns a new \Bundler::URI object constructed from the given string +uri+:
237
+ #
238
+ # Bundler::URI.parse('https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
239
+ # # => #<Bundler::URI::HTTPS https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
240
+ # Bundler::URI.parse('http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
241
+ # # => #<Bundler::URI::HTTP http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
242
+ #
243
+ # It's recommended to first Bundler::URI::RFC2396_PARSER.escape string +uri+
244
+ # if it may contain invalid Bundler::URI characters.
245
+ #
246
+ def self.parse(uri)
247
+ PARSER.parse(uri)
248
+ end
249
+
250
+ # Merges the given Bundler::URI strings +str+
251
+ # per {RFC 2396}[https://www.rfc-editor.org/rfc/rfc2396.html].
252
+ #
253
+ # Each string in +str+ is converted to an
254
+ # {RFC3986 Bundler::URI}[https://www.rfc-editor.org/rfc/rfc3986.html] before being merged.
255
+ #
256
+ # Examples:
257
+ #
258
+ # Bundler::URI.join("http://example.com/","main.rbx")
259
+ # # => #<Bundler::URI::HTTP http://example.com/main.rbx>
260
+ #
261
+ # Bundler::URI.join('http://example.com', 'foo')
262
+ # # => #<Bundler::URI::HTTP http://example.com/foo>
263
+ #
264
+ # Bundler::URI.join('http://example.com', '/foo', '/bar')
265
+ # # => #<Bundler::URI::HTTP http://example.com/bar>
266
+ #
267
+ # Bundler::URI.join('http://example.com', '/foo', 'bar')
268
+ # # => #<Bundler::URI::HTTP http://example.com/bar>
269
+ #
270
+ # Bundler::URI.join('http://example.com', '/foo/', 'bar')
271
+ # # => #<Bundler::URI::HTTP http://example.com/foo/bar>
272
+ #
273
+ def self.join(*str)
274
+ DEFAULT_PARSER.join(*str)
275
+ end
276
+
277
+ #
278
+ # == Synopsis
279
+ #
280
+ # Bundler::URI::extract(str[, schemes][,&blk])
281
+ #
282
+ # == Args
283
+ #
284
+ # +str+::
285
+ # String to extract URIs from.
286
+ # +schemes+::
287
+ # Limit Bundler::URI matching to specific schemes.
288
+ #
289
+ # == Description
290
+ #
291
+ # Extracts URIs from a string. If block given, iterates through all matched URIs.
292
+ # Returns nil if block given or array with matches.
293
+ #
294
+ # == Usage
295
+ #
296
+ # require "bundler/vendor/uri/lib/uri"
297
+ #
298
+ # Bundler::URI.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.")
299
+ # # => ["http://foo.example.com/bla", "mailto:test@example.com"]
300
+ #
301
+ def self.extract(str, schemes = nil, &block) # :nodoc:
302
+ warn "Bundler::URI.extract is obsolete", uplevel: 1 if $VERBOSE
303
+ PARSER.extract(str, schemes, &block)
304
+ end
305
+
306
+ #
307
+ # == Synopsis
308
+ #
309
+ # Bundler::URI::regexp([match_schemes])
310
+ #
311
+ # == Args
312
+ #
313
+ # +match_schemes+::
314
+ # Array of schemes. If given, resulting regexp matches to URIs
315
+ # whose scheme is one of the match_schemes.
316
+ #
317
+ # == Description
318
+ #
319
+ # Returns a Regexp object which matches to Bundler::URI-like strings.
320
+ # The Regexp object returned by this method includes arbitrary
321
+ # number of capture group (parentheses). Never rely on its number.
322
+ #
323
+ # == Usage
324
+ #
325
+ # require 'bundler/vendor/uri/lib/uri'
326
+ #
327
+ # # extract first Bundler::URI from html_string
328
+ # html_string.slice(Bundler::URI.regexp)
329
+ #
330
+ # # remove ftp URIs
331
+ # html_string.sub(Bundler::URI.regexp(['ftp']), '')
332
+ #
333
+ # # You should not rely on the number of parentheses
334
+ # html_string.scan(Bundler::URI.regexp) do |*matches|
335
+ # p $&
336
+ # end
337
+ #
338
+ def self.regexp(schemes = nil)# :nodoc:
339
+ warn "Bundler::URI.regexp is obsolete", uplevel: 1 if $VERBOSE
340
+ PARSER.make_regexp(schemes)
341
+ end
342
+
343
+ TBLENCWWWCOMP_ = {} # :nodoc:
344
+ 256.times do |i|
345
+ TBLENCWWWCOMP_[-i.chr] = -('%%%02X' % i)
346
+ end
347
+ TBLENCURICOMP_ = TBLENCWWWCOMP_.dup.freeze # :nodoc:
348
+ TBLENCWWWCOMP_[' '] = '+'
349
+ TBLENCWWWCOMP_.freeze
350
+ TBLDECWWWCOMP_ = {} # :nodoc:
351
+ 256.times do |i|
352
+ h, l = i>>4, i&15
353
+ TBLDECWWWCOMP_[-('%%%X%X' % [h, l])] = -i.chr
354
+ TBLDECWWWCOMP_[-('%%%x%X' % [h, l])] = -i.chr
355
+ TBLDECWWWCOMP_[-('%%%X%x' % [h, l])] = -i.chr
356
+ TBLDECWWWCOMP_[-('%%%x%x' % [h, l])] = -i.chr
357
+ end
358
+ TBLDECWWWCOMP_['+'] = ' '
359
+ TBLDECWWWCOMP_.freeze
360
+
361
+ # Returns a URL-encoded string derived from the given string +str+.
362
+ #
363
+ # The returned string:
364
+ #
365
+ # - Preserves:
366
+ #
367
+ # - Characters <tt>'*'</tt>, <tt>'.'</tt>, <tt>'-'</tt>, and <tt>'_'</tt>.
368
+ # - Character in ranges <tt>'a'..'z'</tt>, <tt>'A'..'Z'</tt>,
369
+ # and <tt>'0'..'9'</tt>.
370
+ #
371
+ # Example:
372
+ #
373
+ # Bundler::URI.encode_www_form_component('*.-_azAZ09')
374
+ # # => "*.-_azAZ09"
375
+ #
376
+ # - Converts:
377
+ #
378
+ # - Character <tt>' '</tt> to character <tt>'+'</tt>.
379
+ # - Any other character to "percent notation";
380
+ # the percent notation for character <i>c</i> is <tt>'%%%X' % c.ord</tt>.
381
+ #
382
+ # Example:
383
+ #
384
+ # Bundler::URI.encode_www_form_component('Here are some punctuation characters: ,;?:')
385
+ # # => "Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A"
386
+ #
387
+ # Encoding:
388
+ #
389
+ # - If +str+ has encoding Encoding::ASCII_8BIT, argument +enc+ is ignored.
390
+ # - Otherwise +str+ is converted first to Encoding::UTF_8
391
+ # (with suitable character replacements),
392
+ # and then to encoding +enc+.
393
+ #
394
+ # In either case, the returned string has forced encoding Encoding::US_ASCII.
395
+ #
396
+ # Related: Bundler::URI.encode_uri_component (encodes <tt>' '</tt> as <tt>'%20'</tt>).
397
+ def self.encode_www_form_component(str, enc=nil)
398
+ _encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCWWWCOMP_, str, enc)
399
+ end
400
+
401
+ # Returns a string decoded from the given \URL-encoded string +str+.
402
+ #
403
+ # The given string is first encoded as Encoding::ASCII-8BIT (using String#b),
404
+ # then decoded (as below), and finally force-encoded to the given encoding +enc+.
405
+ #
406
+ # The returned string:
407
+ #
408
+ # - Preserves:
409
+ #
410
+ # - Characters <tt>'*'</tt>, <tt>'.'</tt>, <tt>'-'</tt>, and <tt>'_'</tt>.
411
+ # - Character in ranges <tt>'a'..'z'</tt>, <tt>'A'..'Z'</tt>,
412
+ # and <tt>'0'..'9'</tt>.
413
+ #
414
+ # Example:
415
+ #
416
+ # Bundler::URI.decode_www_form_component('*.-_azAZ09')
417
+ # # => "*.-_azAZ09"
418
+ #
419
+ # - Converts:
420
+ #
421
+ # - Character <tt>'+'</tt> to character <tt>' '</tt>.
422
+ # - Each "percent notation" to an ASCII character.
423
+ #
424
+ # Example:
425
+ #
426
+ # Bundler::URI.decode_www_form_component('Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A')
427
+ # # => "Here are some punctuation characters: ,;?:"
428
+ #
429
+ # Related: Bundler::URI.decode_uri_component (preserves <tt>'+'</tt>).
430
+ def self.decode_www_form_component(str, enc=Encoding::UTF_8)
431
+ _decode_uri_component(/\+|%\h\h/, str, enc)
432
+ end
433
+
434
+ # Like Bundler::URI.encode_www_form_component, except that <tt>' '</tt> (space)
435
+ # is encoded as <tt>'%20'</tt> (instead of <tt>'+'</tt>).
436
+ def self.encode_uri_component(str, enc=nil)
437
+ _encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCURICOMP_, str, enc)
438
+ end
439
+
440
+ # Like Bundler::URI.decode_www_form_component, except that <tt>'+'</tt> is preserved.
441
+ def self.decode_uri_component(str, enc=Encoding::UTF_8)
442
+ _decode_uri_component(/%\h\h/, str, enc)
443
+ end
444
+
445
+ # Returns a string derived from the given string +str+ with
446
+ # Bundler::URI-encoded characters matching +regexp+ according to +table+.
447
+ def self._encode_uri_component(regexp, table, str, enc)
448
+ str = str.to_s.dup
449
+ if str.encoding != Encoding::ASCII_8BIT
450
+ if enc && enc != Encoding::ASCII_8BIT
451
+ str.encode!(Encoding::UTF_8, invalid: :replace, undef: :replace)
452
+ str.encode!(enc, fallback: ->(x){"&##{x.ord};"})
453
+ end
454
+ str.force_encoding(Encoding::ASCII_8BIT)
455
+ end
456
+ str.gsub!(regexp, table)
457
+ str.force_encoding(Encoding::US_ASCII)
458
+ end
459
+ private_class_method :_encode_uri_component
460
+
461
+ # Returns a string decoding characters matching +regexp+ from the
462
+ # given \URL-encoded string +str+.
463
+ def self._decode_uri_component(regexp, str, enc)
464
+ raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/.match?(str)
465
+ str.b.gsub(regexp, TBLDECWWWCOMP_).force_encoding(enc)
466
+ end
467
+ private_class_method :_decode_uri_component
468
+
469
+ # Returns a URL-encoded string derived from the given
470
+ # {Enumerable}[https://docs.ruby-lang.org/en/master/Enumerable.html#module-Enumerable-label-Enumerable+in+Ruby+Classes]
471
+ # +enum+.
472
+ #
473
+ # The result is suitable for use as form data
474
+ # for an \HTTP request whose <tt>Content-Type</tt> is
475
+ # <tt>'application/x-www-form-urlencoded'</tt>.
476
+ #
477
+ # The returned string consists of the elements of +enum+,
478
+ # each converted to one or more URL-encoded strings,
479
+ # and all joined with character <tt>'&'</tt>.
480
+ #
481
+ # Simple examples:
482
+ #
483
+ # Bundler::URI.encode_www_form([['foo', 0], ['bar', 1], ['baz', 2]])
484
+ # # => "foo=0&bar=1&baz=2"
485
+ # Bundler::URI.encode_www_form({foo: 0, bar: 1, baz: 2})
486
+ # # => "foo=0&bar=1&baz=2"
487
+ #
488
+ # The returned string is formed using method Bundler::URI.encode_www_form_component,
489
+ # which converts certain characters:
490
+ #
491
+ # Bundler::URI.encode_www_form('f#o': '/', 'b-r': '$', 'b z': '@')
492
+ # # => "f%23o=%2F&b-r=%24&b+z=%40"
493
+ #
494
+ # When +enum+ is Array-like, each element +ele+ is converted to a field:
495
+ #
496
+ # - If +ele+ is an array of two or more elements,
497
+ # the field is formed from its first two elements
498
+ # (and any additional elements are ignored):
499
+ #
500
+ # name = Bundler::URI.encode_www_form_component(ele[0], enc)
501
+ # value = Bundler::URI.encode_www_form_component(ele[1], enc)
502
+ # "#{name}=#{value}"
503
+ #
504
+ # Examples:
505
+ #
506
+ # Bundler::URI.encode_www_form([%w[foo bar], %w[baz bat bah]])
507
+ # # => "foo=bar&baz=bat"
508
+ # Bundler::URI.encode_www_form([['foo', 0], ['bar', :baz, 'bat']])
509
+ # # => "foo=0&bar=baz"
510
+ #
511
+ # - If +ele+ is an array of one element,
512
+ # the field is formed from <tt>ele[0]</tt>:
513
+ #
514
+ # Bundler::URI.encode_www_form_component(ele[0])
515
+ #
516
+ # Example:
517
+ #
518
+ # Bundler::URI.encode_www_form([['foo'], [:bar], [0]])
519
+ # # => "foo&bar&0"
520
+ #
521
+ # - Otherwise the field is formed from +ele+:
522
+ #
523
+ # Bundler::URI.encode_www_form_component(ele)
524
+ #
525
+ # Example:
526
+ #
527
+ # Bundler::URI.encode_www_form(['foo', :bar, 0])
528
+ # # => "foo&bar&0"
529
+ #
530
+ # The elements of an Array-like +enum+ may be mixture:
531
+ #
532
+ # Bundler::URI.encode_www_form([['foo', 0], ['bar', 1, 2], ['baz'], :bat])
533
+ # # => "foo=0&bar=1&baz&bat"
534
+ #
535
+ # When +enum+ is Hash-like,
536
+ # each +key+/+value+ pair is converted to one or more fields:
537
+ #
538
+ # - If +value+ is
539
+ # {Array-convertible}[https://docs.ruby-lang.org/en/master/implicit_conversion_rdoc.html#label-Array-Convertible+Objects],
540
+ # each element +ele+ in +value+ is paired with +key+ to form a field:
541
+ #
542
+ # name = Bundler::URI.encode_www_form_component(key, enc)
543
+ # value = Bundler::URI.encode_www_form_component(ele, enc)
544
+ # "#{name}=#{value}"
545
+ #
546
+ # Example:
547
+ #
548
+ # Bundler::URI.encode_www_form({foo: [:bar, 1], baz: [:bat, :bam, 2]})
549
+ # # => "foo=bar&foo=1&baz=bat&baz=bam&baz=2"
550
+ #
551
+ # - Otherwise, +key+ and +value+ are paired to form a field:
552
+ #
553
+ # name = Bundler::URI.encode_www_form_component(key, enc)
554
+ # value = Bundler::URI.encode_www_form_component(value, enc)
555
+ # "#{name}=#{value}"
556
+ #
557
+ # Example:
558
+ #
559
+ # Bundler::URI.encode_www_form({foo: 0, bar: 1, baz: 2})
560
+ # # => "foo=0&bar=1&baz=2"
561
+ #
562
+ # The elements of a Hash-like +enum+ may be mixture:
563
+ #
564
+ # Bundler::URI.encode_www_form({foo: [0, 1], bar: 2})
565
+ # # => "foo=0&foo=1&bar=2"
566
+ #
567
+ def self.encode_www_form(enum, enc=nil)
568
+ enum.map do |k,v|
569
+ if v.nil?
570
+ encode_www_form_component(k, enc)
571
+ elsif v.respond_to?(:to_ary)
572
+ v.to_ary.map do |w|
573
+ str = encode_www_form_component(k, enc)
574
+ unless w.nil?
575
+ str << '='
576
+ str << encode_www_form_component(w, enc)
577
+ end
578
+ end.join('&')
579
+ else
580
+ str = encode_www_form_component(k, enc)
581
+ str << '='
582
+ str << encode_www_form_component(v, enc)
583
+ end
584
+ end.join('&')
585
+ end
586
+
587
+ # Returns name/value pairs derived from the given string +str+,
588
+ # which must be an ASCII string.
589
+ #
590
+ # The method may be used to decode the body of Net::HTTPResponse object +res+
591
+ # for which <tt>res['Content-Type']</tt> is <tt>'application/x-www-form-urlencoded'</tt>.
592
+ #
593
+ # The returned data is an array of 2-element subarrays;
594
+ # each subarray is a name/value pair (both are strings).
595
+ # Each returned string has encoding +enc+,
596
+ # and has had invalid characters removed via
597
+ # {String#scrub}[https://docs.ruby-lang.org/en/master/String.html#method-i-scrub].
598
+ #
599
+ # A simple example:
600
+ #
601
+ # Bundler::URI.decode_www_form('foo=0&bar=1&baz')
602
+ # # => [["foo", "0"], ["bar", "1"], ["baz", ""]]
603
+ #
604
+ # The returned strings have certain conversions,
605
+ # similar to those performed in Bundler::URI.decode_www_form_component:
606
+ #
607
+ # Bundler::URI.decode_www_form('f%23o=%2F&b-r=%24&b+z=%40')
608
+ # # => [["f#o", "/"], ["b-r", "$"], ["b z", "@"]]
609
+ #
610
+ # The given string may contain consecutive separators:
611
+ #
612
+ # Bundler::URI.decode_www_form('foo=0&&bar=1&&baz=2')
613
+ # # => [["foo", "0"], ["", ""], ["bar", "1"], ["", ""], ["baz", "2"]]
614
+ #
615
+ # A different separator may be specified:
616
+ #
617
+ # Bundler::URI.decode_www_form('foo=0--bar=1--baz', separator: '--')
618
+ # # => [["foo", "0"], ["bar", "1"], ["baz", ""]]
619
+ #
620
+ def self.decode_www_form(str, enc=Encoding::UTF_8, separator: '&', use__charset_: false, isindex: false)
621
+ raise ArgumentError, "the input of #{self.name}.#{__method__} must be ASCII only string" unless str.ascii_only?
622
+ ary = []
623
+ return ary if str.empty?
624
+ enc = Encoding.find(enc)
625
+ str.b.each_line(separator) do |string|
626
+ string.chomp!(separator)
627
+ key, sep, val = string.partition('=')
628
+ if isindex
629
+ if sep.empty?
630
+ val = key
631
+ key = +''
632
+ end
633
+ isindex = false
634
+ end
635
+
636
+ if use__charset_ and key == '_charset_' and e = get_encoding(val)
637
+ enc = e
638
+ use__charset_ = false
639
+ end
640
+
641
+ key.gsub!(/\+|%\h\h/, TBLDECWWWCOMP_)
642
+ if val
643
+ val.gsub!(/\+|%\h\h/, TBLDECWWWCOMP_)
644
+ else
645
+ val = +''
646
+ end
647
+
648
+ ary << [key, val]
649
+ end
650
+ ary.each do |k, v|
651
+ k.force_encoding(enc)
652
+ k.scrub!
653
+ v.force_encoding(enc)
654
+ v.scrub!
655
+ end
656
+ ary
657
+ end
658
+
659
+ private
660
+ =begin command for WEB_ENCODINGS_
661
+ curl https://encoding.spec.whatwg.org/encodings.json|
662
+ ruby -rjson -e 'H={}
663
+ h={
664
+ "shift_jis"=>"Windows-31J",
665
+ "euc-jp"=>"cp51932",
666
+ "iso-2022-jp"=>"cp50221",
667
+ "x-mac-cyrillic"=>"macCyrillic",
668
+ }
669
+ JSON($<.read).map{|x|x["encodings"]}.flatten.each{|x|
670
+ Encoding.find(n=h.fetch(n=x["name"].downcase,n))rescue next
671
+ x["labels"].each{|y|H[y]=n}
672
+ }
673
+ puts "{"
674
+ H.each{|k,v|puts %[ #{k.dump}=>#{v.dump},]}
675
+ puts "}"
676
+ '
677
+ =end
678
+ WEB_ENCODINGS_ = {
679
+ "unicode-1-1-utf-8"=>"utf-8",
680
+ "utf-8"=>"utf-8",
681
+ "utf8"=>"utf-8",
682
+ "866"=>"ibm866",
683
+ "cp866"=>"ibm866",
684
+ "csibm866"=>"ibm866",
685
+ "ibm866"=>"ibm866",
686
+ "csisolatin2"=>"iso-8859-2",
687
+ "iso-8859-2"=>"iso-8859-2",
688
+ "iso-ir-101"=>"iso-8859-2",
689
+ "iso8859-2"=>"iso-8859-2",
690
+ "iso88592"=>"iso-8859-2",
691
+ "iso_8859-2"=>"iso-8859-2",
692
+ "iso_8859-2:1987"=>"iso-8859-2",
693
+ "l2"=>"iso-8859-2",
694
+ "latin2"=>"iso-8859-2",
695
+ "csisolatin3"=>"iso-8859-3",
696
+ "iso-8859-3"=>"iso-8859-3",
697
+ "iso-ir-109"=>"iso-8859-3",
698
+ "iso8859-3"=>"iso-8859-3",
699
+ "iso88593"=>"iso-8859-3",
700
+ "iso_8859-3"=>"iso-8859-3",
701
+ "iso_8859-3:1988"=>"iso-8859-3",
702
+ "l3"=>"iso-8859-3",
703
+ "latin3"=>"iso-8859-3",
704
+ "csisolatin4"=>"iso-8859-4",
705
+ "iso-8859-4"=>"iso-8859-4",
706
+ "iso-ir-110"=>"iso-8859-4",
707
+ "iso8859-4"=>"iso-8859-4",
708
+ "iso88594"=>"iso-8859-4",
709
+ "iso_8859-4"=>"iso-8859-4",
710
+ "iso_8859-4:1988"=>"iso-8859-4",
711
+ "l4"=>"iso-8859-4",
712
+ "latin4"=>"iso-8859-4",
713
+ "csisolatincyrillic"=>"iso-8859-5",
714
+ "cyrillic"=>"iso-8859-5",
715
+ "iso-8859-5"=>"iso-8859-5",
716
+ "iso-ir-144"=>"iso-8859-5",
717
+ "iso8859-5"=>"iso-8859-5",
718
+ "iso88595"=>"iso-8859-5",
719
+ "iso_8859-5"=>"iso-8859-5",
720
+ "iso_8859-5:1988"=>"iso-8859-5",
721
+ "arabic"=>"iso-8859-6",
722
+ "asmo-708"=>"iso-8859-6",
723
+ "csiso88596e"=>"iso-8859-6",
724
+ "csiso88596i"=>"iso-8859-6",
725
+ "csisolatinarabic"=>"iso-8859-6",
726
+ "ecma-114"=>"iso-8859-6",
727
+ "iso-8859-6"=>"iso-8859-6",
728
+ "iso-8859-6-e"=>"iso-8859-6",
729
+ "iso-8859-6-i"=>"iso-8859-6",
730
+ "iso-ir-127"=>"iso-8859-6",
731
+ "iso8859-6"=>"iso-8859-6",
732
+ "iso88596"=>"iso-8859-6",
733
+ "iso_8859-6"=>"iso-8859-6",
734
+ "iso_8859-6:1987"=>"iso-8859-6",
735
+ "csisolatingreek"=>"iso-8859-7",
736
+ "ecma-118"=>"iso-8859-7",
737
+ "elot_928"=>"iso-8859-7",
738
+ "greek"=>"iso-8859-7",
739
+ "greek8"=>"iso-8859-7",
740
+ "iso-8859-7"=>"iso-8859-7",
741
+ "iso-ir-126"=>"iso-8859-7",
742
+ "iso8859-7"=>"iso-8859-7",
743
+ "iso88597"=>"iso-8859-7",
744
+ "iso_8859-7"=>"iso-8859-7",
745
+ "iso_8859-7:1987"=>"iso-8859-7",
746
+ "sun_eu_greek"=>"iso-8859-7",
747
+ "csiso88598e"=>"iso-8859-8",
748
+ "csisolatinhebrew"=>"iso-8859-8",
749
+ "hebrew"=>"iso-8859-8",
750
+ "iso-8859-8"=>"iso-8859-8",
751
+ "iso-8859-8-e"=>"iso-8859-8",
752
+ "iso-ir-138"=>"iso-8859-8",
753
+ "iso8859-8"=>"iso-8859-8",
754
+ "iso88598"=>"iso-8859-8",
755
+ "iso_8859-8"=>"iso-8859-8",
756
+ "iso_8859-8:1988"=>"iso-8859-8",
757
+ "visual"=>"iso-8859-8",
758
+ "csisolatin6"=>"iso-8859-10",
759
+ "iso-8859-10"=>"iso-8859-10",
760
+ "iso-ir-157"=>"iso-8859-10",
761
+ "iso8859-10"=>"iso-8859-10",
762
+ "iso885910"=>"iso-8859-10",
763
+ "l6"=>"iso-8859-10",
764
+ "latin6"=>"iso-8859-10",
765
+ "iso-8859-13"=>"iso-8859-13",
766
+ "iso8859-13"=>"iso-8859-13",
767
+ "iso885913"=>"iso-8859-13",
768
+ "iso-8859-14"=>"iso-8859-14",
769
+ "iso8859-14"=>"iso-8859-14",
770
+ "iso885914"=>"iso-8859-14",
771
+ "csisolatin9"=>"iso-8859-15",
772
+ "iso-8859-15"=>"iso-8859-15",
773
+ "iso8859-15"=>"iso-8859-15",
774
+ "iso885915"=>"iso-8859-15",
775
+ "iso_8859-15"=>"iso-8859-15",
776
+ "l9"=>"iso-8859-15",
777
+ "iso-8859-16"=>"iso-8859-16",
778
+ "cskoi8r"=>"koi8-r",
779
+ "koi"=>"koi8-r",
780
+ "koi8"=>"koi8-r",
781
+ "koi8-r"=>"koi8-r",
782
+ "koi8_r"=>"koi8-r",
783
+ "koi8-ru"=>"koi8-u",
784
+ "koi8-u"=>"koi8-u",
785
+ "dos-874"=>"windows-874",
786
+ "iso-8859-11"=>"windows-874",
787
+ "iso8859-11"=>"windows-874",
788
+ "iso885911"=>"windows-874",
789
+ "tis-620"=>"windows-874",
790
+ "windows-874"=>"windows-874",
791
+ "cp1250"=>"windows-1250",
792
+ "windows-1250"=>"windows-1250",
793
+ "x-cp1250"=>"windows-1250",
794
+ "cp1251"=>"windows-1251",
795
+ "windows-1251"=>"windows-1251",
796
+ "x-cp1251"=>"windows-1251",
797
+ "ansi_x3.4-1968"=>"windows-1252",
798
+ "ascii"=>"windows-1252",
799
+ "cp1252"=>"windows-1252",
800
+ "cp819"=>"windows-1252",
801
+ "csisolatin1"=>"windows-1252",
802
+ "ibm819"=>"windows-1252",
803
+ "iso-8859-1"=>"windows-1252",
804
+ "iso-ir-100"=>"windows-1252",
805
+ "iso8859-1"=>"windows-1252",
806
+ "iso88591"=>"windows-1252",
807
+ "iso_8859-1"=>"windows-1252",
808
+ "iso_8859-1:1987"=>"windows-1252",
809
+ "l1"=>"windows-1252",
810
+ "latin1"=>"windows-1252",
811
+ "us-ascii"=>"windows-1252",
812
+ "windows-1252"=>"windows-1252",
813
+ "x-cp1252"=>"windows-1252",
814
+ "cp1253"=>"windows-1253",
815
+ "windows-1253"=>"windows-1253",
816
+ "x-cp1253"=>"windows-1253",
817
+ "cp1254"=>"windows-1254",
818
+ "csisolatin5"=>"windows-1254",
819
+ "iso-8859-9"=>"windows-1254",
820
+ "iso-ir-148"=>"windows-1254",
821
+ "iso8859-9"=>"windows-1254",
822
+ "iso88599"=>"windows-1254",
823
+ "iso_8859-9"=>"windows-1254",
824
+ "iso_8859-9:1989"=>"windows-1254",
825
+ "l5"=>"windows-1254",
826
+ "latin5"=>"windows-1254",
827
+ "windows-1254"=>"windows-1254",
828
+ "x-cp1254"=>"windows-1254",
829
+ "cp1255"=>"windows-1255",
830
+ "windows-1255"=>"windows-1255",
831
+ "x-cp1255"=>"windows-1255",
832
+ "cp1256"=>"windows-1256",
833
+ "windows-1256"=>"windows-1256",
834
+ "x-cp1256"=>"windows-1256",
835
+ "cp1257"=>"windows-1257",
836
+ "windows-1257"=>"windows-1257",
837
+ "x-cp1257"=>"windows-1257",
838
+ "cp1258"=>"windows-1258",
839
+ "windows-1258"=>"windows-1258",
840
+ "x-cp1258"=>"windows-1258",
841
+ "x-mac-cyrillic"=>"macCyrillic",
842
+ "x-mac-ukrainian"=>"macCyrillic",
843
+ "chinese"=>"gbk",
844
+ "csgb2312"=>"gbk",
845
+ "csiso58gb231280"=>"gbk",
846
+ "gb2312"=>"gbk",
847
+ "gb_2312"=>"gbk",
848
+ "gb_2312-80"=>"gbk",
849
+ "gbk"=>"gbk",
850
+ "iso-ir-58"=>"gbk",
851
+ "x-gbk"=>"gbk",
852
+ "gb18030"=>"gb18030",
853
+ "big5"=>"big5",
854
+ "big5-hkscs"=>"big5",
855
+ "cn-big5"=>"big5",
856
+ "csbig5"=>"big5",
857
+ "x-x-big5"=>"big5",
858
+ "cseucpkdfmtjapanese"=>"cp51932",
859
+ "euc-jp"=>"cp51932",
860
+ "x-euc-jp"=>"cp51932",
861
+ "csiso2022jp"=>"cp50221",
862
+ "iso-2022-jp"=>"cp50221",
863
+ "csshiftjis"=>"Windows-31J",
864
+ "ms932"=>"Windows-31J",
865
+ "ms_kanji"=>"Windows-31J",
866
+ "shift-jis"=>"Windows-31J",
867
+ "shift_jis"=>"Windows-31J",
868
+ "sjis"=>"Windows-31J",
869
+ "windows-31j"=>"Windows-31J",
870
+ "x-sjis"=>"Windows-31J",
871
+ "cseuckr"=>"euc-kr",
872
+ "csksc56011987"=>"euc-kr",
873
+ "euc-kr"=>"euc-kr",
874
+ "iso-ir-149"=>"euc-kr",
875
+ "korean"=>"euc-kr",
876
+ "ks_c_5601-1987"=>"euc-kr",
877
+ "ks_c_5601-1989"=>"euc-kr",
878
+ "ksc5601"=>"euc-kr",
879
+ "ksc_5601"=>"euc-kr",
880
+ "windows-949"=>"euc-kr",
881
+ "utf-16be"=>"utf-16be",
882
+ "utf-16"=>"utf-16le",
883
+ "utf-16le"=>"utf-16le",
884
+ } # :nodoc:
885
+ Ractor.make_shareable(WEB_ENCODINGS_) if defined?(Ractor)
886
+
887
+ # :nodoc:
888
+ # return encoding or nil
889
+ # http://encoding.spec.whatwg.org/#concept-encoding-get
890
+ def self.get_encoding(label)
891
+ Encoding.find(WEB_ENCODINGS_[label.to_str.strip.downcase]) rescue nil
892
+ end
893
+ end # module Bundler::URI
894
+
895
+ module Bundler
896
+
897
+ #
898
+ # Returns a \Bundler::URI object derived from the given +uri+,
899
+ # which may be a \Bundler::URI string or an existing \Bundler::URI object:
900
+ #
901
+ # require 'bundler/vendor/uri/lib/uri'
902
+ # # Returns a new Bundler::URI.
903
+ # uri = Bundler::URI('http://github.com/ruby/ruby')
904
+ # # => #<Bundler::URI::HTTP http://github.com/ruby/ruby>
905
+ # # Returns the given Bundler::URI.
906
+ # Bundler::URI(uri)
907
+ # # => #<Bundler::URI::HTTP http://github.com/ruby/ruby>
908
+ #
909
+ # You must require 'bundler/vendor/uri/lib/uri' to use this method.
910
+ #
911
+ def URI(uri)
912
+ if uri.is_a?(Bundler::URI::Generic)
913
+ uri
914
+ elsif uri = String.try_convert(uri)
915
+ Bundler::URI.parse(uri)
916
+ else
917
+ raise ArgumentError,
918
+ "bad argument (expected Bundler::URI object or Bundler::URI string)"
919
+ end
920
+ end
921
+ module_function :URI
922
+ end