rubygems-update 3.0.3 → 3.4.7

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 (795) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5556 -0
  3. data/CODE_OF_CONDUCT.md +62 -24
  4. data/CONTRIBUTING.md +111 -21
  5. data/MAINTAINERS.txt +1 -6
  6. data/Manifest.txt +209 -101
  7. data/POLICIES.md +65 -22
  8. data/README.md +23 -15
  9. data/UPGRADING.md +5 -81
  10. data/bin/gem +2 -16
  11. data/bin/update_rubygems +5 -5
  12. data/bundler/CHANGELOG.md +2619 -1256
  13. data/bundler/LICENSE.md +18 -19
  14. data/bundler/README.md +11 -12
  15. data/bundler/UPGRADING.md +222 -0
  16. data/bundler/bundler.gemspec +13 -33
  17. data/bundler/exe/bundle +26 -11
  18. data/bundler/exe/bundler +1 -1
  19. data/bundler/lib/bundler/.document +1 -0
  20. data/bundler/lib/bundler/build_metadata.rb +5 -13
  21. data/bundler/lib/bundler/capistrano.rb +4 -4
  22. data/bundler/lib/bundler/cli/add.rb +28 -16
  23. data/bundler/lib/bundler/cli/binstubs.rb +11 -3
  24. data/bundler/lib/bundler/cli/cache.rb +24 -17
  25. data/bundler/lib/bundler/cli/check.rb +5 -3
  26. data/bundler/lib/bundler/cli/clean.rb +1 -1
  27. data/bundler/lib/bundler/cli/common.rb +41 -13
  28. data/bundler/lib/bundler/cli/config.rb +170 -86
  29. data/bundler/lib/bundler/cli/console.rb +3 -3
  30. data/bundler/lib/bundler/cli/doctor.rb +27 -10
  31. data/bundler/lib/bundler/cli/exec.rb +8 -25
  32. data/bundler/lib/bundler/cli/fund.rb +36 -0
  33. data/bundler/lib/bundler/cli/gem.rb +261 -48
  34. data/bundler/lib/bundler/cli/info.rb +52 -8
  35. data/bundler/lib/bundler/cli/init.rb +7 -3
  36. data/bundler/lib/bundler/cli/inject.rb +1 -1
  37. data/bundler/lib/bundler/cli/install.rb +38 -66
  38. data/bundler/lib/bundler/cli/issue.rb +8 -7
  39. data/bundler/lib/bundler/cli/list.rb +19 -11
  40. data/bundler/lib/bundler/cli/lock.rb +11 -4
  41. data/bundler/lib/bundler/cli/open.rb +14 -9
  42. data/bundler/lib/bundler/cli/outdated.rb +152 -121
  43. data/bundler/lib/bundler/cli/platform.rb +2 -2
  44. data/bundler/lib/bundler/cli/plugin.rb +19 -2
  45. data/bundler/lib/bundler/cli/pristine.rb +6 -1
  46. data/bundler/lib/bundler/cli/remove.rb +1 -2
  47. data/bundler/lib/bundler/cli/show.rb +3 -3
  48. data/bundler/lib/bundler/cli/update.rb +49 -18
  49. data/bundler/lib/bundler/cli/viz.rb +1 -1
  50. data/bundler/lib/bundler/cli.rb +269 -165
  51. data/bundler/lib/bundler/compact_index_client/cache.rb +7 -24
  52. data/bundler/lib/bundler/compact_index_client/gem_parser.rb +28 -0
  53. data/bundler/lib/bundler/compact_index_client/updater.rb +58 -57
  54. data/bundler/lib/bundler/compact_index_client.rb +28 -18
  55. data/bundler/lib/bundler/constants.rb +1 -1
  56. data/bundler/lib/bundler/current_ruby.rb +26 -11
  57. data/bundler/lib/bundler/definition.rb +359 -441
  58. data/bundler/lib/bundler/dependency.rb +29 -71
  59. data/bundler/lib/bundler/deployment.rb +1 -1
  60. data/bundler/lib/bundler/digest.rb +71 -0
  61. data/bundler/lib/bundler/dsl.rb +84 -116
  62. data/bundler/lib/bundler/endpoint_specification.rb +20 -14
  63. data/bundler/lib/bundler/env.rb +10 -15
  64. data/bundler/lib/bundler/environment_preserver.rb +30 -3
  65. data/bundler/lib/bundler/errors.rb +31 -14
  66. data/bundler/lib/bundler/feature_flag.rb +13 -33
  67. data/bundler/lib/bundler/fetcher/base.rb +7 -9
  68. data/bundler/lib/bundler/fetcher/compact_index.rb +46 -39
  69. data/bundler/lib/bundler/fetcher/dependency.rb +2 -2
  70. data/bundler/lib/bundler/fetcher/downloader.rb +15 -12
  71. data/bundler/lib/bundler/fetcher/index.rb +4 -30
  72. data/bundler/lib/bundler/fetcher.rb +39 -41
  73. data/bundler/lib/bundler/force_platform.rb +18 -0
  74. data/bundler/lib/bundler/friendly_errors.rb +49 -54
  75. data/bundler/lib/bundler/gem_helper.rb +79 -43
  76. data/bundler/lib/bundler/gem_helpers.rb +44 -28
  77. data/bundler/lib/bundler/gem_tasks.rb +1 -1
  78. data/bundler/lib/bundler/gem_version_promoter.rb +54 -99
  79. data/bundler/lib/bundler/graph.rb +5 -5
  80. data/bundler/lib/bundler/index.rb +14 -52
  81. data/bundler/lib/bundler/injector.rb +50 -16
  82. data/bundler/lib/bundler/inline.rb +28 -29
  83. data/bundler/lib/bundler/installer/gem_installer.rb +22 -23
  84. data/bundler/lib/bundler/installer/parallel_installer.rb +51 -51
  85. data/bundler/lib/bundler/installer/standalone.rb +62 -12
  86. data/bundler/lib/bundler/installer.rb +46 -97
  87. data/bundler/lib/bundler/lazy_specification.rb +88 -48
  88. data/bundler/lib/bundler/lockfile_generator.rb +3 -3
  89. data/bundler/lib/bundler/lockfile_parser.rb +30 -62
  90. data/bundler/{man → lib/bundler/man}/bundle-add.1 +29 -5
  91. data/bundler/{man/bundle-add.ronn → lib/bundler/man/bundle-add.1.ronn} +22 -4
  92. data/bundler/{man → lib/bundler/man}/bundle-binstubs.1 +6 -4
  93. data/bundler/{man/bundle-binstubs.ronn → lib/bundler/man/bundle-binstubs.1.ronn} +3 -5
  94. data/bundler/lib/bundler/man/bundle-cache.1 +61 -0
  95. data/bundler/{man/bundle-package.ronn → lib/bundler/man/bundle-cache.1.ronn} +22 -15
  96. data/bundler/{man → lib/bundler/man}/bundle-check.1 +1 -1
  97. data/bundler/{man → lib/bundler/man}/bundle-clean.1 +2 -2
  98. data/bundler/{man/bundle-clean.ronn → lib/bundler/man/bundle-clean.1.ronn} +1 -1
  99. data/bundler/{man → lib/bundler/man}/bundle-config.1 +78 -60
  100. data/bundler/{man/bundle-config.ronn → lib/bundler/man/bundle-config.1.ronn} +96 -85
  101. data/bundler/lib/bundler/man/bundle-console.1 +53 -0
  102. data/bundler/lib/bundler/man/bundle-console.1.ronn +44 -0
  103. data/bundler/{man → lib/bundler/man}/bundle-doctor.1 +1 -1
  104. data/bundler/{man → lib/bundler/man}/bundle-exec.1 +6 -6
  105. data/bundler/{man/bundle-exec.ronn → lib/bundler/man/bundle-exec.1.ronn} +6 -6
  106. data/bundler/lib/bundler/man/bundle-gem.1 +105 -0
  107. data/bundler/lib/bundler/man/bundle-gem.1.ronn +117 -0
  108. data/bundler/lib/bundler/man/bundle-help.1 +13 -0
  109. data/bundler/lib/bundler/man/bundle-help.1.ronn +12 -0
  110. data/bundler/{man → lib/bundler/man}/bundle-info.1 +1 -1
  111. data/bundler/{man → lib/bundler/man}/bundle-init.1 +6 -2
  112. data/bundler/{man/bundle-init.ronn → lib/bundler/man/bundle-init.1.ronn} +3 -1
  113. data/bundler/{man → lib/bundler/man}/bundle-inject.1 +5 -2
  114. data/bundler/{man/bundle-inject.ronn → lib/bundler/man/bundle-inject.1.ronn} +3 -1
  115. data/bundler/{man → lib/bundler/man}/bundle-install.1 +42 -37
  116. data/bundler/{man/bundle-install.ronn → lib/bundler/man/bundle-install.1.ronn} +42 -38
  117. data/bundler/{man → lib/bundler/man}/bundle-list.1 +7 -7
  118. data/bundler/{man/bundle-list.ronn → lib/bundler/man/bundle-list.1.ronn} +6 -6
  119. data/bundler/{man → lib/bundler/man}/bundle-lock.1 +1 -1
  120. data/bundler/{man → lib/bundler/man}/bundle-open.1 +22 -2
  121. data/bundler/{man/bundle-open.ronn → lib/bundler/man/bundle-open.1.ronn} +9 -1
  122. data/bundler/{man → lib/bundler/man}/bundle-outdated.1 +3 -10
  123. data/bundler/{man/bundle-outdated.ronn → lib/bundler/man/bundle-outdated.1.ronn} +1 -10
  124. data/bundler/{man → lib/bundler/man}/bundle-platform.1 +16 -6
  125. data/bundler/{man/bundle-platform.ronn → lib/bundler/man/bundle-platform.1.ronn} +14 -7
  126. data/bundler/lib/bundler/man/bundle-plugin.1 +81 -0
  127. data/bundler/lib/bundler/man/bundle-plugin.1.ronn +59 -0
  128. data/bundler/{man → lib/bundler/man}/bundle-pristine.1 +1 -1
  129. data/bundler/{man → lib/bundler/man}/bundle-remove.1 +1 -1
  130. data/bundler/{man → lib/bundler/man}/bundle-show.1 +1 -1
  131. data/bundler/{man → lib/bundler/man}/bundle-update.1 +8 -8
  132. data/bundler/{man/bundle-update.ronn → lib/bundler/man/bundle-update.1.ronn} +8 -7
  133. data/bundler/lib/bundler/man/bundle-version.1 +35 -0
  134. data/bundler/lib/bundler/man/bundle-version.1.ronn +24 -0
  135. data/bundler/{man → lib/bundler/man}/bundle-viz.1 +4 -1
  136. data/bundler/{man/bundle-viz.ronn → lib/bundler/man/bundle-viz.1.ronn} +2 -0
  137. data/bundler/{man → lib/bundler/man}/bundle.1 +17 -12
  138. data/bundler/{man/bundle.ronn → lib/bundler/man/bundle.1.ronn} +14 -9
  139. data/bundler/lib/bundler/man/gemfile.5 +723 -0
  140. data/bundler/{man → lib/bundler/man}/gemfile.5.ronn +112 -95
  141. data/bundler/lib/bundler/man/index.txt +29 -0
  142. data/bundler/lib/bundler/match_metadata.rb +13 -0
  143. data/bundler/lib/bundler/match_platform.rb +1 -2
  144. data/bundler/lib/bundler/match_remote_metadata.rb +29 -0
  145. data/bundler/lib/bundler/mirror.rb +10 -12
  146. data/bundler/lib/bundler/plugin/api/source.rb +29 -15
  147. data/bundler/lib/bundler/plugin/api.rb +1 -1
  148. data/bundler/lib/bundler/plugin/dsl.rb +1 -1
  149. data/bundler/lib/bundler/plugin/index.rb +31 -8
  150. data/bundler/lib/bundler/plugin/installer/git.rb +0 -4
  151. data/bundler/lib/bundler/plugin/installer/rubygems.rb +1 -9
  152. data/bundler/lib/bundler/plugin/installer.rb +35 -22
  153. data/bundler/lib/bundler/plugin/source_list.rb +5 -1
  154. data/bundler/lib/bundler/plugin.rb +102 -42
  155. data/bundler/lib/bundler/process_lock.rb +1 -1
  156. data/bundler/lib/bundler/remote_specification.rb +15 -8
  157. data/bundler/lib/bundler/resolver/base.rb +77 -0
  158. data/bundler/lib/bundler/resolver/candidate.rb +94 -0
  159. data/bundler/lib/bundler/resolver/incompatibility.rb +15 -0
  160. data/bundler/lib/bundler/resolver/package.rb +72 -0
  161. data/bundler/lib/bundler/resolver/root.rb +25 -0
  162. data/bundler/lib/bundler/resolver/spec_group.rb +49 -73
  163. data/bundler/lib/bundler/resolver.rb +343 -300
  164. data/bundler/lib/bundler/retry.rb +4 -4
  165. data/bundler/lib/bundler/ruby_dsl.rb +1 -1
  166. data/bundler/lib/bundler/ruby_version.rb +9 -37
  167. data/bundler/lib/bundler/rubygems_ext.rb +235 -92
  168. data/bundler/lib/bundler/rubygems_gem_installer.rb +87 -21
  169. data/bundler/lib/bundler/rubygems_integration.rb +179 -515
  170. data/bundler/lib/bundler/runtime.rb +25 -40
  171. data/bundler/lib/bundler/self_manager.rb +168 -0
  172. data/bundler/lib/bundler/settings.rb +162 -118
  173. data/bundler/lib/bundler/setup.rb +11 -12
  174. data/bundler/lib/bundler/shared_helpers.rb +61 -102
  175. data/bundler/lib/bundler/similarity_detector.rb +3 -3
  176. data/bundler/lib/bundler/source/git/git_proxy.rb +257 -128
  177. data/bundler/lib/bundler/source/git.rb +84 -61
  178. data/bundler/lib/bundler/source/metadata.rb +9 -9
  179. data/bundler/lib/bundler/source/path/installer.rb +11 -32
  180. data/bundler/lib/bundler/source/path.rb +28 -17
  181. data/bundler/lib/bundler/source/rubygems/remote.rb +3 -4
  182. data/bundler/lib/bundler/source/rubygems.rb +171 -197
  183. data/bundler/lib/bundler/source/rubygems_aggregate.rb +68 -0
  184. data/bundler/lib/bundler/source.rb +30 -10
  185. data/bundler/lib/bundler/source_list.rb +112 -67
  186. data/bundler/lib/bundler/source_map.rb +71 -0
  187. data/bundler/lib/bundler/spec_set.rb +86 -72
  188. data/bundler/lib/bundler/stub_specification.rb +45 -37
  189. data/bundler/lib/bundler/templates/Executable +3 -5
  190. data/bundler/lib/bundler/templates/Executable.bundler +21 -17
  191. data/bundler/lib/bundler/templates/Executable.standalone +4 -4
  192. data/bundler/lib/bundler/templates/Gemfile +0 -2
  193. data/bundler/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
  194. data/bundler/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +57 -47
  195. data/bundler/lib/bundler/templates/newgem/Cargo.toml.tt +7 -0
  196. data/bundler/lib/bundler/templates/newgem/Gemfile.tt +22 -2
  197. data/bundler/lib/bundler/templates/newgem/README.md.tt +13 -15
  198. data/bundler/lib/bundler/templates/newgem/Rakefile.tt +33 -5
  199. data/bundler/lib/bundler/templates/newgem/bin/console.tt +1 -0
  200. data/bundler/lib/bundler/templates/newgem/circleci/config.yml.tt +25 -0
  201. data/bundler/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +15 -0
  202. data/bundler/lib/bundler/templates/newgem/ext/newgem/{extconf.rb.tt → extconf-c.rb.tt} +2 -0
  203. data/bundler/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
  204. data/bundler/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +12 -0
  205. data/bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt +37 -0
  206. data/bundler/lib/bundler/templates/newgem/gitignore.tt +3 -0
  207. data/bundler/lib/bundler/templates/newgem/gitlab-ci.yml.tt +18 -0
  208. data/bundler/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +2 -0
  209. data/bundler/lib/bundler/templates/newgem/lib/newgem.rb.tt +4 -2
  210. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +36 -41
  211. data/bundler/lib/bundler/templates/newgem/rubocop.yml.tt +13 -0
  212. data/bundler/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  213. data/bundler/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +2 -0
  214. data/bundler/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -1
  215. data/bundler/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  216. data/bundler/lib/bundler/templates/newgem/test/minitest/test_helper.rb.tt +6 -0
  217. data/bundler/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/test_newgem.rb.tt} +3 -1
  218. data/bundler/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
  219. data/bundler/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
  220. data/bundler/lib/bundler/ui/rg_proxy.rb +1 -1
  221. data/bundler/lib/bundler/ui/shell.rb +39 -20
  222. data/bundler/lib/bundler/ui/silent.rb +21 -5
  223. data/bundler/lib/bundler/ui.rb +3 -3
  224. data/bundler/lib/bundler/uri_credentials_filter.rb +10 -4
  225. data/bundler/lib/bundler/vendor/.document +1 -0
  226. data/bundler/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  227. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +174 -0
  228. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +3 -0
  229. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +56 -0
  230. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +128 -0
  231. data/bundler/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  232. data/bundler/lib/bundler/vendor/fileutils/lib/fileutils.rb +1493 -425
  233. data/bundler/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  234. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +40 -0
  235. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +53 -0
  236. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +79 -0
  237. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +302 -462
  238. data/bundler/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
  239. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
  240. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +189 -0
  241. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
  242. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +155 -0
  243. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
  244. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
  245. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
  246. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
  247. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +60 -0
  248. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
  249. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
  250. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +129 -0
  251. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +411 -0
  252. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +243 -0
  253. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
  254. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
  255. data/bundler/lib/bundler/vendor/thor/LICENSE.md +20 -0
  256. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +1 -1
  257. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +3 -2
  258. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +7 -17
  259. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +25 -14
  260. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +20 -10
  261. data/bundler/lib/bundler/vendor/thor/lib/thor/actions.rb +34 -15
  262. data/bundler/lib/bundler/vendor/thor/lib/thor/base.rb +63 -43
  263. data/bundler/lib/bundler/vendor/thor/lib/thor/command.rb +21 -14
  264. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
  265. data/bundler/lib/bundler/vendor/thor/lib/thor/error.rb +83 -0
  266. data/bundler/lib/bundler/vendor/thor/lib/thor/group.rb +3 -3
  267. data/bundler/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -0
  268. data/bundler/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +1 -1
  269. data/bundler/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +6 -6
  270. data/bundler/lib/bundler/vendor/thor/lib/thor/line_editor.rb +2 -2
  271. data/bundler/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
  272. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +7 -3
  273. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/option.rb +20 -7
  274. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +40 -6
  275. data/bundler/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -4
  276. data/bundler/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +1 -0
  277. data/bundler/lib/bundler/vendor/thor/lib/thor/runner.rb +15 -14
  278. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +88 -13
  279. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/color.rb +10 -2
  280. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/html.rb +3 -3
  281. data/bundler/lib/bundler/vendor/thor/lib/thor/shell.rb +5 -5
  282. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +18 -2
  283. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  284. data/bundler/lib/bundler/vendor/thor/lib/thor.rb +16 -9
  285. data/bundler/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  286. data/bundler/lib/bundler/vendor/tsort/lib/tsort.rb +452 -0
  287. data/bundler/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  288. data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +729 -0
  289. data/bundler/lib/bundler/vendor/uri/lib/uri/file.rb +100 -0
  290. data/bundler/lib/bundler/vendor/uri/lib/uri/ftp.rb +267 -0
  291. data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +1587 -0
  292. data/bundler/lib/bundler/vendor/uri/lib/uri/http.rb +125 -0
  293. data/bundler/lib/bundler/vendor/uri/lib/uri/https.rb +23 -0
  294. data/bundler/lib/bundler/vendor/uri/lib/uri/ldap.rb +261 -0
  295. data/bundler/lib/bundler/vendor/uri/lib/uri/ldaps.rb +22 -0
  296. data/bundler/lib/bundler/vendor/uri/lib/uri/mailto.rb +293 -0
  297. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +539 -0
  298. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +119 -0
  299. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +6 -0
  300. data/bundler/lib/bundler/vendor/uri/lib/uri/ws.rb +83 -0
  301. data/bundler/lib/bundler/vendor/uri/lib/uri/wss.rb +23 -0
  302. data/bundler/lib/bundler/vendor/uri/lib/uri.rb +104 -0
  303. data/bundler/lib/bundler/vendored_fileutils.rb +1 -6
  304. data/bundler/lib/bundler/vendored_persistent.rb +2 -39
  305. data/bundler/lib/bundler/{vendored_molinillo.rb → vendored_pub_grub.rb} +1 -1
  306. data/bundler/lib/bundler/vendored_thor.rb +2 -2
  307. data/bundler/lib/bundler/vendored_tsort.rb +4 -0
  308. data/bundler/lib/bundler/vendored_uri.rb +4 -0
  309. data/bundler/lib/bundler/version.rb +5 -20
  310. data/bundler/lib/bundler/vlad.rb +2 -2
  311. data/bundler/lib/bundler/worker.rb +26 -15
  312. data/bundler/lib/bundler/yaml_serializer.rb +3 -4
  313. data/bundler/lib/bundler.rb +285 -183
  314. data/hide_lib_for_update/note.txt +0 -4
  315. data/lib/rubygems/available_set.rb +7 -8
  316. data/lib/rubygems/basic_specification.rb +44 -31
  317. data/lib/rubygems/bundler_version_finder.rb +28 -50
  318. data/lib/rubygems/command.rb +104 -46
  319. data/lib/rubygems/command_manager.rb +35 -16
  320. data/lib/rubygems/commands/build_command.rb +77 -26
  321. data/lib/rubygems/commands/cert_command.rb +78 -76
  322. data/lib/rubygems/commands/check_command.rb +20 -22
  323. data/lib/rubygems/commands/cleanup_command.rb +36 -32
  324. data/lib/rubygems/commands/contents_command.rb +16 -18
  325. data/lib/rubygems/commands/dependency_command.rb +39 -50
  326. data/lib/rubygems/commands/environment_command.rb +11 -13
  327. data/lib/rubygems/commands/fetch_command.rb +33 -16
  328. data/lib/rubygems/commands/generate_index_command.rb +18 -17
  329. data/lib/rubygems/commands/help_command.rb +7 -7
  330. data/lib/rubygems/commands/info_command.rb +11 -6
  331. data/lib/rubygems/commands/install_command.rb +45 -79
  332. data/lib/rubygems/commands/list_command.rb +9 -8
  333. data/lib/rubygems/commands/lock_command.rb +7 -9
  334. data/lib/rubygems/commands/mirror_command.rb +3 -4
  335. data/lib/rubygems/commands/open_command.rb +11 -14
  336. data/lib/rubygems/commands/outdated_command.rb +5 -6
  337. data/lib/rubygems/commands/owner_command.rb +29 -22
  338. data/lib/rubygems/commands/pristine_command.rb +61 -51
  339. data/lib/rubygems/commands/push_command.rb +26 -63
  340. data/lib/rubygems/commands/query_command.rb +21 -337
  341. data/lib/rubygems/commands/rdoc_command.rb +26 -26
  342. data/lib/rubygems/commands/search_command.rb +8 -8
  343. data/lib/rubygems/commands/server_command.rb +16 -77
  344. data/lib/rubygems/commands/setup_command.rb +282 -241
  345. data/lib/rubygems/commands/signin_command.rb +9 -10
  346. data/lib/rubygems/commands/signout_command.rb +7 -9
  347. data/lib/rubygems/commands/sources_command.rb +42 -26
  348. data/lib/rubygems/commands/specification_command.rb +25 -20
  349. data/lib/rubygems/commands/stale_command.rb +3 -3
  350. data/lib/rubygems/commands/uninstall_command.rb +58 -49
  351. data/lib/rubygems/commands/unpack_command.rb +15 -44
  352. data/lib/rubygems/commands/update_command.rb +133 -81
  353. data/lib/rubygems/commands/which_command.rb +8 -11
  354. data/lib/rubygems/commands/yank_command.rb +22 -19
  355. data/lib/rubygems/compatibility.rb +7 -5
  356. data/lib/rubygems/config_file.rb +101 -47
  357. data/lib/rubygems/core_ext/kernel_gem.rb +8 -12
  358. data/lib/rubygems/core_ext/kernel_require.rb +124 -83
  359. data/lib/rubygems/core_ext/kernel_warn.rb +35 -30
  360. data/lib/rubygems/core_ext/tcpsocket_init.rb +52 -0
  361. data/lib/rubygems/defaults.rb +131 -55
  362. data/lib/rubygems/dependency.rb +44 -27
  363. data/lib/rubygems/dependency_installer.rb +49 -205
  364. data/lib/rubygems/dependency_list.rb +24 -25
  365. data/lib/rubygems/deprecate.rb +106 -12
  366. data/lib/rubygems/doctor.rb +22 -22
  367. data/lib/rubygems/errors.rb +8 -14
  368. data/lib/rubygems/exceptions.rb +35 -33
  369. data/lib/rubygems/ext/build_error.rb +2 -0
  370. data/lib/rubygems/ext/builder.rb +71 -95
  371. data/lib/rubygems/ext/cargo_builder/link_flag_converter.rb +27 -0
  372. data/lib/rubygems/ext/cargo_builder.rb +360 -0
  373. data/lib/rubygems/ext/cmake_builder.rb +6 -7
  374. data/lib/rubygems/ext/configure_builder.rb +5 -8
  375. data/lib/rubygems/ext/ext_conf_builder.rb +45 -65
  376. data/lib/rubygems/ext/rake_builder.rb +7 -10
  377. data/lib/rubygems/ext.rb +7 -6
  378. data/lib/rubygems/gem_runner.rb +15 -26
  379. data/lib/rubygems/gemcutter_utilities.rb +179 -54
  380. data/lib/rubygems/indexer.rb +38 -53
  381. data/lib/rubygems/install_default_message.rb +2 -2
  382. data/lib/rubygems/install_message.rb +2 -2
  383. data/lib/rubygems/install_update_options.rb +73 -64
  384. data/lib/rubygems/installer.rb +230 -173
  385. data/lib/rubygems/installer_uninstaller_utils.rb +29 -0
  386. data/lib/rubygems/local_remote_options.rb +22 -24
  387. data/lib/rubygems/mock_gem_ui.rb +2 -5
  388. data/lib/rubygems/name_tuple.rb +10 -14
  389. data/lib/rubygems/openssl.rb +7 -0
  390. data/lib/rubygems/optparse/.document +1 -0
  391. data/lib/rubygems/optparse/COPYING +56 -0
  392. data/lib/rubygems/optparse/lib/optionparser.rb +2 -0
  393. data/lib/rubygems/optparse/lib/optparse/ac.rb +54 -0
  394. data/lib/rubygems/optparse/lib/optparse/date.rb +18 -0
  395. data/lib/rubygems/optparse/lib/optparse/kwargs.rb +22 -0
  396. data/lib/rubygems/optparse/lib/optparse/shellwords.rb +7 -0
  397. data/lib/rubygems/optparse/lib/optparse/time.rb +11 -0
  398. data/lib/rubygems/optparse/lib/optparse/uri.rb +7 -0
  399. data/lib/rubygems/optparse/lib/optparse/version.rb +71 -0
  400. data/lib/rubygems/optparse/lib/optparse.rb +2308 -0
  401. data/lib/rubygems/optparse.rb +3 -0
  402. data/lib/rubygems/package/digest_io.rb +0 -2
  403. data/lib/rubygems/package/file_source.rb +2 -4
  404. data/lib/rubygems/package/io_source.rb +4 -2
  405. data/lib/rubygems/package/old.rb +9 -11
  406. data/lib/rubygems/package/tar_header.rb +73 -66
  407. data/lib/rubygems/package/tar_reader/entry.rb +8 -9
  408. data/lib/rubygems/package/tar_reader.rb +16 -13
  409. data/lib/rubygems/package/tar_writer.rb +12 -22
  410. data/lib/rubygems/package.rb +142 -125
  411. data/lib/rubygems/package_task.rb +5 -11
  412. data/lib/rubygems/path_support.rb +3 -8
  413. data/lib/rubygems/platform.rb +113 -73
  414. data/lib/rubygems/psych_tree.rb +1 -1
  415. data/lib/rubygems/query_utils.rb +351 -0
  416. data/lib/rubygems/rdoc.rb +4 -16
  417. data/lib/rubygems/remote_fetcher.rb +64 -136
  418. data/lib/rubygems/request/connection_pools.rb +7 -11
  419. data/lib/rubygems/request/http_pool.rb +2 -3
  420. data/lib/rubygems/request.rb +31 -32
  421. data/lib/rubygems/request_set/gem_dependency_api.rb +135 -136
  422. data/lib/rubygems/request_set/lockfile/parser.rb +28 -28
  423. data/lib/rubygems/request_set/lockfile/tokenizer.rb +5 -5
  424. data/lib/rubygems/request_set/lockfile.rb +21 -20
  425. data/lib/rubygems/request_set.rb +30 -43
  426. data/lib/rubygems/requirement.rb +42 -64
  427. data/lib/rubygems/resolver/activation_request.rb +29 -53
  428. data/lib/rubygems/resolver/api_set/gem_parser.rb +20 -0
  429. data/lib/rubygems/resolver/api_set.rb +33 -26
  430. data/lib/rubygems/resolver/api_specification.rb +30 -16
  431. data/lib/rubygems/resolver/best_set.rb +9 -11
  432. data/lib/rubygems/resolver/composed_set.rb +3 -5
  433. data/lib/rubygems/resolver/conflict.rb +12 -19
  434. data/lib/rubygems/resolver/current_set.rb +0 -2
  435. data/lib/rubygems/resolver/dependency_request.rb +3 -5
  436. data/lib/rubygems/resolver/git_set.rb +2 -4
  437. data/lib/rubygems/resolver/git_specification.rb +6 -8
  438. data/lib/rubygems/resolver/index_set.rb +4 -6
  439. data/lib/rubygems/resolver/index_specification.rb +38 -7
  440. data/lib/rubygems/resolver/installed_specification.rb +4 -6
  441. data/lib/rubygems/resolver/installer_set.rb +69 -27
  442. data/lib/rubygems/resolver/local_specification.rb +2 -4
  443. data/lib/rubygems/resolver/lock_set.rb +7 -9
  444. data/lib/rubygems/resolver/lock_specification.rb +6 -8
  445. data/lib/rubygems/resolver/molinillo/LICENSE +9 -0
  446. data/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/resolution_state.rb +7 -0
  447. data/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb +8 -0
  448. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action.rb +1 -0
  449. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +2 -1
  450. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +2 -1
  451. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +2 -1
  452. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +2 -1
  453. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/log.rb +7 -6
  454. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/set_payload.rb +2 -1
  455. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/tag.rb +4 -3
  456. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/vertex.rb +51 -12
  457. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb +42 -9
  458. data/lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb +82 -8
  459. data/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb +2 -1
  460. data/lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb +13 -1
  461. data/lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb +3 -1
  462. data/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb +510 -165
  463. data/lib/rubygems/resolver/molinillo/lib/molinillo/resolver.rb +3 -2
  464. data/lib/rubygems/resolver/molinillo/lib/molinillo/state.rb +8 -4
  465. data/lib/rubygems/resolver/molinillo/lib/molinillo.rb +6 -5
  466. data/lib/rubygems/resolver/molinillo.rb +1 -1
  467. data/lib/rubygems/resolver/requirement_list.rb +0 -1
  468. data/lib/rubygems/resolver/set.rb +0 -3
  469. data/lib/rubygems/resolver/source_set.rb +0 -2
  470. data/lib/rubygems/resolver/spec_specification.rb +14 -2
  471. data/lib/rubygems/resolver/specification.rb +14 -3
  472. data/lib/rubygems/resolver/vendor_set.rb +1 -3
  473. data/lib/rubygems/resolver/vendor_specification.rb +3 -5
  474. data/lib/rubygems/resolver.rb +58 -54
  475. data/lib/rubygems/s3_uri_signer.rb +175 -0
  476. data/lib/rubygems/safe_yaml.rb +14 -16
  477. data/lib/rubygems/security/policies.rb +47 -47
  478. data/lib/rubygems/security/policy.rb +25 -29
  479. data/lib/rubygems/security/signer.rb +16 -18
  480. data/lib/rubygems/security/trust_dir.rb +5 -6
  481. data/lib/rubygems/security.rb +90 -69
  482. data/lib/rubygems/security_option.rb +7 -8
  483. data/lib/rubygems/source/git.rb +30 -30
  484. data/lib/rubygems/source/installed.rb +1 -3
  485. data/lib/rubygems/source/local.rb +4 -6
  486. data/lib/rubygems/source/lock.rb +0 -2
  487. data/lib/rubygems/source/specific_file.rb +1 -3
  488. data/lib/rubygems/source/vendor.rb +0 -2
  489. data/lib/rubygems/source.rb +50 -38
  490. data/lib/rubygems/source_list.rb +9 -13
  491. data/lib/rubygems/spec_fetcher.rb +52 -64
  492. data/lib/rubygems/specification.rb +432 -463
  493. data/lib/rubygems/specification_policy.rb +185 -87
  494. data/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA_R3.pem +21 -0
  495. data/lib/rubygems/stub_specification.rb +24 -29
  496. data/lib/rubygems/text.rb +21 -21
  497. data/lib/rubygems/tsort/.document +1 -0
  498. data/lib/rubygems/tsort/LICENSE.txt +22 -0
  499. data/lib/rubygems/tsort/lib/tsort.rb +452 -0
  500. data/lib/rubygems/tsort.rb +3 -0
  501. data/lib/rubygems/uninstaller.rb +110 -57
  502. data/lib/rubygems/unknown_command_spell_checker.rb +21 -0
  503. data/lib/rubygems/update_suggestion.rb +69 -0
  504. data/lib/rubygems/uri.rb +126 -0
  505. data/lib/rubygems/uri_formatter.rb +2 -4
  506. data/lib/rubygems/user_interaction.rb +46 -49
  507. data/lib/rubygems/util/licenses.rb +511 -404
  508. data/lib/rubygems/util.rb +40 -56
  509. data/lib/rubygems/validator.rb +15 -37
  510. data/lib/rubygems/version.rb +48 -29
  511. data/lib/rubygems/version_option.rb +11 -5
  512. data/lib/rubygems.rb +305 -332
  513. data/rubygems-update.gemspec +6 -13
  514. data/setup.rb +11 -22
  515. data/test/rubygems/alternate_cert.pem +14 -14
  516. data/test/rubygems/alternate_cert_32.pem +15 -15
  517. data/test/rubygems/alternate_key.pem +25 -25
  518. data/test/rubygems/bundler_test_gem.rb +419 -0
  519. data/test/rubygems/ca_cert.pem +74 -65
  520. data/test/rubygems/child_cert.pem +15 -16
  521. data/test/rubygems/child_cert_32.pem +15 -16
  522. data/test/rubygems/child_key.pem +25 -25
  523. data/test/rubygems/client.pem +103 -45
  524. data/test/rubygems/data/excon-0.7.7.gemspec.rz +0 -0
  525. data/test/rubygems/data/null-required-ruby-version.gemspec.rz +0 -0
  526. data/test/rubygems/data/null-required-rubygems-version.gemspec.rz +0 -0
  527. data/test/rubygems/data/pry-0.4.7.gemspec.rz +0 -0
  528. data/test/rubygems/encrypted_private_key.pem +26 -26
  529. data/test/rubygems/expired_cert.pem +15 -15
  530. data/test/rubygems/future_cert.pem +15 -15
  531. data/test/rubygems/future_cert_32.pem +15 -15
  532. data/test/rubygems/grandchild_cert.pem +15 -16
  533. data/test/rubygems/grandchild_cert_32.pem +15 -16
  534. data/test/rubygems/grandchild_key.pem +25 -25
  535. data/{lib/rubygems/test_case.rb → test/rubygems/helper.rb} +505 -507
  536. data/{lib → test}/rubygems/installer_test_case.rb +115 -53
  537. data/test/rubygems/invalid_issuer_cert.pem +16 -16
  538. data/test/rubygems/invalid_issuer_cert_32.pem +16 -16
  539. data/test/rubygems/invalid_key.pem +25 -25
  540. data/test/rubygems/invalid_signer_cert.pem +15 -15
  541. data/test/rubygems/invalid_signer_cert_32.pem +15 -15
  542. data/test/rubygems/invalidchild_cert.pem +15 -16
  543. data/test/rubygems/invalidchild_cert_32.pem +15 -16
  544. data/test/rubygems/invalidchild_key.pem +25 -25
  545. data/{lib → test}/rubygems/package/tar_test_case.rb +4 -6
  546. data/test/rubygems/packages/Bluebie-legs-0.6.2.gem +0 -0
  547. data/test/rubygems/packages/ascii_binder-0.1.10.1.gem +0 -0
  548. data/test/rubygems/packages/ill-formatted-platform-1.0.0.10.gem +0 -0
  549. data/test/rubygems/plugin/exception/rubygems_plugin.rb +1 -1
  550. data/test/rubygems/plugin/standarderror/rubygems_plugin.rb +1 -1
  551. data/test/rubygems/private_ec_key.pem +9 -0
  552. data/test/rubygems/private_key.pem +25 -25
  553. data/test/rubygems/public_cert.pem +16 -16
  554. data/test/rubygems/public_cert_32.pem +15 -15
  555. data/test/rubygems/public_key.pem +7 -7
  556. data/test/rubygems/rubygems/commands/crash_command.rb +0 -2
  557. data/test/rubygems/rubygems_plugin.rb +2 -4
  558. data/test/rubygems/specifications/bar-0.0.2.gemspec +0 -2
  559. data/test/rubygems/specifications/rubyforge-0.0.1.gemspec +12 -0
  560. data/test/rubygems/ssl_cert.pem +78 -17
  561. data/test/rubygems/ssl_key.pem +25 -13
  562. data/test/rubygems/test_bundled_ca.rb +44 -47
  563. data/test/rubygems/test_config.rb +5 -7
  564. data/test/rubygems/test_deprecate.rb +90 -10
  565. data/test/rubygems/test_exit.rb +17 -0
  566. data/test/rubygems/test_gem.rb +679 -885
  567. data/test/rubygems/test_gem_available_set.rb +24 -25
  568. data/test/rubygems/test_gem_bundler_version_finder.rb +42 -42
  569. data/test/rubygems/test_gem_command.rb +186 -39
  570. data/test/rubygems/test_gem_command_manager.rb +166 -36
  571. data/test/rubygems/test_gem_commands_build_command.rb +436 -52
  572. data/test/rubygems/test_gem_commands_cert_command.rb +193 -124
  573. data/test/rubygems/test_gem_commands_check_command.rb +9 -11
  574. data/test/rubygems/test_gem_commands_cleanup_command.rb +87 -62
  575. data/test/rubygems/test_gem_commands_contents_command.rb +73 -42
  576. data/test/rubygems/test_gem_commands_dependency_command.rb +39 -41
  577. data/test/rubygems/test_gem_commands_environment_command.rb +60 -48
  578. data/test/rubygems/test_gem_commands_fetch_command.rb +163 -32
  579. data/test/rubygems/test_gem_commands_generate_index_command.rb +39 -9
  580. data/test/rubygems/test_gem_commands_help_command.rb +34 -19
  581. data/test/rubygems/test_gem_commands_info_command.rb +34 -9
  582. data/test/rubygems/test_gem_commands_install_command.rb +600 -173
  583. data/test/rubygems/test_gem_commands_list_command.rb +5 -7
  584. data/test/rubygems/test_gem_commands_lock_command.rb +11 -13
  585. data/test/rubygems/test_gem_commands_mirror.rb +3 -4
  586. data/test/rubygems/test_gem_commands_open_command.rb +16 -19
  587. data/test/rubygems/test_gem_commands_outdated_command.rb +24 -7
  588. data/test/rubygems/test_gem_commands_owner_command.rb +183 -49
  589. data/test/rubygems/test_gem_commands_pristine_command.rb +222 -89
  590. data/test/rubygems/test_gem_commands_push_command.rb +178 -69
  591. data/test/rubygems/test_gem_commands_query_command.rb +114 -89
  592. data/test/rubygems/test_gem_commands_search_command.rb +2 -4
  593. data/test/rubygems/test_gem_commands_server_command.rb +6 -46
  594. data/test/rubygems/test_gem_commands_setup_command.rb +334 -157
  595. data/test/rubygems/test_gem_commands_signin_command.rb +187 -27
  596. data/test/rubygems/test_gem_commands_signout_command.rb +3 -10
  597. data/test/rubygems/test_gem_commands_sources_command.rb +266 -33
  598. data/test/rubygems/test_gem_commands_specification_command.rb +81 -55
  599. data/test/rubygems/test_gem_commands_stale_command.rb +4 -6
  600. data/test/rubygems/test_gem_commands_uninstall_command.rb +230 -95
  601. data/test/rubygems/test_gem_commands_unpack_command.rb +32 -34
  602. data/test/rubygems/test_gem_commands_update_command.rb +412 -102
  603. data/test/rubygems/test_gem_commands_which_command.rb +12 -14
  604. data/test/rubygems/test_gem_commands_yank_command.rb +107 -26
  605. data/test/rubygems/test_gem_config_file.rb +120 -96
  606. data/test/rubygems/test_gem_dependency.rb +94 -86
  607. data/test/rubygems/test_gem_dependency_installer.rb +305 -388
  608. data/test/rubygems/test_gem_dependency_list.rb +66 -61
  609. data/test/rubygems/test_gem_dependency_resolution_error.rb +5 -7
  610. data/test/rubygems/test_gem_doctor.rb +73 -47
  611. data/test/rubygems/test_gem_ext_builder.rb +116 -106
  612. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/.gitignore +1 -0
  613. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/custom_name.gemspec +8 -0
  614. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.lock +233 -0
  615. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.toml +10 -0
  616. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/src/lib.rs +27 -0
  617. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/lib/custom_name.rb +1 -0
  618. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/.gitignore +1 -0
  619. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock +233 -0
  620. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml +10 -0
  621. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/rust_ruby_example.gemspec +8 -0
  622. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/src/lib.rs +51 -0
  623. data/test/rubygems/test_gem_ext_cargo_builder.rb +166 -0
  624. data/test/rubygems/test_gem_ext_cargo_builder_link_flag_converter.rb +33 -0
  625. data/test/rubygems/test_gem_ext_cargo_builder_unit.rb +60 -0
  626. data/test/rubygems/test_gem_ext_cmake_builder.rb +32 -37
  627. data/test/rubygems/test_gem_ext_configure_builder.rb +23 -31
  628. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +75 -79
  629. data/test/rubygems/test_gem_ext_rake_builder.rb +49 -30
  630. data/test/rubygems/test_gem_gem_runner.rb +52 -7
  631. data/test/rubygems/test_gem_gemcutter_utilities.rb +91 -76
  632. data/test/rubygems/test_gem_impossible_dependencies_error.rb +4 -6
  633. data/test/rubygems/test_gem_indexer.rb +120 -105
  634. data/test/rubygems/test_gem_install_update_options.rb +57 -33
  635. data/test/rubygems/test_gem_installer.rb +1230 -644
  636. data/test/rubygems/test_gem_local_remote_options.rb +11 -13
  637. data/test/rubygems/test_gem_name_tuple.rb +4 -6
  638. data/test/rubygems/test_gem_package.rb +396 -266
  639. data/test/rubygems/test_gem_package_old.rb +57 -56
  640. data/test/rubygems/test_gem_package_tar_header.rb +108 -50
  641. data/test/rubygems/test_gem_package_tar_reader.rb +8 -10
  642. data/test/rubygems/test_gem_package_tar_reader_entry.rb +77 -20
  643. data/test/rubygems/test_gem_package_tar_writer.rb +107 -101
  644. data/test/rubygems/test_gem_package_task.rb +58 -25
  645. data/test/rubygems/test_gem_path_support.rb +29 -29
  646. data/test/rubygems/test_gem_platform.rb +388 -199
  647. data/test/rubygems/test_gem_rdoc.rb +20 -155
  648. data/test/rubygems/test_gem_remote_fetcher.rb +474 -303
  649. data/test/rubygems/test_gem_request.rb +128 -85
  650. data/test/rubygems/test_gem_request_connection_pools.rb +32 -32
  651. data/test/rubygems/test_gem_request_set.rb +186 -110
  652. data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +280 -261
  653. data/test/rubygems/test_gem_request_set_lockfile.rb +93 -94
  654. data/test/rubygems/test_gem_request_set_lockfile_parser.rb +68 -69
  655. data/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb +136 -136
  656. data/test/rubygems/test_gem_requirement.rb +140 -55
  657. data/test/rubygems/test_gem_resolver.rb +224 -115
  658. data/test/rubygems/test_gem_resolver_activation_request.rb +9 -40
  659. data/test/rubygems/test_gem_resolver_api_set.rb +79 -78
  660. data/test/rubygems/test_gem_resolver_api_specification.rb +47 -49
  661. data/test/rubygems/test_gem_resolver_best_set.rb +43 -22
  662. data/test/rubygems/test_gem_resolver_composed_set.rb +1 -3
  663. data/test/rubygems/test_gem_resolver_conflict.rb +12 -18
  664. data/test/rubygems/test_gem_resolver_dependency_request.rb +15 -17
  665. data/test/rubygems/test_gem_resolver_git_set.rb +22 -24
  666. data/test/rubygems/test_gem_resolver_git_specification.rb +22 -22
  667. data/test/rubygems/test_gem_resolver_index_set.rb +14 -16
  668. data/test/rubygems/test_gem_resolver_index_specification.rb +21 -18
  669. data/test/rubygems/test_gem_resolver_installed_specification.rb +5 -8
  670. data/test/rubygems/test_gem_resolver_installer_set.rb +106 -44
  671. data/test/rubygems/test_gem_resolver_local_specification.rb +7 -9
  672. data/test/rubygems/test_gem_resolver_lock_set.rb +15 -17
  673. data/test/rubygems/test_gem_resolver_lock_specification.rb +17 -19
  674. data/test/rubygems/test_gem_resolver_requirement_list.rb +1 -3
  675. data/test/rubygems/test_gem_resolver_specification.rb +8 -10
  676. data/test/rubygems/test_gem_resolver_vendor_set.rb +9 -11
  677. data/test/rubygems/test_gem_resolver_vendor_specification.rb +10 -12
  678. data/test/rubygems/test_gem_security.rb +109 -79
  679. data/test/rubygems/test_gem_security_policy.rb +102 -107
  680. data/test/rubygems/test_gem_security_signer.rb +51 -52
  681. data/test/rubygems/test_gem_security_trust_dir.rb +14 -16
  682. data/test/rubygems/test_gem_silent_ui.rb +47 -42
  683. data/test/rubygems/test_gem_source.rb +66 -51
  684. data/test/rubygems/test_gem_source_fetch_problem.rb +17 -8
  685. data/test/rubygems/test_gem_source_git.rb +74 -74
  686. data/test/rubygems/test_gem_source_installed.rb +16 -18
  687. data/test/rubygems/test_gem_source_list.rb +5 -5
  688. data/test/rubygems/test_gem_source_local.rb +15 -16
  689. data/test/rubygems/test_gem_source_lock.rb +31 -33
  690. data/test/rubygems/test_gem_source_specific_file.rb +18 -19
  691. data/test/rubygems/test_gem_source_subpath_problem.rb +49 -0
  692. data/test/rubygems/test_gem_source_vendor.rb +13 -15
  693. data/test/rubygems/test_gem_spec_fetcher.rb +74 -67
  694. data/test/rubygems/test_gem_specification.rb +1051 -1071
  695. data/test/rubygems/test_gem_stream_ui.rb +25 -23
  696. data/test/rubygems/test_gem_stub_specification.rb +39 -56
  697. data/test/rubygems/test_gem_text.rb +8 -3
  698. data/test/rubygems/test_gem_uninstaller.rb +269 -100
  699. data/test/rubygems/test_gem_unsatisfiable_dependency_error.rb +3 -5
  700. data/test/rubygems/test_gem_update_suggestion.rb +208 -0
  701. data/test/rubygems/test_gem_uri.rb +39 -0
  702. data/test/rubygems/test_gem_uri_formatter.rb +14 -16
  703. data/test/rubygems/test_gem_util.rb +46 -34
  704. data/test/rubygems/test_gem_validator.rb +12 -15
  705. data/test/rubygems/test_gem_version.rb +49 -34
  706. data/test/rubygems/test_gem_version_option.rb +16 -18
  707. data/test/rubygems/test_kernel.rb +61 -53
  708. data/test/rubygems/test_project_sanity.rb +20 -0
  709. data/test/rubygems/test_remote_fetch_error.rb +7 -8
  710. data/test/rubygems/test_require.rb +415 -121
  711. data/test/rubygems/test_rubygems.rb +74 -0
  712. data/{lib/rubygems/test_utilities.rb → test/rubygems/utilities.rb} +74 -50
  713. data/test/rubygems/wrong_key_cert.pem +15 -15
  714. data/test/rubygems/wrong_key_cert_32.pem +15 -15
  715. data/test/test_changelog_generator.rb +17 -0
  716. metadata +218 -244
  717. data/.rubocop.yml +0 -66
  718. data/.travis.yml +0 -38
  719. data/History.txt +0 -3965
  720. data/Rakefile +0 -372
  721. data/appveyor.yml +0 -43
  722. data/bundler/CODE_OF_CONDUCT.md +0 -42
  723. data/bundler/CONTRIBUTING.md +0 -17
  724. data/bundler/exe/bundle_ruby +0 -60
  725. data/bundler/lib/bundler/cli/package.rb +0 -49
  726. data/bundler/lib/bundler/compatibility_guard.rb +0 -14
  727. data/bundler/lib/bundler/dep_proxy.rb +0 -48
  728. data/bundler/lib/bundler/gem_remote_fetcher.rb +0 -43
  729. data/bundler/lib/bundler/gemdeps.rb +0 -29
  730. data/bundler/lib/bundler/psyched_yaml.rb +0 -37
  731. data/bundler/lib/bundler/ssl_certs/certificate_manager.rb +0 -66
  732. data/bundler/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
  733. data/bundler/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
  734. data/bundler/lib/bundler/templates/gems.rb +0 -8
  735. data/bundler/lib/bundler/templates/newgem/test/test_helper.rb.tt +0 -4
  736. data/bundler/lib/bundler/templates/newgem/travis.yml.tt +0 -7
  737. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +0 -26
  738. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
  739. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +0 -81
  740. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +0 -36
  741. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +0 -66
  742. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +0 -62
  743. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +0 -63
  744. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +0 -61
  745. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +0 -126
  746. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +0 -46
  747. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +0 -36
  748. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +0 -136
  749. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -223
  750. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +0 -143
  751. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +0 -6
  752. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +0 -101
  753. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +0 -67
  754. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +0 -837
  755. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +0 -46
  756. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +0 -58
  757. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -12
  758. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb +0 -27
  759. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb +0 -129
  760. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +0 -12
  761. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -129
  762. data/bundler/lib/bundler/version_ranges.rb +0 -76
  763. data/bundler/man/bundle-gem.1 +0 -80
  764. data/bundler/man/bundle-gem.ronn +0 -78
  765. data/bundler/man/bundle-package.1 +0 -55
  766. data/lib/rubygems/psych_additions.rb +0 -10
  767. data/lib/rubygems/server.rb +0 -878
  768. data/lib/rubygems/source_local.rb +0 -7
  769. data/lib/rubygems/source_specific_file.rb +0 -6
  770. data/lib/rubygems/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +0 -21
  771. data/lib/rubygems/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
  772. data/lib/rubygems/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
  773. data/lib/rubygems/syck_hack.rb +0 -77
  774. data/lib/ubygems.rb +0 -14
  775. data/test/rubygems/bogussources.rb +0 -9
  776. data/test/rubygems/data/null-type.gemspec.rz +0 -0
  777. data/test/rubygems/test_gem_server.rb +0 -607
  778. data/util/CL2notes +0 -55
  779. data/util/ci +0 -77
  780. data/util/create_certs.rb +0 -171
  781. data/util/create_encrypted_key.rb +0 -16
  782. data/util/generate_spdx_license_list.rb +0 -61
  783. data/util/patch_with_prs.rb +0 -77
  784. data/util/rubocop +0 -8
  785. data/util/update_bundled_ca_certificates.rb +0 -139
  786. data/util/update_changelog.rb +0 -67
  787. /data/bundler/lib/bundler/{ssl_certs → man}/.document +0 -0
  788. /data/bundler/{man/bundle-check.ronn → lib/bundler/man/bundle-check.1.ronn} +0 -0
  789. /data/bundler/{man/bundle-doctor.ronn → lib/bundler/man/bundle-doctor.1.ronn} +0 -0
  790. /data/bundler/{man/bundle-info.ronn → lib/bundler/man/bundle-info.1.ronn} +0 -0
  791. /data/bundler/{man/bundle-lock.ronn → lib/bundler/man/bundle-lock.1.ronn} +0 -0
  792. /data/bundler/{man/bundle-pristine.ronn → lib/bundler/man/bundle-pristine.1.ronn} +0 -0
  793. /data/bundler/{man/bundle-remove.ronn → lib/bundler/man/bundle-remove.1.ronn} +0 -0
  794. /data/bundler/{man/bundle-show.ronn → lib/bundler/man/bundle-show.1.ronn} +0 -0
  795. /data/{bundler/lib/bundler/ssl_certs/index.rubygems.org → lib/rubygems/ssl_certs/rubygems.org}/GlobalSignRootCA.pem +0 -0
@@ -0,0 +1,1587 @@
1
+ # frozen_string_literal: true
2
+
3
+ # = uri/generic.rb
4
+ #
5
+ # Author:: Akira Yamada <akira@ruby-lang.org>
6
+ # License:: You can redistribute it and/or modify it under the same term as Ruby.
7
+ #
8
+ # See Bundler::URI for general documentation
9
+ #
10
+
11
+ require_relative 'common'
12
+ autoload :IPSocket, 'socket'
13
+ autoload :IPAddr, 'ipaddr'
14
+
15
+ module Bundler::URI
16
+
17
+ #
18
+ # Base class for all Bundler::URI classes.
19
+ # Implements generic Bundler::URI syntax as per RFC 2396.
20
+ #
21
+ class Generic
22
+ include Bundler::URI
23
+
24
+ #
25
+ # A Default port of nil for Bundler::URI::Generic.
26
+ #
27
+ DEFAULT_PORT = nil
28
+
29
+ #
30
+ # Returns default port.
31
+ #
32
+ def self.default_port
33
+ self::DEFAULT_PORT
34
+ end
35
+
36
+ #
37
+ # Returns default port.
38
+ #
39
+ def default_port
40
+ self.class.default_port
41
+ end
42
+
43
+ #
44
+ # An Array of the available components for Bundler::URI::Generic.
45
+ #
46
+ COMPONENT = [
47
+ :scheme,
48
+ :userinfo, :host, :port, :registry,
49
+ :path, :opaque,
50
+ :query,
51
+ :fragment
52
+ ].freeze
53
+
54
+ #
55
+ # Components of the Bundler::URI in the order.
56
+ #
57
+ def self.component
58
+ self::COMPONENT
59
+ end
60
+
61
+ USE_REGISTRY = false # :nodoc:
62
+
63
+ def self.use_registry # :nodoc:
64
+ self::USE_REGISTRY
65
+ end
66
+
67
+ #
68
+ # == Synopsis
69
+ #
70
+ # See ::new.
71
+ #
72
+ # == Description
73
+ #
74
+ # At first, tries to create a new Bundler::URI::Generic instance using
75
+ # Bundler::URI::Generic::build. But, if exception Bundler::URI::InvalidComponentError is raised,
76
+ # then it does Bundler::URI::Escape.escape all Bundler::URI components and tries again.
77
+ #
78
+ def self.build2(args)
79
+ begin
80
+ return self.build(args)
81
+ rescue InvalidComponentError
82
+ if args.kind_of?(Array)
83
+ return self.build(args.collect{|x|
84
+ if x.is_a?(String)
85
+ DEFAULT_PARSER.escape(x)
86
+ else
87
+ x
88
+ end
89
+ })
90
+ elsif args.kind_of?(Hash)
91
+ tmp = {}
92
+ args.each do |key, value|
93
+ tmp[key] = if value
94
+ DEFAULT_PARSER.escape(value)
95
+ else
96
+ value
97
+ end
98
+ end
99
+ return self.build(tmp)
100
+ end
101
+ end
102
+ end
103
+
104
+ #
105
+ # == Synopsis
106
+ #
107
+ # See ::new.
108
+ #
109
+ # == Description
110
+ #
111
+ # Creates a new Bundler::URI::Generic instance from components of Bundler::URI::Generic
112
+ # with check. Components are: scheme, userinfo, host, port, registry, path,
113
+ # opaque, query, and fragment. You can provide arguments either by an Array or a Hash.
114
+ # See ::new for hash keys to use or for order of array items.
115
+ #
116
+ def self.build(args)
117
+ if args.kind_of?(Array) &&
118
+ args.size == ::Bundler::URI::Generic::COMPONENT.size
119
+ tmp = args.dup
120
+ elsif args.kind_of?(Hash)
121
+ tmp = ::Bundler::URI::Generic::COMPONENT.collect do |c|
122
+ if args.include?(c)
123
+ args[c]
124
+ else
125
+ nil
126
+ end
127
+ end
128
+ else
129
+ component = self.class.component rescue ::Bundler::URI::Generic::COMPONENT
130
+ raise ArgumentError,
131
+ "expected Array of or Hash of components of #{self.class} (#{component.join(', ')})"
132
+ end
133
+
134
+ tmp << nil
135
+ tmp << true
136
+ return self.new(*tmp)
137
+ end
138
+
139
+ #
140
+ # == Args
141
+ #
142
+ # +scheme+::
143
+ # Protocol scheme, i.e. 'http','ftp','mailto' and so on.
144
+ # +userinfo+::
145
+ # User name and password, i.e. 'sdmitry:bla'.
146
+ # +host+::
147
+ # Server host name.
148
+ # +port+::
149
+ # Server port.
150
+ # +registry+::
151
+ # Registry of naming authorities.
152
+ # +path+::
153
+ # Path on server.
154
+ # +opaque+::
155
+ # Opaque part.
156
+ # +query+::
157
+ # Query data.
158
+ # +fragment+::
159
+ # Part of the Bundler::URI after '#' character.
160
+ # +parser+::
161
+ # Parser for internal use [Bundler::URI::DEFAULT_PARSER by default].
162
+ # +arg_check+::
163
+ # Check arguments [false by default].
164
+ #
165
+ # == Description
166
+ #
167
+ # Creates a new Bundler::URI::Generic instance from ``generic'' components without check.
168
+ #
169
+ def initialize(scheme,
170
+ userinfo, host, port, registry,
171
+ path, opaque,
172
+ query,
173
+ fragment,
174
+ parser = DEFAULT_PARSER,
175
+ arg_check = false)
176
+ @scheme = nil
177
+ @user = nil
178
+ @password = nil
179
+ @host = nil
180
+ @port = nil
181
+ @path = nil
182
+ @query = nil
183
+ @opaque = nil
184
+ @fragment = nil
185
+ @parser = parser == DEFAULT_PARSER ? nil : parser
186
+
187
+ if arg_check
188
+ self.scheme = scheme
189
+ self.userinfo = userinfo
190
+ self.hostname = host
191
+ self.port = port
192
+ self.path = path
193
+ self.query = query
194
+ self.opaque = opaque
195
+ self.fragment = fragment
196
+ else
197
+ self.set_scheme(scheme)
198
+ self.set_userinfo(userinfo)
199
+ self.set_host(host)
200
+ self.set_port(port)
201
+ self.set_path(path)
202
+ self.query = query
203
+ self.set_opaque(opaque)
204
+ self.fragment=(fragment)
205
+ end
206
+ if registry
207
+ raise InvalidURIError,
208
+ "the scheme #{@scheme} does not accept registry part: #{registry} (or bad hostname?)"
209
+ end
210
+
211
+ @scheme&.freeze
212
+ self.set_path('') if !@path && !@opaque # (see RFC2396 Section 5.2)
213
+ self.set_port(self.default_port) if self.default_port && !@port
214
+ end
215
+
216
+ #
217
+ # Returns the scheme component of the Bundler::URI.
218
+ #
219
+ # Bundler::URI("http://foo/bar/baz").scheme #=> "http"
220
+ #
221
+ attr_reader :scheme
222
+
223
+ # Returns the host component of the Bundler::URI.
224
+ #
225
+ # Bundler::URI("http://foo/bar/baz").host #=> "foo"
226
+ #
227
+ # It returns nil if no host component exists.
228
+ #
229
+ # Bundler::URI("mailto:foo@example.org").host #=> nil
230
+ #
231
+ # The component does not contain the port number.
232
+ #
233
+ # Bundler::URI("http://foo:8080/bar/baz").host #=> "foo"
234
+ #
235
+ # Since IPv6 addresses are wrapped with brackets in URIs,
236
+ # this method returns IPv6 addresses wrapped with brackets.
237
+ # This form is not appropriate to pass to socket methods such as TCPSocket.open.
238
+ # If unwrapped host names are required, use the #hostname method.
239
+ #
240
+ # Bundler::URI("http://[::1]/bar/baz").host #=> "[::1]"
241
+ # Bundler::URI("http://[::1]/bar/baz").hostname #=> "::1"
242
+ #
243
+ attr_reader :host
244
+
245
+ # Returns the port component of the Bundler::URI.
246
+ #
247
+ # Bundler::URI("http://foo/bar/baz").port #=> 80
248
+ # Bundler::URI("http://foo:8080/bar/baz").port #=> 8080
249
+ #
250
+ attr_reader :port
251
+
252
+ def registry # :nodoc:
253
+ nil
254
+ end
255
+
256
+ # Returns the path component of the Bundler::URI.
257
+ #
258
+ # Bundler::URI("http://foo/bar/baz").path #=> "/bar/baz"
259
+ #
260
+ attr_reader :path
261
+
262
+ # Returns the query component of the Bundler::URI.
263
+ #
264
+ # Bundler::URI("http://foo/bar/baz?search=FooBar").query #=> "search=FooBar"
265
+ #
266
+ attr_reader :query
267
+
268
+ # Returns the opaque part of the Bundler::URI.
269
+ #
270
+ # Bundler::URI("mailto:foo@example.org").opaque #=> "foo@example.org"
271
+ # Bundler::URI("http://foo/bar/baz").opaque #=> nil
272
+ #
273
+ # The portion of the path that does not make use of the slash '/'.
274
+ # The path typically refers to an absolute path or an opaque part.
275
+ # (See RFC2396 Section 3 and 5.2.)
276
+ #
277
+ attr_reader :opaque
278
+
279
+ # Returns the fragment component of the Bundler::URI.
280
+ #
281
+ # Bundler::URI("http://foo/bar/baz?search=FooBar#ponies").fragment #=> "ponies"
282
+ #
283
+ attr_reader :fragment
284
+
285
+ # Returns the parser to be used.
286
+ #
287
+ # Unless a Bundler::URI::Parser is defined, DEFAULT_PARSER is used.
288
+ #
289
+ def parser
290
+ if !defined?(@parser) || !@parser
291
+ DEFAULT_PARSER
292
+ else
293
+ @parser || DEFAULT_PARSER
294
+ end
295
+ end
296
+
297
+ # Replaces self by other Bundler::URI object.
298
+ #
299
+ def replace!(oth)
300
+ if self.class != oth.class
301
+ raise ArgumentError, "expected #{self.class} object"
302
+ end
303
+
304
+ component.each do |c|
305
+ self.__send__("#{c}=", oth.__send__(c))
306
+ end
307
+ end
308
+ private :replace!
309
+
310
+ #
311
+ # Components of the Bundler::URI in the order.
312
+ #
313
+ def component
314
+ self.class.component
315
+ end
316
+
317
+ #
318
+ # Checks the scheme +v+ component against the Bundler::URI::Parser Regexp for :SCHEME.
319
+ #
320
+ def check_scheme(v)
321
+ if v && parser.regexp[:SCHEME] !~ v
322
+ raise InvalidComponentError,
323
+ "bad component(expected scheme component): #{v}"
324
+ end
325
+
326
+ return true
327
+ end
328
+ private :check_scheme
329
+
330
+ # Protected setter for the scheme component +v+.
331
+ #
332
+ # See also Bundler::URI::Generic.scheme=.
333
+ #
334
+ def set_scheme(v)
335
+ @scheme = v&.downcase
336
+ end
337
+ protected :set_scheme
338
+
339
+ #
340
+ # == Args
341
+ #
342
+ # +v+::
343
+ # String
344
+ #
345
+ # == Description
346
+ #
347
+ # Public setter for the scheme component +v+
348
+ # (with validation).
349
+ #
350
+ # See also Bundler::URI::Generic.check_scheme.
351
+ #
352
+ # == Usage
353
+ #
354
+ # require 'bundler/vendor/uri/lib/uri'
355
+ #
356
+ # uri = Bundler::URI.parse("http://my.example.com")
357
+ # uri.scheme = "https"
358
+ # uri.to_s #=> "https://my.example.com"
359
+ #
360
+ def scheme=(v)
361
+ check_scheme(v)
362
+ set_scheme(v)
363
+ v
364
+ end
365
+
366
+ #
367
+ # Checks the +user+ and +password+.
368
+ #
369
+ # If +password+ is not provided, then +user+ is
370
+ # split, using Bundler::URI::Generic.split_userinfo, to
371
+ # pull +user+ and +password.
372
+ #
373
+ # See also Bundler::URI::Generic.check_user, Bundler::URI::Generic.check_password.
374
+ #
375
+ def check_userinfo(user, password = nil)
376
+ if !password
377
+ user, password = split_userinfo(user)
378
+ end
379
+ check_user(user)
380
+ check_password(password, user)
381
+
382
+ return true
383
+ end
384
+ private :check_userinfo
385
+
386
+ #
387
+ # Checks the user +v+ component for RFC2396 compliance
388
+ # and against the Bundler::URI::Parser Regexp for :USERINFO.
389
+ #
390
+ # Can not have a registry or opaque component defined,
391
+ # with a user component defined.
392
+ #
393
+ def check_user(v)
394
+ if @opaque
395
+ raise InvalidURIError,
396
+ "can not set user with opaque"
397
+ end
398
+
399
+ return v unless v
400
+
401
+ if parser.regexp[:USERINFO] !~ v
402
+ raise InvalidComponentError,
403
+ "bad component(expected userinfo component or user component): #{v}"
404
+ end
405
+
406
+ return true
407
+ end
408
+ private :check_user
409
+
410
+ #
411
+ # Checks the password +v+ component for RFC2396 compliance
412
+ # and against the Bundler::URI::Parser Regexp for :USERINFO.
413
+ #
414
+ # Can not have a registry or opaque component defined,
415
+ # with a user component defined.
416
+ #
417
+ def check_password(v, user = @user)
418
+ if @opaque
419
+ raise InvalidURIError,
420
+ "can not set password with opaque"
421
+ end
422
+ return v unless v
423
+
424
+ if !user
425
+ raise InvalidURIError,
426
+ "password component depends user component"
427
+ end
428
+
429
+ if parser.regexp[:USERINFO] !~ v
430
+ raise InvalidComponentError,
431
+ "bad password component"
432
+ end
433
+
434
+ return true
435
+ end
436
+ private :check_password
437
+
438
+ #
439
+ # Sets userinfo, argument is string like 'name:pass'.
440
+ #
441
+ def userinfo=(userinfo)
442
+ if userinfo.nil?
443
+ return nil
444
+ end
445
+ check_userinfo(*userinfo)
446
+ set_userinfo(*userinfo)
447
+ # returns userinfo
448
+ end
449
+
450
+ #
451
+ # == Args
452
+ #
453
+ # +v+::
454
+ # String
455
+ #
456
+ # == Description
457
+ #
458
+ # Public setter for the +user+ component
459
+ # (with validation).
460
+ #
461
+ # See also Bundler::URI::Generic.check_user.
462
+ #
463
+ # == Usage
464
+ #
465
+ # require 'bundler/vendor/uri/lib/uri'
466
+ #
467
+ # uri = Bundler::URI.parse("http://john:S3nsit1ve@my.example.com")
468
+ # uri.user = "sam"
469
+ # uri.to_s #=> "http://sam:V3ry_S3nsit1ve@my.example.com"
470
+ #
471
+ def user=(user)
472
+ check_user(user)
473
+ set_user(user)
474
+ # returns user
475
+ end
476
+
477
+ #
478
+ # == Args
479
+ #
480
+ # +v+::
481
+ # String
482
+ #
483
+ # == Description
484
+ #
485
+ # Public setter for the +password+ component
486
+ # (with validation).
487
+ #
488
+ # See also Bundler::URI::Generic.check_password.
489
+ #
490
+ # == Usage
491
+ #
492
+ # require 'bundler/vendor/uri/lib/uri'
493
+ #
494
+ # uri = Bundler::URI.parse("http://john:S3nsit1ve@my.example.com")
495
+ # uri.password = "V3ry_S3nsit1ve"
496
+ # uri.to_s #=> "http://john:V3ry_S3nsit1ve@my.example.com"
497
+ #
498
+ def password=(password)
499
+ check_password(password)
500
+ set_password(password)
501
+ # returns password
502
+ end
503
+
504
+ # Protected setter for the +user+ component, and +password+ if available
505
+ # (with validation).
506
+ #
507
+ # See also Bundler::URI::Generic.userinfo=.
508
+ #
509
+ def set_userinfo(user, password = nil)
510
+ unless password
511
+ user, password = split_userinfo(user)
512
+ end
513
+ @user = user
514
+ @password = password if password
515
+
516
+ [@user, @password]
517
+ end
518
+ protected :set_userinfo
519
+
520
+ # Protected setter for the user component +v+.
521
+ #
522
+ # See also Bundler::URI::Generic.user=.
523
+ #
524
+ def set_user(v)
525
+ set_userinfo(v, @password)
526
+ v
527
+ end
528
+ protected :set_user
529
+
530
+ # Protected setter for the password component +v+.
531
+ #
532
+ # See also Bundler::URI::Generic.password=.
533
+ #
534
+ def set_password(v)
535
+ @password = v
536
+ # returns v
537
+ end
538
+ protected :set_password
539
+
540
+ # Returns the userinfo +ui+ as <code>[user, password]</code>
541
+ # if properly formatted as 'user:password'.
542
+ def split_userinfo(ui)
543
+ return nil, nil unless ui
544
+ user, password = ui.split(':', 2)
545
+
546
+ return user, password
547
+ end
548
+ private :split_userinfo
549
+
550
+ # Escapes 'user:password' +v+ based on RFC 1738 section 3.1.
551
+ def escape_userpass(v)
552
+ parser.escape(v, /[@:\/]/o) # RFC 1738 section 3.1 #/
553
+ end
554
+ private :escape_userpass
555
+
556
+ # Returns the userinfo, either as 'user' or 'user:password'.
557
+ def userinfo
558
+ if @user.nil?
559
+ nil
560
+ elsif @password.nil?
561
+ @user
562
+ else
563
+ @user + ':' + @password
564
+ end
565
+ end
566
+
567
+ # Returns the user component (without Bundler::URI decoding).
568
+ def user
569
+ @user
570
+ end
571
+
572
+ # Returns the password component (without Bundler::URI decoding).
573
+ def password
574
+ @password
575
+ end
576
+
577
+ # Returns the user component after Bundler::URI decoding.
578
+ def decoded_user
579
+ Bundler::URI.decode_uri_component(@user) if @user
580
+ end
581
+
582
+ # Returns the password component after Bundler::URI decoding.
583
+ def decoded_password
584
+ Bundler::URI.decode_uri_component(@password) if @password
585
+ end
586
+
587
+ #
588
+ # Checks the host +v+ component for RFC2396 compliance
589
+ # and against the Bundler::URI::Parser Regexp for :HOST.
590
+ #
591
+ # Can not have a registry or opaque component defined,
592
+ # with a host component defined.
593
+ #
594
+ def check_host(v)
595
+ return v unless v
596
+
597
+ if @opaque
598
+ raise InvalidURIError,
599
+ "can not set host with registry or opaque"
600
+ elsif parser.regexp[:HOST] !~ v
601
+ raise InvalidComponentError,
602
+ "bad component(expected host component): #{v}"
603
+ end
604
+
605
+ return true
606
+ end
607
+ private :check_host
608
+
609
+ # Protected setter for the host component +v+.
610
+ #
611
+ # See also Bundler::URI::Generic.host=.
612
+ #
613
+ def set_host(v)
614
+ @host = v
615
+ end
616
+ protected :set_host
617
+
618
+ #
619
+ # == Args
620
+ #
621
+ # +v+::
622
+ # String
623
+ #
624
+ # == Description
625
+ #
626
+ # Public setter for the host component +v+
627
+ # (with validation).
628
+ #
629
+ # See also Bundler::URI::Generic.check_host.
630
+ #
631
+ # == Usage
632
+ #
633
+ # require 'bundler/vendor/uri/lib/uri'
634
+ #
635
+ # uri = Bundler::URI.parse("http://my.example.com")
636
+ # uri.host = "foo.com"
637
+ # uri.to_s #=> "http://foo.com"
638
+ #
639
+ def host=(v)
640
+ check_host(v)
641
+ set_host(v)
642
+ v
643
+ end
644
+
645
+ # Extract the host part of the Bundler::URI and unwrap brackets for IPv6 addresses.
646
+ #
647
+ # This method is the same as Bundler::URI::Generic#host except
648
+ # brackets for IPv6 (and future IP) addresses are removed.
649
+ #
650
+ # uri = Bundler::URI("http://[::1]/bar")
651
+ # uri.hostname #=> "::1"
652
+ # uri.host #=> "[::1]"
653
+ #
654
+ def hostname
655
+ v = self.host
656
+ v&.start_with?('[') && v.end_with?(']') ? v[1..-2] : v
657
+ end
658
+
659
+ # Sets the host part of the Bundler::URI as the argument with brackets for IPv6 addresses.
660
+ #
661
+ # This method is the same as Bundler::URI::Generic#host= except
662
+ # the argument can be a bare IPv6 address.
663
+ #
664
+ # uri = Bundler::URI("http://foo/bar")
665
+ # uri.hostname = "::1"
666
+ # uri.to_s #=> "http://[::1]/bar"
667
+ #
668
+ # If the argument seems to be an IPv6 address,
669
+ # it is wrapped with brackets.
670
+ #
671
+ def hostname=(v)
672
+ v = "[#{v}]" if !(v&.start_with?('[') && v&.end_with?(']')) && v&.index(':')
673
+ self.host = v
674
+ end
675
+
676
+ #
677
+ # Checks the port +v+ component for RFC2396 compliance
678
+ # and against the Bundler::URI::Parser Regexp for :PORT.
679
+ #
680
+ # Can not have a registry or opaque component defined,
681
+ # with a port component defined.
682
+ #
683
+ def check_port(v)
684
+ return v unless v
685
+
686
+ if @opaque
687
+ raise InvalidURIError,
688
+ "can not set port with registry or opaque"
689
+ elsif !v.kind_of?(Integer) && parser.regexp[:PORT] !~ v
690
+ raise InvalidComponentError,
691
+ "bad component(expected port component): #{v.inspect}"
692
+ end
693
+
694
+ return true
695
+ end
696
+ private :check_port
697
+
698
+ # Protected setter for the port component +v+.
699
+ #
700
+ # See also Bundler::URI::Generic.port=.
701
+ #
702
+ def set_port(v)
703
+ v = v.empty? ? nil : v.to_i unless !v || v.kind_of?(Integer)
704
+ @port = v
705
+ end
706
+ protected :set_port
707
+
708
+ #
709
+ # == Args
710
+ #
711
+ # +v+::
712
+ # String
713
+ #
714
+ # == Description
715
+ #
716
+ # Public setter for the port component +v+
717
+ # (with validation).
718
+ #
719
+ # See also Bundler::URI::Generic.check_port.
720
+ #
721
+ # == Usage
722
+ #
723
+ # require 'bundler/vendor/uri/lib/uri'
724
+ #
725
+ # uri = Bundler::URI.parse("http://my.example.com")
726
+ # uri.port = 8080
727
+ # uri.to_s #=> "http://my.example.com:8080"
728
+ #
729
+ def port=(v)
730
+ check_port(v)
731
+ set_port(v)
732
+ port
733
+ end
734
+
735
+ def check_registry(v) # :nodoc:
736
+ raise InvalidURIError, "can not set registry"
737
+ end
738
+ private :check_registry
739
+
740
+ def set_registry(v) #:nodoc:
741
+ raise InvalidURIError, "can not set registry"
742
+ end
743
+ protected :set_registry
744
+
745
+ def registry=(v)
746
+ raise InvalidURIError, "can not set registry"
747
+ end
748
+
749
+ #
750
+ # Checks the path +v+ component for RFC2396 compliance
751
+ # and against the Bundler::URI::Parser Regexp
752
+ # for :ABS_PATH and :REL_PATH.
753
+ #
754
+ # Can not have a opaque component defined,
755
+ # with a path component defined.
756
+ #
757
+ def check_path(v)
758
+ # raise if both hier and opaque are not nil, because:
759
+ # absoluteURI = scheme ":" ( hier_part | opaque_part )
760
+ # hier_part = ( net_path | abs_path ) [ "?" query ]
761
+ if v && @opaque
762
+ raise InvalidURIError,
763
+ "path conflicts with opaque"
764
+ end
765
+
766
+ # If scheme is ftp, path may be relative.
767
+ # See RFC 1738 section 3.2.2, and RFC 2396.
768
+ if @scheme && @scheme != "ftp"
769
+ if v && v != '' && parser.regexp[:ABS_PATH] !~ v
770
+ raise InvalidComponentError,
771
+ "bad component(expected absolute path component): #{v}"
772
+ end
773
+ else
774
+ if v && v != '' && parser.regexp[:ABS_PATH] !~ v &&
775
+ parser.regexp[:REL_PATH] !~ v
776
+ raise InvalidComponentError,
777
+ "bad component(expected relative path component): #{v}"
778
+ end
779
+ end
780
+
781
+ return true
782
+ end
783
+ private :check_path
784
+
785
+ # Protected setter for the path component +v+.
786
+ #
787
+ # See also Bundler::URI::Generic.path=.
788
+ #
789
+ def set_path(v)
790
+ @path = v
791
+ end
792
+ protected :set_path
793
+
794
+ #
795
+ # == Args
796
+ #
797
+ # +v+::
798
+ # String
799
+ #
800
+ # == Description
801
+ #
802
+ # Public setter for the path component +v+
803
+ # (with validation).
804
+ #
805
+ # See also Bundler::URI::Generic.check_path.
806
+ #
807
+ # == Usage
808
+ #
809
+ # require 'bundler/vendor/uri/lib/uri'
810
+ #
811
+ # uri = Bundler::URI.parse("http://my.example.com/pub/files")
812
+ # uri.path = "/faq/"
813
+ # uri.to_s #=> "http://my.example.com/faq/"
814
+ #
815
+ def path=(v)
816
+ check_path(v)
817
+ set_path(v)
818
+ v
819
+ end
820
+
821
+ #
822
+ # == Args
823
+ #
824
+ # +v+::
825
+ # String
826
+ #
827
+ # == Description
828
+ #
829
+ # Public setter for the query component +v+.
830
+ #
831
+ # == Usage
832
+ #
833
+ # require 'bundler/vendor/uri/lib/uri'
834
+ #
835
+ # uri = Bundler::URI.parse("http://my.example.com/?id=25")
836
+ # uri.query = "id=1"
837
+ # uri.to_s #=> "http://my.example.com/?id=1"
838
+ #
839
+ def query=(v)
840
+ return @query = nil unless v
841
+ raise InvalidURIError, "query conflicts with opaque" if @opaque
842
+
843
+ x = v.to_str
844
+ v = x.dup if x.equal? v
845
+ v.encode!(Encoding::UTF_8) rescue nil
846
+ v.delete!("\t\r\n")
847
+ v.force_encoding(Encoding::ASCII_8BIT)
848
+ raise InvalidURIError, "invalid percent escape: #{$1}" if /(%\H\H)/n.match(v)
849
+ v.gsub!(/(?!%\h\h|[!$-&(-;=?-_a-~])./n.freeze){'%%%02X' % $&.ord}
850
+ v.force_encoding(Encoding::US_ASCII)
851
+ @query = v
852
+ end
853
+
854
+ #
855
+ # Checks the opaque +v+ component for RFC2396 compliance and
856
+ # against the Bundler::URI::Parser Regexp for :OPAQUE.
857
+ #
858
+ # Can not have a host, port, user, or path component defined,
859
+ # with an opaque component defined.
860
+ #
861
+ def check_opaque(v)
862
+ return v unless v
863
+
864
+ # raise if both hier and opaque are not nil, because:
865
+ # absoluteURI = scheme ":" ( hier_part | opaque_part )
866
+ # hier_part = ( net_path | abs_path ) [ "?" query ]
867
+ if @host || @port || @user || @path # userinfo = @user + ':' + @password
868
+ raise InvalidURIError,
869
+ "can not set opaque with host, port, userinfo or path"
870
+ elsif v && parser.regexp[:OPAQUE] !~ v
871
+ raise InvalidComponentError,
872
+ "bad component(expected opaque component): #{v}"
873
+ end
874
+
875
+ return true
876
+ end
877
+ private :check_opaque
878
+
879
+ # Protected setter for the opaque component +v+.
880
+ #
881
+ # See also Bundler::URI::Generic.opaque=.
882
+ #
883
+ def set_opaque(v)
884
+ @opaque = v
885
+ end
886
+ protected :set_opaque
887
+
888
+ #
889
+ # == Args
890
+ #
891
+ # +v+::
892
+ # String
893
+ #
894
+ # == Description
895
+ #
896
+ # Public setter for the opaque component +v+
897
+ # (with validation).
898
+ #
899
+ # See also Bundler::URI::Generic.check_opaque.
900
+ #
901
+ def opaque=(v)
902
+ check_opaque(v)
903
+ set_opaque(v)
904
+ v
905
+ end
906
+
907
+ #
908
+ # Checks the fragment +v+ component against the Bundler::URI::Parser Regexp for :FRAGMENT.
909
+ #
910
+ #
911
+ # == Args
912
+ #
913
+ # +v+::
914
+ # String
915
+ #
916
+ # == Description
917
+ #
918
+ # Public setter for the fragment component +v+
919
+ # (with validation).
920
+ #
921
+ # == Usage
922
+ #
923
+ # require 'bundler/vendor/uri/lib/uri'
924
+ #
925
+ # uri = Bundler::URI.parse("http://my.example.com/?id=25#time=1305212049")
926
+ # uri.fragment = "time=1305212086"
927
+ # uri.to_s #=> "http://my.example.com/?id=25#time=1305212086"
928
+ #
929
+ def fragment=(v)
930
+ return @fragment = nil unless v
931
+
932
+ x = v.to_str
933
+ v = x.dup if x.equal? v
934
+ v.encode!(Encoding::UTF_8) rescue nil
935
+ v.delete!("\t\r\n")
936
+ v.force_encoding(Encoding::ASCII_8BIT)
937
+ v.gsub!(/(?!%\h\h|[!-~])./n){'%%%02X' % $&.ord}
938
+ v.force_encoding(Encoding::US_ASCII)
939
+ @fragment = v
940
+ end
941
+
942
+ #
943
+ # Returns true if Bundler::URI is hierarchical.
944
+ #
945
+ # == Description
946
+ #
947
+ # Bundler::URI has components listed in order of decreasing significance from left to right,
948
+ # see RFC3986 https://tools.ietf.org/html/rfc3986 1.2.3.
949
+ #
950
+ # == Usage
951
+ #
952
+ # require 'bundler/vendor/uri/lib/uri'
953
+ #
954
+ # uri = Bundler::URI.parse("http://my.example.com/")
955
+ # uri.hierarchical?
956
+ # #=> true
957
+ # uri = Bundler::URI.parse("mailto:joe@example.com")
958
+ # uri.hierarchical?
959
+ # #=> false
960
+ #
961
+ def hierarchical?
962
+ if @path
963
+ true
964
+ else
965
+ false
966
+ end
967
+ end
968
+
969
+ #
970
+ # Returns true if Bundler::URI has a scheme (e.g. http:// or https://) specified.
971
+ #
972
+ def absolute?
973
+ if @scheme
974
+ true
975
+ else
976
+ false
977
+ end
978
+ end
979
+ alias absolute absolute?
980
+
981
+ #
982
+ # Returns true if Bundler::URI does not have a scheme (e.g. http:// or https://) specified.
983
+ #
984
+ def relative?
985
+ !absolute?
986
+ end
987
+
988
+ #
989
+ # Returns an Array of the path split on '/'.
990
+ #
991
+ def split_path(path)
992
+ path.split("/", -1)
993
+ end
994
+ private :split_path
995
+
996
+ #
997
+ # Merges a base path +base+, with relative path +rel+,
998
+ # returns a modified base path.
999
+ #
1000
+ def merge_path(base, rel)
1001
+
1002
+ # RFC2396, Section 5.2, 5)
1003
+ # RFC2396, Section 5.2, 6)
1004
+ base_path = split_path(base)
1005
+ rel_path = split_path(rel)
1006
+
1007
+ # RFC2396, Section 5.2, 6), a)
1008
+ base_path << '' if base_path.last == '..'
1009
+ while i = base_path.index('..')
1010
+ base_path.slice!(i - 1, 2)
1011
+ end
1012
+
1013
+ if (first = rel_path.first) and first.empty?
1014
+ base_path.clear
1015
+ rel_path.shift
1016
+ end
1017
+
1018
+ # RFC2396, Section 5.2, 6), c)
1019
+ # RFC2396, Section 5.2, 6), d)
1020
+ rel_path.push('') if rel_path.last == '.' || rel_path.last == '..'
1021
+ rel_path.delete('.')
1022
+
1023
+ # RFC2396, Section 5.2, 6), e)
1024
+ tmp = []
1025
+ rel_path.each do |x|
1026
+ if x == '..' &&
1027
+ !(tmp.empty? || tmp.last == '..')
1028
+ tmp.pop
1029
+ else
1030
+ tmp << x
1031
+ end
1032
+ end
1033
+
1034
+ add_trailer_slash = !tmp.empty?
1035
+ if base_path.empty?
1036
+ base_path = [''] # keep '/' for root directory
1037
+ elsif add_trailer_slash
1038
+ base_path.pop
1039
+ end
1040
+ while x = tmp.shift
1041
+ if x == '..'
1042
+ # RFC2396, Section 4
1043
+ # a .. or . in an absolute path has no special meaning
1044
+ base_path.pop if base_path.size > 1
1045
+ else
1046
+ # if x == '..'
1047
+ # valid absolute (but abnormal) path "/../..."
1048
+ # else
1049
+ # valid absolute path
1050
+ # end
1051
+ base_path << x
1052
+ tmp.each {|t| base_path << t}
1053
+ add_trailer_slash = false
1054
+ break
1055
+ end
1056
+ end
1057
+ base_path.push('') if add_trailer_slash
1058
+
1059
+ return base_path.join('/')
1060
+ end
1061
+ private :merge_path
1062
+
1063
+ #
1064
+ # == Args
1065
+ #
1066
+ # +oth+::
1067
+ # Bundler::URI or String
1068
+ #
1069
+ # == Description
1070
+ #
1071
+ # Destructive form of #merge.
1072
+ #
1073
+ # == Usage
1074
+ #
1075
+ # require 'bundler/vendor/uri/lib/uri'
1076
+ #
1077
+ # uri = Bundler::URI.parse("http://my.example.com")
1078
+ # uri.merge!("/main.rbx?page=1")
1079
+ # uri.to_s # => "http://my.example.com/main.rbx?page=1"
1080
+ #
1081
+ def merge!(oth)
1082
+ t = merge(oth)
1083
+ if self == t
1084
+ nil
1085
+ else
1086
+ replace!(t)
1087
+ self
1088
+ end
1089
+ end
1090
+
1091
+ #
1092
+ # == Args
1093
+ #
1094
+ # +oth+::
1095
+ # Bundler::URI or String
1096
+ #
1097
+ # == Description
1098
+ #
1099
+ # Merges two URIs.
1100
+ #
1101
+ # == Usage
1102
+ #
1103
+ # require 'bundler/vendor/uri/lib/uri'
1104
+ #
1105
+ # uri = Bundler::URI.parse("http://my.example.com")
1106
+ # uri.merge("/main.rbx?page=1")
1107
+ # # => "http://my.example.com/main.rbx?page=1"
1108
+ #
1109
+ def merge(oth)
1110
+ rel = parser.__send__(:convert_to_uri, oth)
1111
+
1112
+ if rel.absolute?
1113
+ #raise BadURIError, "both Bundler::URI are absolute" if absolute?
1114
+ # hmm... should return oth for usability?
1115
+ return rel
1116
+ end
1117
+
1118
+ unless self.absolute?
1119
+ raise BadURIError, "both Bundler::URI are relative"
1120
+ end
1121
+
1122
+ base = self.dup
1123
+
1124
+ authority = rel.userinfo || rel.host || rel.port
1125
+
1126
+ # RFC2396, Section 5.2, 2)
1127
+ if (rel.path.nil? || rel.path.empty?) && !authority && !rel.query
1128
+ base.fragment=(rel.fragment) if rel.fragment
1129
+ return base
1130
+ end
1131
+
1132
+ base.query = nil
1133
+ base.fragment=(nil)
1134
+
1135
+ # RFC2396, Section 5.2, 4)
1136
+ if !authority
1137
+ base.set_path(merge_path(base.path, rel.path)) if base.path && rel.path
1138
+ else
1139
+ # RFC2396, Section 5.2, 4)
1140
+ base.set_path(rel.path) if rel.path
1141
+ end
1142
+
1143
+ # RFC2396, Section 5.2, 7)
1144
+ base.set_userinfo(rel.userinfo) if rel.userinfo
1145
+ base.set_host(rel.host) if rel.host
1146
+ base.set_port(rel.port) if rel.port
1147
+ base.query = rel.query if rel.query
1148
+ base.fragment=(rel.fragment) if rel.fragment
1149
+
1150
+ return base
1151
+ end # merge
1152
+ alias + merge
1153
+
1154
+ # :stopdoc:
1155
+ def route_from_path(src, dst)
1156
+ case dst
1157
+ when src
1158
+ # RFC2396, Section 4.2
1159
+ return ''
1160
+ when %r{(?:\A|/)\.\.?(?:/|\z)}
1161
+ # dst has abnormal absolute path,
1162
+ # like "/./", "/../", "/x/../", ...
1163
+ return dst.dup
1164
+ end
1165
+
1166
+ src_path = src.scan(%r{[^/]*/})
1167
+ dst_path = dst.scan(%r{[^/]*/?})
1168
+
1169
+ # discard same parts
1170
+ while !dst_path.empty? && dst_path.first == src_path.first
1171
+ src_path.shift
1172
+ dst_path.shift
1173
+ end
1174
+
1175
+ tmp = dst_path.join
1176
+
1177
+ # calculate
1178
+ if src_path.empty?
1179
+ if tmp.empty?
1180
+ return './'
1181
+ elsif dst_path.first.include?(':') # (see RFC2396 Section 5)
1182
+ return './' + tmp
1183
+ else
1184
+ return tmp
1185
+ end
1186
+ end
1187
+
1188
+ return '../' * src_path.size + tmp
1189
+ end
1190
+ private :route_from_path
1191
+ # :startdoc:
1192
+
1193
+ # :stopdoc:
1194
+ def route_from0(oth)
1195
+ oth = parser.__send__(:convert_to_uri, oth)
1196
+ if self.relative?
1197
+ raise BadURIError,
1198
+ "relative Bundler::URI: #{self}"
1199
+ end
1200
+ if oth.relative?
1201
+ raise BadURIError,
1202
+ "relative Bundler::URI: #{oth}"
1203
+ end
1204
+
1205
+ if self.scheme != oth.scheme
1206
+ return self, self.dup
1207
+ end
1208
+ rel = Bundler::URI::Generic.new(nil, # it is relative Bundler::URI
1209
+ self.userinfo, self.host, self.port,
1210
+ nil, self.path, self.opaque,
1211
+ self.query, self.fragment, parser)
1212
+
1213
+ if rel.userinfo != oth.userinfo ||
1214
+ rel.host.to_s.downcase != oth.host.to_s.downcase ||
1215
+ rel.port != oth.port
1216
+
1217
+ if self.userinfo.nil? && self.host.nil?
1218
+ return self, self.dup
1219
+ end
1220
+
1221
+ rel.set_port(nil) if rel.port == oth.default_port
1222
+ return rel, rel
1223
+ end
1224
+ rel.set_userinfo(nil)
1225
+ rel.set_host(nil)
1226
+ rel.set_port(nil)
1227
+
1228
+ if rel.path && rel.path == oth.path
1229
+ rel.set_path('')
1230
+ rel.query = nil if rel.query == oth.query
1231
+ return rel, rel
1232
+ elsif rel.opaque && rel.opaque == oth.opaque
1233
+ rel.set_opaque('')
1234
+ rel.query = nil if rel.query == oth.query
1235
+ return rel, rel
1236
+ end
1237
+
1238
+ # you can modify `rel', but can not `oth'.
1239
+ return oth, rel
1240
+ end
1241
+ private :route_from0
1242
+ # :startdoc:
1243
+
1244
+ #
1245
+ # == Args
1246
+ #
1247
+ # +oth+::
1248
+ # Bundler::URI or String
1249
+ #
1250
+ # == Description
1251
+ #
1252
+ # Calculates relative path from oth to self.
1253
+ #
1254
+ # == Usage
1255
+ #
1256
+ # require 'bundler/vendor/uri/lib/uri'
1257
+ #
1258
+ # uri = Bundler::URI.parse('http://my.example.com/main.rbx?page=1')
1259
+ # uri.route_from('http://my.example.com')
1260
+ # #=> #<Bundler::URI::Generic /main.rbx?page=1>
1261
+ #
1262
+ def route_from(oth)
1263
+ # you can modify `rel', but can not `oth'.
1264
+ begin
1265
+ oth, rel = route_from0(oth)
1266
+ rescue
1267
+ raise $!.class, $!.message
1268
+ end
1269
+ if oth == rel
1270
+ return rel
1271
+ end
1272
+
1273
+ rel.set_path(route_from_path(oth.path, self.path))
1274
+ if rel.path == './' && self.query
1275
+ # "./?foo" -> "?foo"
1276
+ rel.set_path('')
1277
+ end
1278
+
1279
+ return rel
1280
+ end
1281
+
1282
+ alias - route_from
1283
+
1284
+ #
1285
+ # == Args
1286
+ #
1287
+ # +oth+::
1288
+ # Bundler::URI or String
1289
+ #
1290
+ # == Description
1291
+ #
1292
+ # Calculates relative path to oth from self.
1293
+ #
1294
+ # == Usage
1295
+ #
1296
+ # require 'bundler/vendor/uri/lib/uri'
1297
+ #
1298
+ # uri = Bundler::URI.parse('http://my.example.com')
1299
+ # uri.route_to('http://my.example.com/main.rbx?page=1')
1300
+ # #=> #<Bundler::URI::Generic /main.rbx?page=1>
1301
+ #
1302
+ def route_to(oth)
1303
+ parser.__send__(:convert_to_uri, oth).route_from(self)
1304
+ end
1305
+
1306
+ #
1307
+ # Returns normalized Bundler::URI.
1308
+ #
1309
+ # require 'bundler/vendor/uri/lib/uri'
1310
+ #
1311
+ # Bundler::URI("HTTP://my.EXAMPLE.com").normalize
1312
+ # #=> #<Bundler::URI::HTTP http://my.example.com/>
1313
+ #
1314
+ # Normalization here means:
1315
+ #
1316
+ # * scheme and host are converted to lowercase,
1317
+ # * an empty path component is set to "/".
1318
+ #
1319
+ def normalize
1320
+ uri = dup
1321
+ uri.normalize!
1322
+ uri
1323
+ end
1324
+
1325
+ #
1326
+ # Destructive version of #normalize.
1327
+ #
1328
+ def normalize!
1329
+ if path&.empty?
1330
+ set_path('/')
1331
+ end
1332
+ if scheme && scheme != scheme.downcase
1333
+ set_scheme(self.scheme.downcase)
1334
+ end
1335
+ if host && host != host.downcase
1336
+ set_host(self.host.downcase)
1337
+ end
1338
+ end
1339
+
1340
+ #
1341
+ # Constructs String from Bundler::URI.
1342
+ #
1343
+ def to_s
1344
+ str = ''.dup
1345
+ if @scheme
1346
+ str << @scheme
1347
+ str << ':'
1348
+ end
1349
+
1350
+ if @opaque
1351
+ str << @opaque
1352
+ else
1353
+ if @host || %w[file postgres].include?(@scheme)
1354
+ str << '//'
1355
+ end
1356
+ if self.userinfo
1357
+ str << self.userinfo
1358
+ str << '@'
1359
+ end
1360
+ if @host
1361
+ str << @host
1362
+ end
1363
+ if @port && @port != self.default_port
1364
+ str << ':'
1365
+ str << @port.to_s
1366
+ end
1367
+ str << @path
1368
+ if @query
1369
+ str << '?'
1370
+ str << @query
1371
+ end
1372
+ end
1373
+ if @fragment
1374
+ str << '#'
1375
+ str << @fragment
1376
+ end
1377
+ str
1378
+ end
1379
+
1380
+ #
1381
+ # Compares two URIs.
1382
+ #
1383
+ def ==(oth)
1384
+ if self.class == oth.class
1385
+ self.normalize.component_ary == oth.normalize.component_ary
1386
+ else
1387
+ false
1388
+ end
1389
+ end
1390
+
1391
+ def hash
1392
+ self.component_ary.hash
1393
+ end
1394
+
1395
+ def eql?(oth)
1396
+ self.class == oth.class &&
1397
+ parser == oth.parser &&
1398
+ self.component_ary.eql?(oth.component_ary)
1399
+ end
1400
+
1401
+ =begin
1402
+
1403
+ --- Bundler::URI::Generic#===(oth)
1404
+
1405
+ =end
1406
+ # def ===(oth)
1407
+ # raise NotImplementedError
1408
+ # end
1409
+
1410
+ =begin
1411
+ =end
1412
+
1413
+
1414
+ # Returns an Array of the components defined from the COMPONENT Array.
1415
+ def component_ary
1416
+ component.collect do |x|
1417
+ self.__send__(x)
1418
+ end
1419
+ end
1420
+ protected :component_ary
1421
+
1422
+ # == Args
1423
+ #
1424
+ # +components+::
1425
+ # Multiple Symbol arguments defined in Bundler::URI::HTTP.
1426
+ #
1427
+ # == Description
1428
+ #
1429
+ # Selects specified components from Bundler::URI.
1430
+ #
1431
+ # == Usage
1432
+ #
1433
+ # require 'bundler/vendor/uri/lib/uri'
1434
+ #
1435
+ # uri = Bundler::URI.parse('http://myuser:mypass@my.example.com/test.rbx')
1436
+ # uri.select(:userinfo, :host, :path)
1437
+ # # => ["myuser:mypass", "my.example.com", "/test.rbx"]
1438
+ #
1439
+ def select(*components)
1440
+ components.collect do |c|
1441
+ if component.include?(c)
1442
+ self.__send__(c)
1443
+ else
1444
+ raise ArgumentError,
1445
+ "expected of components of #{self.class} (#{self.class.component.join(', ')})"
1446
+ end
1447
+ end
1448
+ end
1449
+
1450
+ def inspect
1451
+ "#<#{self.class} #{self}>"
1452
+ end
1453
+
1454
+ #
1455
+ # == Args
1456
+ #
1457
+ # +v+::
1458
+ # Bundler::URI or String
1459
+ #
1460
+ # == Description
1461
+ #
1462
+ # Attempts to parse other Bundler::URI +oth+,
1463
+ # returns [parsed_oth, self].
1464
+ #
1465
+ # == Usage
1466
+ #
1467
+ # require 'bundler/vendor/uri/lib/uri'
1468
+ #
1469
+ # uri = Bundler::URI.parse("http://my.example.com")
1470
+ # uri.coerce("http://foo.com")
1471
+ # #=> [#<Bundler::URI::HTTP http://foo.com>, #<Bundler::URI::HTTP http://my.example.com>]
1472
+ #
1473
+ def coerce(oth)
1474
+ case oth
1475
+ when String
1476
+ oth = parser.parse(oth)
1477
+ else
1478
+ super
1479
+ end
1480
+
1481
+ return oth, self
1482
+ end
1483
+
1484
+ # Returns a proxy Bundler::URI.
1485
+ # The proxy Bundler::URI is obtained from environment variables such as http_proxy,
1486
+ # ftp_proxy, no_proxy, etc.
1487
+ # If there is no proper proxy, nil is returned.
1488
+ #
1489
+ # If the optional parameter +env+ is specified, it is used instead of ENV.
1490
+ #
1491
+ # Note that capitalized variables (HTTP_PROXY, FTP_PROXY, NO_PROXY, etc.)
1492
+ # are examined, too.
1493
+ #
1494
+ # But http_proxy and HTTP_PROXY is treated specially under CGI environment.
1495
+ # It's because HTTP_PROXY may be set by Proxy: header.
1496
+ # So HTTP_PROXY is not used.
1497
+ # http_proxy is not used too if the variable is case insensitive.
1498
+ # CGI_HTTP_PROXY can be used instead.
1499
+ def find_proxy(env=ENV)
1500
+ raise BadURIError, "relative Bundler::URI: #{self}" if self.relative?
1501
+ name = self.scheme.downcase + '_proxy'
1502
+ proxy_uri = nil
1503
+ if name == 'http_proxy' && env.include?('REQUEST_METHOD') # CGI?
1504
+ # HTTP_PROXY conflicts with *_proxy for proxy settings and
1505
+ # HTTP_* for header information in CGI.
1506
+ # So it should be careful to use it.
1507
+ pairs = env.reject {|k, v| /\Ahttp_proxy\z/i !~ k }
1508
+ case pairs.length
1509
+ when 0 # no proxy setting anyway.
1510
+ proxy_uri = nil
1511
+ when 1
1512
+ k, _ = pairs.shift
1513
+ if k == 'http_proxy' && env[k.upcase] == nil
1514
+ # http_proxy is safe to use because ENV is case sensitive.
1515
+ proxy_uri = env[name]
1516
+ else
1517
+ proxy_uri = nil
1518
+ end
1519
+ else # http_proxy is safe to use because ENV is case sensitive.
1520
+ proxy_uri = env.to_hash[name]
1521
+ end
1522
+ if !proxy_uri
1523
+ # Use CGI_HTTP_PROXY. cf. libwww-perl.
1524
+ proxy_uri = env["CGI_#{name.upcase}"]
1525
+ end
1526
+ elsif name == 'http_proxy'
1527
+ if RUBY_ENGINE == 'jruby' && p_addr = ENV_JAVA['http.proxyHost']
1528
+ p_port = ENV_JAVA['http.proxyPort']
1529
+ if p_user = ENV_JAVA['http.proxyUser']
1530
+ p_pass = ENV_JAVA['http.proxyPass']
1531
+ proxy_uri = "http://#{p_user}:#{p_pass}@#{p_addr}:#{p_port}"
1532
+ else
1533
+ proxy_uri = "http://#{p_addr}:#{p_port}"
1534
+ end
1535
+ else
1536
+ unless proxy_uri = env[name]
1537
+ if proxy_uri = env[name.upcase]
1538
+ warn 'The environment variable HTTP_PROXY is discouraged. Use http_proxy.', uplevel: 1
1539
+ end
1540
+ end
1541
+ end
1542
+ else
1543
+ proxy_uri = env[name] || env[name.upcase]
1544
+ end
1545
+
1546
+ if proxy_uri.nil? || proxy_uri.empty?
1547
+ return nil
1548
+ end
1549
+
1550
+ if self.hostname
1551
+ begin
1552
+ addr = IPSocket.getaddress(self.hostname)
1553
+ return nil if /\A127\.|\A::1\z/ =~ addr
1554
+ rescue SocketError
1555
+ end
1556
+ end
1557
+
1558
+ name = 'no_proxy'
1559
+ if no_proxy = env[name] || env[name.upcase]
1560
+ return nil unless Bundler::URI::Generic.use_proxy?(self.hostname, addr, self.port, no_proxy)
1561
+ end
1562
+ Bundler::URI.parse(proxy_uri)
1563
+ end
1564
+
1565
+ def self.use_proxy?(hostname, addr, port, no_proxy) # :nodoc:
1566
+ hostname = hostname.downcase
1567
+ dothostname = ".#{hostname}"
1568
+ no_proxy.scan(/([^:,\s]+)(?::(\d+))?/) {|p_host, p_port|
1569
+ if !p_port || port == p_port.to_i
1570
+ if p_host.start_with?('.')
1571
+ return false if hostname.end_with?(p_host.downcase)
1572
+ else
1573
+ return false if dothostname.end_with?(".#{p_host.downcase}")
1574
+ end
1575
+ if addr
1576
+ begin
1577
+ return false if IPAddr.new(p_host).include?(addr)
1578
+ rescue IPAddr::InvalidAddressError
1579
+ next
1580
+ end
1581
+ end
1582
+ end
1583
+ }
1584
+ true
1585
+ end
1586
+ end
1587
+ end