rubygems-update 3.3.26 → 3.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (272) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +35 -0
  3. data/CONTRIBUTING.md +24 -1
  4. data/Manifest.txt +30 -27
  5. data/POLICIES.md +10 -8
  6. data/README.md +2 -2
  7. data/bin/gem +1 -4
  8. data/bin/update_rubygems +1 -1
  9. data/bundler/CHANGELOG.md +59 -0
  10. data/bundler/README.md +2 -2
  11. data/bundler/bundler.gemspec +2 -2
  12. data/bundler/exe/bundle +1 -4
  13. data/bundler/lib/bundler/build_metadata.rb +2 -2
  14. data/bundler/lib/bundler/cli/add.rb +1 -1
  15. data/bundler/lib/bundler/cli/check.rb +1 -1
  16. data/bundler/lib/bundler/cli/common.rb +1 -0
  17. data/bundler/lib/bundler/cli/console.rb +2 -2
  18. data/bundler/lib/bundler/cli/doctor.rb +4 -6
  19. data/bundler/lib/bundler/cli/gem.rb +62 -40
  20. data/bundler/lib/bundler/cli/install.rb +2 -3
  21. data/bundler/lib/bundler/cli/lock.rb +8 -5
  22. data/bundler/lib/bundler/cli/outdated.rb +1 -3
  23. data/bundler/lib/bundler/cli/viz.rb +1 -1
  24. data/bundler/lib/bundler/cli.rb +43 -2
  25. data/bundler/lib/bundler/compact_index_client/cache.rb +1 -1
  26. data/bundler/lib/bundler/compact_index_client/updater.rb +40 -39
  27. data/bundler/lib/bundler/constants.rb +1 -1
  28. data/bundler/lib/bundler/definition.rb +61 -31
  29. data/bundler/lib/bundler/dependency.rb +12 -11
  30. data/bundler/lib/bundler/digest.rb +1 -1
  31. data/bundler/lib/bundler/dsl.rb +1 -1
  32. data/bundler/lib/bundler/env.rb +1 -1
  33. data/bundler/lib/bundler/environment_preserver.rb +1 -0
  34. data/bundler/lib/bundler/errors.rb +1 -11
  35. data/bundler/lib/bundler/fetcher/compact_index.rb +9 -11
  36. data/bundler/lib/bundler/fetcher/dependency.rb +1 -1
  37. data/bundler/lib/bundler/fetcher/downloader.rb +2 -5
  38. data/bundler/lib/bundler/fetcher.rb +2 -6
  39. data/bundler/lib/bundler/force_platform.rb +18 -0
  40. data/bundler/lib/bundler/friendly_errors.rb +0 -3
  41. data/bundler/lib/bundler/gem_version_promoter.rb +52 -86
  42. data/bundler/lib/bundler/graph.rb +3 -3
  43. data/bundler/lib/bundler/index.rb +5 -13
  44. data/bundler/lib/bundler/injector.rb +1 -1
  45. data/bundler/lib/bundler/inline.rb +2 -2
  46. data/bundler/lib/bundler/installer/parallel_installer.rb +0 -31
  47. data/bundler/lib/bundler/installer.rb +6 -16
  48. data/bundler/lib/bundler/lazy_specification.rb +5 -1
  49. data/bundler/lib/bundler/lockfile_parser.rb +5 -5
  50. data/bundler/lib/bundler/man/bundle-add.1 +1 -1
  51. data/bundler/lib/bundler/man/bundle-binstubs.1 +1 -1
  52. data/bundler/lib/bundler/man/bundle-cache.1 +1 -1
  53. data/bundler/lib/bundler/man/bundle-check.1 +1 -1
  54. data/bundler/lib/bundler/man/bundle-clean.1 +1 -1
  55. data/bundler/lib/bundler/man/bundle-config.1 +1 -1
  56. data/bundler/lib/bundler/man/bundle-console.1 +1 -1
  57. data/bundler/lib/bundler/man/bundle-doctor.1 +1 -1
  58. data/bundler/lib/bundler/man/bundle-exec.1 +1 -1
  59. data/bundler/lib/bundler/man/bundle-gem.1 +27 -37
  60. data/bundler/lib/bundler/man/bundle-gem.1.ronn +5 -5
  61. data/bundler/lib/bundler/man/bundle-help.1 +1 -1
  62. data/bundler/lib/bundler/man/bundle-info.1 +1 -1
  63. data/bundler/lib/bundler/man/bundle-init.1 +1 -1
  64. data/bundler/lib/bundler/man/bundle-inject.1 +1 -1
  65. data/bundler/lib/bundler/man/bundle-install.1 +1 -30
  66. data/bundler/lib/bundler/man/bundle-install.1.ronn +0 -29
  67. data/bundler/lib/bundler/man/bundle-list.1 +1 -1
  68. data/bundler/lib/bundler/man/bundle-lock.1 +1 -1
  69. data/bundler/lib/bundler/man/bundle-open.1 +1 -1
  70. data/bundler/lib/bundler/man/bundle-outdated.1 +1 -1
  71. data/bundler/lib/bundler/man/bundle-platform.1 +2 -2
  72. data/bundler/lib/bundler/man/bundle-platform.1.ronn +1 -1
  73. data/bundler/lib/bundler/man/bundle-plugin.1 +1 -1
  74. data/bundler/lib/bundler/man/bundle-pristine.1 +1 -1
  75. data/bundler/lib/bundler/man/bundle-remove.1 +1 -1
  76. data/bundler/lib/bundler/man/bundle-show.1 +1 -1
  77. data/bundler/lib/bundler/man/bundle-update.1 +1 -1
  78. data/bundler/lib/bundler/man/bundle-version.1 +1 -1
  79. data/bundler/lib/bundler/man/bundle-viz.1 +1 -1
  80. data/bundler/lib/bundler/man/bundle.1 +1 -1
  81. data/bundler/lib/bundler/man/gemfile.5 +1 -1
  82. data/bundler/lib/bundler/mirror.rb +5 -7
  83. data/bundler/lib/bundler/plugin/index.rb +4 -4
  84. data/bundler/lib/bundler/plugin/installer/rubygems.rb +0 -4
  85. data/bundler/lib/bundler/resolver/base.rb +7 -11
  86. data/bundler/lib/bundler/resolver/candidate.rb +92 -0
  87. data/bundler/lib/bundler/resolver/incompatibility.rb +15 -0
  88. data/bundler/lib/bundler/resolver/package.rb +63 -0
  89. data/bundler/lib/bundler/resolver/root.rb +25 -0
  90. data/bundler/lib/bundler/resolver/spec_group.rb +26 -36
  91. data/bundler/lib/bundler/resolver.rb +294 -277
  92. data/bundler/lib/bundler/rubygems_ext.rb +11 -6
  93. data/bundler/lib/bundler/rubygems_gem_installer.rb +4 -2
  94. data/bundler/lib/bundler/rubygems_integration.rb +1 -9
  95. data/bundler/lib/bundler/runtime.rb +1 -5
  96. data/bundler/lib/bundler/settings.rb +0 -6
  97. data/bundler/lib/bundler/shared_helpers.rb +1 -0
  98. data/bundler/lib/bundler/source/git/git_proxy.rb +193 -67
  99. data/bundler/lib/bundler/source/git.rb +15 -17
  100. data/bundler/lib/bundler/source/metadata.rb +0 -1
  101. data/bundler/lib/bundler/source/path/installer.rb +1 -22
  102. data/bundler/lib/bundler/source/path.rb +5 -5
  103. data/bundler/lib/bundler/source/rubygems.rb +13 -67
  104. data/bundler/lib/bundler/source_list.rb +8 -2
  105. data/bundler/lib/bundler/spec_set.rb +7 -9
  106. data/bundler/lib/bundler/templates/Executable +1 -1
  107. data/bundler/lib/bundler/templates/Executable.bundler +4 -9
  108. data/bundler/lib/bundler/templates/Executable.standalone +2 -0
  109. data/bundler/lib/bundler/templates/newgem/Cargo.toml.tt +7 -0
  110. data/bundler/lib/bundler/templates/newgem/Gemfile.tt +3 -0
  111. data/bundler/lib/bundler/templates/newgem/README.md.tt +6 -4
  112. data/bundler/lib/bundler/templates/newgem/Rakefile.tt +2 -1
  113. data/bundler/lib/bundler/templates/newgem/circleci/config.yml.tt +12 -0
  114. data/bundler/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +15 -0
  115. data/bundler/lib/bundler/templates/newgem/ext/newgem/{extconf.rb.tt → extconf-c.rb.tt} +0 -0
  116. data/bundler/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
  117. data/bundler/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +12 -0
  118. data/bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt +10 -0
  119. data/bundler/lib/bundler/templates/newgem/gitignore.tt +3 -0
  120. data/bundler/lib/bundler/templates/newgem/gitlab-ci.yml.tt +8 -0
  121. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +8 -2
  122. data/bundler/lib/bundler/ui/shell.rb +35 -12
  123. data/bundler/lib/bundler/ui/silent.rb +21 -5
  124. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +3 -3
  125. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +0 -1
  126. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +3 -1
  127. data/bundler/lib/bundler/vendor/fileutils/lib/fileutils.rb +1350 -408
  128. data/bundler/lib/bundler/vendor/net-http-persistent/README.rdoc +1 -1
  129. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1 -1
  130. data/bundler/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
  131. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
  132. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +189 -0
  133. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
  134. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +151 -0
  135. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
  136. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
  137. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
  138. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
  139. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +53 -0
  140. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
  141. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
  142. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +124 -0
  143. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +409 -0
  144. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +240 -0
  145. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
  146. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
  147. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +1 -1
  148. data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +64 -16
  149. data/bundler/lib/bundler/vendor/uri/lib/uri/file.rb +7 -1
  150. data/bundler/lib/bundler/vendor/uri/lib/uri/ftp.rb +2 -1
  151. data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +27 -7
  152. data/bundler/lib/bundler/vendor/uri/lib/uri/http.rb +40 -2
  153. data/bundler/lib/bundler/vendor/uri/lib/uri/https.rb +2 -1
  154. data/bundler/lib/bundler/vendor/uri/lib/uri/ldap.rb +1 -1
  155. data/bundler/lib/bundler/vendor/uri/lib/uri/ldaps.rb +2 -1
  156. data/bundler/lib/bundler/vendor/uri/lib/uri/mailto.rb +2 -2
  157. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +13 -7
  158. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +10 -5
  159. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  160. data/bundler/lib/bundler/vendor/uri/lib/uri/ws.rb +1 -2
  161. data/bundler/lib/bundler/vendor/uri/lib/uri/wss.rb +2 -1
  162. data/bundler/lib/bundler/vendor/uri/lib/uri.rb +3 -2
  163. data/bundler/lib/bundler/vendored_persistent.rb +1 -33
  164. data/bundler/lib/bundler/{vendored_tmpdir.rb → vendored_pub_grub.rb} +1 -1
  165. data/bundler/lib/bundler/version.rb +5 -1
  166. data/bundler/lib/bundler/worker.rb +5 -7
  167. data/bundler/lib/bundler.rb +20 -64
  168. data/lib/rubygems/command_manager.rb +2 -2
  169. data/lib/rubygems/commands/fetch_command.rb +1 -1
  170. data/lib/rubygems/commands/install_command.rb +7 -3
  171. data/lib/rubygems/commands/rdoc_command.rb +3 -2
  172. data/lib/rubygems/commands/setup_command.rb +2 -2
  173. data/lib/rubygems/commands/unpack_command.rb +1 -1
  174. data/lib/rubygems/commands/update_command.rb +1 -7
  175. data/lib/rubygems/config_file.rb +33 -0
  176. data/lib/rubygems/core_ext/kernel_warn.rb +1 -2
  177. data/lib/rubygems/defaults.rb +15 -1
  178. data/lib/rubygems/dependency.rb +4 -1
  179. data/lib/rubygems/dependency_installer.rb +24 -24
  180. data/lib/rubygems/exceptions.rb +1 -3
  181. data/lib/rubygems/ext/builder.rb +3 -3
  182. data/lib/rubygems/ext/cargo_builder/link_flag_converter.rb +9 -5
  183. data/lib/rubygems/ext/cargo_builder.rb +15 -20
  184. data/lib/rubygems/ext/ext_conf_builder.rb +2 -0
  185. data/lib/rubygems/indexer.rb +1 -1
  186. data/lib/rubygems/installer.rb +5 -5
  187. data/lib/rubygems/optparse/lib/optparse.rb +20 -15
  188. data/lib/rubygems/package/tar_header.rb +11 -11
  189. data/lib/rubygems/platform.rb +0 -2
  190. data/lib/rubygems/request_set/gem_dependency_api.rb +104 -104
  191. data/lib/rubygems/requirement.rb +7 -7
  192. data/lib/rubygems/resolver/installer_set.rb +1 -1
  193. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb +1 -1
  194. data/lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb +32 -26
  195. data/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb +1 -1
  196. data/lib/rubygems/security/policies.rb +40 -40
  197. data/lib/rubygems/security/trust_dir.rb +1 -1
  198. data/lib/rubygems/security.rb +3 -16
  199. data/lib/rubygems/source.rb +2 -2
  200. data/lib/rubygems/specification.rb +37 -49
  201. data/lib/rubygems/specification_policy.rb +14 -0
  202. data/lib/rubygems/stub_specification.rb +2 -2
  203. data/lib/rubygems/text.rb +1 -1
  204. data/lib/rubygems/tsort/lib/tsort.rb +308 -310
  205. data/lib/rubygems/update_suggestion.rb +69 -0
  206. data/lib/rubygems/util.rb +1 -5
  207. data/lib/rubygems/validator.rb +1 -1
  208. data/lib/rubygems.rb +8 -3
  209. data/rubygems-update.gemspec +2 -2
  210. data/test/rubygems/helper.rb +7 -3
  211. data/test/rubygems/test_bundled_ca.rb +1 -1
  212. data/test/rubygems/test_exit.rb +6 -0
  213. data/test/rubygems/test_gem.rb +4 -9
  214. data/test/rubygems/test_gem_bundler_version_finder.rb +2 -1
  215. data/test/rubygems/test_gem_command_manager.rb +1 -1
  216. data/test/rubygems/test_gem_commands_install_command.rb +19 -0
  217. data/test/rubygems/test_gem_commands_setup_command.rb +1 -8
  218. data/test/rubygems/test_gem_commands_update_command.rb +6 -6
  219. data/test/rubygems/test_gem_config_file.rb +1 -1
  220. data/test/rubygems/test_gem_dependency.rb +2 -0
  221. data/test/rubygems/test_gem_ext_builder.rb +3 -3
  222. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.lock +22 -32
  223. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.toml +1 -1
  224. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock +22 -32
  225. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml +1 -1
  226. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/src/lib.rs +12 -0
  227. data/test/rubygems/test_gem_ext_cargo_builder.rb +22 -27
  228. data/test/rubygems/test_gem_ext_cargo_builder_link_flag_converter.rb +16 -16
  229. data/test/rubygems/test_gem_ext_cargo_builder_unit.rb +0 -10
  230. data/test/rubygems/test_gem_indexer.rb +39 -20
  231. data/test/rubygems/test_gem_installer.rb +68 -2
  232. data/test/rubygems/test_gem_package_tar_header.rb +13 -13
  233. data/test/rubygems/test_gem_platform.rb +59 -60
  234. data/test/rubygems/test_gem_remote_fetcher.rb +4 -4
  235. data/test/rubygems/test_gem_request_set.rb +2 -2
  236. data/test/rubygems/test_gem_requirement.rb +1 -1
  237. data/test/rubygems/test_gem_resolver_api_set.rb +12 -12
  238. data/test/rubygems/test_gem_resolver_api_specification.rb +19 -19
  239. data/test/rubygems/test_gem_resolver_git_specification.rb +1 -1
  240. data/test/rubygems/test_gem_security_policy.rb +10 -10
  241. data/test/rubygems/test_gem_security_trust_dir.rb +2 -2
  242. data/test/rubygems/test_gem_specification.rb +50 -37
  243. data/test/rubygems/test_gem_uninstaller.rb +1 -1
  244. data/test/rubygems/test_gem_update_suggestion.rb +208 -0
  245. data/test/rubygems/test_kernel.rb +10 -8
  246. data/test/rubygems/test_require.rb +70 -55
  247. metadata +34 -31
  248. data/bundler/lib/bundler/templates/newgem/travis.yml.tt +0 -6
  249. data/bundler/lib/bundler/vendor/molinillo/LICENSE +0 -9
  250. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
  251. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +0 -88
  252. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +0 -36
  253. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +0 -66
  254. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +0 -62
  255. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +0 -63
  256. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +0 -61
  257. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +0 -126
  258. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +0 -46
  259. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +0 -36
  260. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +0 -164
  261. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -255
  262. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +0 -149
  263. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +0 -6
  264. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +0 -112
  265. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +0 -67
  266. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +0 -839
  267. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +0 -46
  268. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +0 -58
  269. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -11
  270. data/bundler/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +0 -154
  271. data/bundler/lib/bundler/vendored_molinillo.rb +0 -4
  272. data/bundler/lib/bundler/version_ranges.rb +0 -122
@@ -0,0 +1,178 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler::PubGrub
4
+ class VersionUnion
5
+ attr_reader :ranges
6
+
7
+ def self.normalize_ranges(ranges)
8
+ ranges = ranges.flat_map do |range|
9
+ range.ranges
10
+ end
11
+
12
+ ranges.reject!(&:empty?)
13
+
14
+ return [] if ranges.empty?
15
+
16
+ mins, ranges = ranges.partition { |r| !r.min }
17
+ original_ranges = mins + ranges.sort_by { |r| [r.min, r.include_min ? 0 : 1] }
18
+ ranges = [original_ranges.shift]
19
+ original_ranges.each do |range|
20
+ if ranges.last.contiguous_to?(range)
21
+ ranges << ranges.pop.span(range)
22
+ else
23
+ ranges << range
24
+ end
25
+ end
26
+
27
+ ranges
28
+ end
29
+
30
+ def self.union(ranges, normalize: true)
31
+ ranges = normalize_ranges(ranges) if normalize
32
+
33
+ if ranges.size == 0
34
+ VersionRange.empty
35
+ elsif ranges.size == 1
36
+ ranges[0]
37
+ else
38
+ new(ranges)
39
+ end
40
+ end
41
+
42
+ def initialize(ranges)
43
+ raise ArgumentError unless ranges.all? { |r| r.instance_of?(VersionRange) }
44
+ @ranges = ranges
45
+ end
46
+
47
+ def hash
48
+ ranges.hash
49
+ end
50
+
51
+ def eql?(other)
52
+ ranges.eql?(other.ranges)
53
+ end
54
+
55
+ def include?(version)
56
+ !!ranges.bsearch {|r| r.compare_version(version) }
57
+ end
58
+
59
+ def select_versions(all_versions)
60
+ versions = []
61
+ ranges.inject(all_versions) do |acc, range|
62
+ _, matching, higher = range.partition_versions(acc)
63
+ versions.concat matching
64
+ higher
65
+ end
66
+ versions
67
+ end
68
+
69
+ def intersects?(other)
70
+ my_ranges = ranges.dup
71
+ other_ranges = other.ranges.dup
72
+
73
+ my_range = my_ranges.shift
74
+ other_range = other_ranges.shift
75
+ while my_range && other_range
76
+ if my_range.intersects?(other_range)
77
+ return true
78
+ end
79
+
80
+ if !my_range.max || other_range.empty? || (other_range.max && other_range.max < my_range.max)
81
+ other_range = other_ranges.shift
82
+ else
83
+ my_range = my_ranges.shift
84
+ end
85
+ end
86
+ end
87
+ alias_method :allows_any?, :intersects?
88
+
89
+ def allows_all?(other)
90
+ my_ranges = ranges.dup
91
+
92
+ my_range = my_ranges.shift
93
+
94
+ other.ranges.all? do |other_range|
95
+ while my_range
96
+ break if my_range.allows_all?(other_range)
97
+ my_range = my_ranges.shift
98
+ end
99
+
100
+ !!my_range
101
+ end
102
+ end
103
+
104
+ def empty?
105
+ false
106
+ end
107
+
108
+ def any?
109
+ false
110
+ end
111
+
112
+ def intersect(other)
113
+ my_ranges = ranges.dup
114
+ other_ranges = other.ranges.dup
115
+ new_ranges = []
116
+
117
+ my_range = my_ranges.shift
118
+ other_range = other_ranges.shift
119
+ while my_range && other_range
120
+ new_ranges << my_range.intersect(other_range)
121
+
122
+ if !my_range.max || other_range.empty? || (other_range.max && other_range.max < my_range.max)
123
+ other_range = other_ranges.shift
124
+ else
125
+ my_range = my_ranges.shift
126
+ end
127
+ end
128
+ new_ranges.reject!(&:empty?)
129
+ VersionUnion.union(new_ranges, normalize: false)
130
+ end
131
+
132
+ def upper_invert
133
+ ranges.last.upper_invert
134
+ end
135
+
136
+ def invert
137
+ ranges.map(&:invert).inject(:intersect)
138
+ end
139
+
140
+ def union(other)
141
+ VersionUnion.union([self, other])
142
+ end
143
+
144
+ def to_s
145
+ output = []
146
+
147
+ ranges = self.ranges.dup
148
+ while !ranges.empty?
149
+ ne = []
150
+ range = ranges.shift
151
+ while !ranges.empty? && ranges[0].min == range.max
152
+ ne << range.max
153
+ range = range.span(ranges.shift)
154
+ end
155
+
156
+ ne.map! {|x| "!= #{x}" }
157
+ if ne.empty?
158
+ output << range.to_s
159
+ elsif range.any?
160
+ output << ne.join(', ')
161
+ else
162
+ output << "#{range}, #{ne.join(', ')}"
163
+ end
164
+ end
165
+
166
+ output.join(" OR ")
167
+ end
168
+
169
+ def inspect
170
+ "#<#{self.class} #{to_s}>"
171
+ end
172
+
173
+ def ==(other)
174
+ self.class == other.class &&
175
+ self.ranges == other.ranges
176
+ end
177
+ end
178
+ end
@@ -0,0 +1,31 @@
1
+ require_relative "pub_grub/package"
2
+ require_relative "pub_grub/static_package_source"
3
+ require_relative "pub_grub/term"
4
+ require_relative "pub_grub/version_range"
5
+ require_relative "pub_grub/version_constraint"
6
+ require_relative "pub_grub/version_union"
7
+ require_relative "pub_grub/version_solver"
8
+ require_relative "pub_grub/incompatibility"
9
+ require_relative 'pub_grub/solve_failure'
10
+ require_relative 'pub_grub/failure_writer'
11
+ require_relative 'pub_grub/version'
12
+
13
+ module Bundler::PubGrub
14
+ class << self
15
+ attr_writer :logger
16
+
17
+ def logger
18
+ @logger || default_logger
19
+ end
20
+
21
+ private
22
+
23
+ def default_logger
24
+ require "logger"
25
+
26
+ logger = ::Logger.new(STDERR)
27
+ logger.level = $DEBUG ? ::Logger::DEBUG : ::Logger::WARN
28
+ @logger = logger
29
+ end
30
+ end
31
+ end
@@ -425,7 +425,7 @@ class Bundler::Thor
425
425
  end
426
426
 
427
427
  def unix?
428
- RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
428
+ RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris)/i
429
429
  end
430
430
 
431
431
  def truncate(string, width)
@@ -13,9 +13,12 @@ require_relative "rfc2396_parser"
13
13
  require_relative "rfc3986_parser"
14
14
 
15
15
  module Bundler::URI
16
+ include RFC2396_REGEXP
17
+
16
18
  REGEXP = RFC2396_REGEXP
17
19
  Parser = RFC2396_Parser
18
20
  RFC3986_PARSER = RFC3986_Parser.new
21
+ Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor)
19
22
 
20
23
  # Bundler::URI::Parser.new
21
24
  DEFAULT_PARSER = Parser.new
@@ -27,6 +30,7 @@ module Bundler::URI
27
30
  DEFAULT_PARSER.regexp.each_pair do |sym, str|
28
31
  const_set(sym, str)
29
32
  end
33
+ Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor)
30
34
 
31
35
  module Util # :nodoc:
32
36
  def make_components_hash(klass, array_hash)
@@ -60,24 +64,42 @@ module Bundler::URI
60
64
  module_function :make_components_hash
61
65
  end
62
66
 
63
- include REGEXP
67
+ module Schemes
68
+ end
69
+ private_constant :Schemes
70
+
71
+ #
72
+ # Register the given +klass+ to be instantiated when parsing URLs with the given +scheme+.
73
+ # Note that currently only schemes which after .upcase are valid constant names
74
+ # can be registered (no -/+/. allowed).
75
+ #
76
+ def self.register_scheme(scheme, klass)
77
+ Schemes.const_set(scheme.to_s.upcase, klass)
78
+ end
64
79
 
65
- @@schemes = {}
66
80
  # Returns a Hash of the defined schemes.
67
81
  def self.scheme_list
68
- @@schemes
82
+ Schemes.constants.map { |name|
83
+ [name.to_s.upcase, Schemes.const_get(name)]
84
+ }.to_h
69
85
  end
70
86
 
87
+ INITIAL_SCHEMES = scheme_list
88
+ private_constant :INITIAL_SCHEMES
89
+ Ractor.make_shareable(INITIAL_SCHEMES) if defined?(Ractor)
90
+
71
91
  #
72
92
  # Construct a Bundler::URI instance, using the scheme to detect the appropriate class
73
93
  # from +Bundler::URI.scheme_list+.
74
94
  #
75
95
  def self.for(scheme, *arguments, default: Generic)
76
- if scheme
77
- uri_class = @@schemes[scheme.upcase] || default
78
- else
79
- uri_class = default
96
+ const_name = scheme.to_s.upcase
97
+
98
+ uri_class = INITIAL_SCHEMES[const_name]
99
+ uri_class ||= if /\A[A-Z]\w*\z/.match?(const_name) && Schemes.const_defined?(const_name, false)
100
+ Schemes.const_get(const_name, false)
80
101
  end
102
+ uri_class ||= default
81
103
 
82
104
  return uri_class.new(scheme, *arguments)
83
105
  end
@@ -278,6 +300,7 @@ module Bundler::URI
278
300
  256.times do |i|
279
301
  TBLENCWWWCOMP_[-i.chr] = -('%%%02X' % i)
280
302
  end
303
+ TBLENCURICOMP_ = TBLENCWWWCOMP_.dup.freeze
281
304
  TBLENCWWWCOMP_[' '] = '+'
282
305
  TBLENCWWWCOMP_.freeze
283
306
  TBLDECWWWCOMP_ = {} # :nodoc:
@@ -303,6 +326,33 @@ module Bundler::URI
303
326
  #
304
327
  # See Bundler::URI.decode_www_form_component, Bundler::URI.encode_www_form.
305
328
  def self.encode_www_form_component(str, enc=nil)
329
+ _encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCWWWCOMP_, str, enc)
330
+ end
331
+
332
+ # Decodes given +str+ of URL-encoded form data.
333
+ #
334
+ # This decodes + to SP.
335
+ #
336
+ # See Bundler::URI.encode_www_form_component, Bundler::URI.decode_www_form.
337
+ def self.decode_www_form_component(str, enc=Encoding::UTF_8)
338
+ _decode_uri_component(/\+|%\h\h/, str, enc)
339
+ end
340
+
341
+ # Encodes +str+ using URL encoding
342
+ #
343
+ # This encodes SP to %20 instead of +.
344
+ def self.encode_uri_component(str, enc=nil)
345
+ _encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCURICOMP_, str, enc)
346
+ end
347
+
348
+ # Decodes given +str+ of URL-encoded data.
349
+ #
350
+ # This does not decode + to SP.
351
+ def self.decode_uri_component(str, enc=Encoding::UTF_8)
352
+ _decode_uri_component(/%\h\h/, str, enc)
353
+ end
354
+
355
+ def self._encode_uri_component(regexp, table, str, enc)
306
356
  str = str.to_s.dup
307
357
  if str.encoding != Encoding::ASCII_8BIT
308
358
  if enc && enc != Encoding::ASCII_8BIT
@@ -311,19 +361,16 @@ module Bundler::URI
311
361
  end
312
362
  str.force_encoding(Encoding::ASCII_8BIT)
313
363
  end
314
- str.gsub!(/[^*\-.0-9A-Z_a-z]/, TBLENCWWWCOMP_)
364
+ str.gsub!(regexp, table)
315
365
  str.force_encoding(Encoding::US_ASCII)
316
366
  end
367
+ private_class_method :_encode_uri_component
317
368
 
318
- # Decodes given +str+ of URL-encoded form data.
319
- #
320
- # This decodes + to SP.
321
- #
322
- # See Bundler::URI.encode_www_form_component, Bundler::URI.decode_www_form.
323
- def self.decode_www_form_component(str, enc=Encoding::UTF_8)
324
- raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/ =~ str
325
- str.b.gsub(/\+|%\h\h/, TBLDECWWWCOMP_).force_encoding(enc)
369
+ def self._decode_uri_component(regexp, str, enc)
370
+ raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/.match?(str)
371
+ str.b.gsub(regexp, TBLDECWWWCOMP_).force_encoding(enc)
326
372
  end
373
+ private_class_method :_decode_uri_component
327
374
 
328
375
  # Generates URL-encoded form data from given +enum+.
329
376
  #
@@ -653,6 +700,7 @@ module Bundler::URI
653
700
  "utf-16"=>"utf-16le",
654
701
  "utf-16le"=>"utf-16le",
655
702
  } # :nodoc:
703
+ Ractor.make_shareable(WEB_ENCODINGS_) if defined?(Ractor)
656
704
 
657
705
  # :nodoc:
658
706
  # return encoding or nil
@@ -33,6 +33,9 @@ module Bundler::URI
33
33
  # If an Array is used, the components must be passed in the
34
34
  # order <code>[host, path]</code>.
35
35
  #
36
+ # A path from e.g. the File class should be escaped before
37
+ # being passed.
38
+ #
36
39
  # Examples:
37
40
  #
38
41
  # require 'bundler/vendor/uri/lib/uri'
@@ -44,6 +47,9 @@ module Bundler::URI
44
47
  # :path => '/ruby/src'})
45
48
  # uri2.to_s # => "file://host.example.com/ruby/src"
46
49
  #
50
+ # uri3 = Bundler::URI::File.build({:path => Bundler::URI::escape('/path/my file.txt')})
51
+ # uri3.to_s # => "file:///path/my%20file.txt"
52
+ #
47
53
  def self.build(args)
48
54
  tmp = Util::make_components_hash(self, args)
49
55
  super(tmp)
@@ -90,5 +96,5 @@ module Bundler::URI
90
96
  end
91
97
  end
92
98
 
93
- @@schemes['FILE'] = File
99
+ register_scheme 'FILE', File
94
100
  end
@@ -262,5 +262,6 @@ module Bundler::URI
262
262
  return str
263
263
  end
264
264
  end
265
- @@schemes['FTP'] = FTP
265
+
266
+ register_scheme 'FTP', FTP
266
267
  end
@@ -564,16 +564,26 @@ module Bundler::URI
564
564
  end
565
565
  end
566
566
 
567
- # Returns the user component.
567
+ # Returns the user component (without Bundler::URI decoding).
568
568
  def user
569
569
  @user
570
570
  end
571
571
 
572
- # Returns the password component.
572
+ # Returns the password component (without Bundler::URI decoding).
573
573
  def password
574
574
  @password
575
575
  end
576
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
+
577
587
  #
578
588
  # Checks the host +v+ component for RFC2396 compliance
579
589
  # and against the Bundler::URI::Parser Regexp for :HOST.
@@ -643,7 +653,7 @@ module Bundler::URI
643
653
  #
644
654
  def hostname
645
655
  v = self.host
646
- /\A\[(.*)\]\z/ =~ v ? $1 : v
656
+ v&.start_with?('[') && v.end_with?(']') ? v[1..-2] : v
647
657
  end
648
658
 
649
659
  # Sets the host part of the Bundler::URI as the argument with brackets for IPv6 addresses.
@@ -659,7 +669,7 @@ module Bundler::URI
659
669
  # it is wrapped with brackets.
660
670
  #
661
671
  def hostname=(v)
662
- v = "[#{v}]" if /\A\[.*\]\z/ !~ v && /:/ =~ v
672
+ v = "[#{v}]" if !(v&.start_with?('[') && v&.end_with?(']')) && v&.index(':')
663
673
  self.host = v
664
674
  end
665
675
 
@@ -1514,9 +1524,19 @@ module Bundler::URI
1514
1524
  proxy_uri = env["CGI_#{name.upcase}"]
1515
1525
  end
1516
1526
  elsif name == 'http_proxy'
1517
- unless proxy_uri = env[name]
1518
- if proxy_uri = env[name.upcase]
1519
- warn 'The environment variable HTTP_PROXY is discouraged. Use http_proxy.', uplevel: 1
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
1520
1540
  end
1521
1541
  end
1522
1542
  else
@@ -80,8 +80,46 @@ module Bundler::URI
80
80
  url = @query ? "#@path?#@query" : @path.dup
81
81
  url.start_with?(?/.freeze) ? url : ?/ + url
82
82
  end
83
- end
84
83
 
85
- @@schemes['HTTP'] = HTTP
84
+ #
85
+ # == Description
86
+ #
87
+ # Returns the authority for an HTTP uri, as defined in
88
+ # https://datatracker.ietf.org/doc/html/rfc3986/#section-3.2.
89
+ #
90
+ #
91
+ # Example:
92
+ #
93
+ # Bundler::URI::HTTP.build(host: 'www.example.com', path: '/foo/bar').authority #=> "www.example.com"
94
+ # Bundler::URI::HTTP.build(host: 'www.example.com', port: 8000, path: '/foo/bar').authority #=> "www.example.com:8000"
95
+ # Bundler::URI::HTTP.build(host: 'www.example.com', port: 80, path: '/foo/bar').authority #=> "www.example.com"
96
+ #
97
+ def authority
98
+ if port == default_port
99
+ host
100
+ else
101
+ "#{host}:#{port}"
102
+ end
103
+ end
104
+
105
+ #
106
+ # == Description
107
+ #
108
+ # Returns the origin for an HTTP uri, as defined in
109
+ # https://datatracker.ietf.org/doc/html/rfc6454.
110
+ #
111
+ #
112
+ # Example:
113
+ #
114
+ # Bundler::URI::HTTP.build(host: 'www.example.com', path: '/foo/bar').origin #=> "http://www.example.com"
115
+ # Bundler::URI::HTTP.build(host: 'www.example.com', port: 8000, path: '/foo/bar').origin #=> "http://www.example.com:8000"
116
+ # Bundler::URI::HTTP.build(host: 'www.example.com', port: 80, path: '/foo/bar').origin #=> "http://www.example.com"
117
+ # Bundler::URI::HTTPS.build(host: 'www.example.com', path: '/foo/bar').origin #=> "https://www.example.com"
118
+ #
119
+ def origin
120
+ "#{scheme}://#{authority}"
121
+ end
122
+ end
86
123
 
124
+ register_scheme 'HTTP', HTTP
87
125
  end
@@ -18,5 +18,6 @@ module Bundler::URI
18
18
  # A Default port of 443 for Bundler::URI::HTTPS
19
19
  DEFAULT_PORT = 443
20
20
  end
21
- @@schemes['HTTPS'] = HTTPS
21
+
22
+ register_scheme 'HTTPS', HTTPS
22
23
  end
@@ -257,5 +257,5 @@ module Bundler::URI
257
257
  end
258
258
  end
259
259
 
260
- @@schemes['LDAP'] = LDAP
260
+ register_scheme 'LDAP', LDAP
261
261
  end
@@ -17,5 +17,6 @@ module Bundler::URI
17
17
  # A Default port of 636 for Bundler::URI::LDAPS
18
18
  DEFAULT_PORT = 636
19
19
  end
20
- @@schemes['LDAPS'] = LDAPS
20
+
21
+ register_scheme 'LDAPS', LDAPS
21
22
  end
@@ -15,7 +15,7 @@ module Bundler::URI
15
15
  # RFC6068, the mailto URL scheme.
16
16
  #
17
17
  class MailTo < Generic
18
- include REGEXP
18
+ include RFC2396_REGEXP
19
19
 
20
20
  # A Default port of nil for Bundler::URI::MailTo.
21
21
  DEFAULT_PORT = nil
@@ -289,5 +289,5 @@ module Bundler::URI
289
289
  alias to_rfc822text to_mailtext
290
290
  end
291
291
 
292
- @@schemes['MAILTO'] = MailTo
292
+ register_scheme 'MAILTO', MailTo
293
293
  end
@@ -116,7 +116,7 @@ module Bundler::URI
116
116
  # See also Bundler::URI::Parser.initialize_regexp.
117
117
  attr_reader :regexp
118
118
 
119
- # Returns a split Bundler::URI against regexp[:ABS_URI].
119
+ # Returns a split Bundler::URI against +regexp[:ABS_URI]+.
120
120
  def split(uri)
121
121
  case uri
122
122
  when ''
@@ -257,8 +257,8 @@ module Bundler::URI
257
257
  end
258
258
  end
259
259
 
260
- # Returns Regexp that is default self.regexp[:ABS_URI_REF],
261
- # unless +schemes+ is provided. Then it is a Regexp.union with self.pattern[:X_ABS_URI].
260
+ # Returns Regexp that is default +self.regexp[:ABS_URI_REF]+,
261
+ # unless +schemes+ is provided. Then it is a Regexp.union with +self.pattern[:X_ABS_URI]+.
262
262
  def make_regexp(schemes = nil)
263
263
  unless schemes
264
264
  @regexp[:ABS_URI_REF]
@@ -277,7 +277,7 @@ module Bundler::URI
277
277
  # +str+::
278
278
  # String to make safe
279
279
  # +unsafe+::
280
- # Regexp to apply. Defaults to self.regexp[:UNSAFE]
280
+ # Regexp to apply. Defaults to +self.regexp[:UNSAFE]+
281
281
  #
282
282
  # == Description
283
283
  #
@@ -309,7 +309,7 @@ module Bundler::URI
309
309
  # +str+::
310
310
  # String to remove escapes from
311
311
  # +escaped+::
312
- # Regexp to apply. Defaults to self.regexp[:ESCAPED]
312
+ # Regexp to apply. Defaults to +self.regexp[:ESCAPED]+
313
313
  #
314
314
  # == Description
315
315
  #
@@ -322,8 +322,14 @@ module Bundler::URI
322
322
  end
323
323
 
324
324
  @@to_s = Kernel.instance_method(:to_s)
325
- def inspect
326
- @@to_s.bind_call(self)
325
+ if @@to_s.respond_to?(:bind_call)
326
+ def inspect
327
+ @@to_s.bind_call(self)
328
+ end
329
+ else
330
+ def inspect
331
+ @@to_s.bind(self).call
332
+ end
327
333
  end
328
334
 
329
335
  private
@@ -2,9 +2,8 @@
2
2
  module Bundler::URI
3
3
  class RFC3986_Parser # :nodoc:
4
4
  # Bundler::URI defined in RFC3986
5
- # this regexp is modified not to host is not empty string
6
- RFC3986_URI = /\A(?<Bundler::URI>(?<scheme>[A-Za-z][+\-.0-9A-Za-z]*):(?<hier-part>\/\/(?<authority>(?:(?<userinfo>(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*)@)?(?<host>(?<IP-literal>\[(?:(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{1,4}?::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:)?\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h+\.[!$&-.0-;=A-Z_a-z~]+))\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])+))?(?::(?<port>\d*))?)(?<path-abempty>(?:\/(?<segment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*))*)|(?<path-absolute>\/(?:(?<segment-nz>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])+)(?:\/\g<segment>)*)?)|(?<path-rootless>\g<segment-nz>(?:\/\g<segment>)*)|(?<path-empty>))(?:\?(?<query>[^#]*))?(?:\#(?<fragment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*))?)\z/
7
- RFC3986_relative_ref = /\A(?<relative-ref>(?<relative-part>\/\/(?<authority>(?:(?<userinfo>(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*)@)?(?<host>(?<IP-literal>\[(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{1,4}?::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:){,1}\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h+\.[!$&-.0-;=A-Z_a-z~]+)\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])+))?(?::(?<port>\d*))?)(?<path-abempty>(?:\/(?<segment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*))*)|(?<path-absolute>\/(?:(?<segment-nz>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])+)(?:\/\g<segment>)*)?)|(?<path-noscheme>(?<segment-nz-nc>(?:%\h\h|[!$&-.0-9;=@-Z_a-z~])+)(?:\/\g<segment>)*)|(?<path-empty>))(?:\?(?<query>[^#]*))?(?:\#(?<fragment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*))?)\z/
5
+ RFC3986_URI = /\A(?<Bundler::URI>(?<scheme>[A-Za-z][+\-.0-9A-Za-z]*):(?<hier-part>\/\/(?<authority>(?:(?<userinfo>(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*)@)?(?<host>(?<IP-literal>\[(?:(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{1,4}?::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:)?\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h+\.[!$&-.0-;=A-Z_a-z~]+))\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])*))(?::(?<port>\d*))?)(?<path-abempty>(?:\/(?<segment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*))*)|(?<path-absolute>\/(?:(?<segment-nz>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])+)(?:\/\g<segment>)*)?)|(?<path-rootless>\g<segment-nz>(?:\/\g<segment>)*)|(?<path-empty>))(?:\?(?<query>[^#]*))?(?:\#(?<fragment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*))?)\z/
6
+ RFC3986_relative_ref = /\A(?<relative-ref>(?<relative-part>\/\/(?<authority>(?:(?<userinfo>(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*)@)?(?<host>(?<IP-literal>\[(?:(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{1,4}?::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:){,1}\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h+\.[!$&-.0-;=A-Z_a-z~]+))\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])+))?(?::(?<port>\d*))?)(?<path-abempty>(?:\/(?<segment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*))*)|(?<path-absolute>\/(?:(?<segment-nz>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])+)(?:\/\g<segment>)*)?)|(?<path-noscheme>(?<segment-nz-nc>(?:%\h\h|[!$&-.0-9;=@-Z_a-z~])+)(?:\/\g<segment>)*)|(?<path-empty>))(?:\?(?<query>[^#]*))?(?:\#(?<fragment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*))?)\z/
8
7
  attr_reader :regexp
9
8
 
10
9
  def initialize
@@ -79,8 +78,14 @@ module Bundler::URI
79
78
  end
80
79
 
81
80
  @@to_s = Kernel.instance_method(:to_s)
82
- def inspect
83
- @@to_s.bind_call(self)
81
+ if @@to_s.respond_to?(:bind_call)
82
+ def inspect
83
+ @@to_s.bind_call(self)
84
+ end
85
+ else
86
+ def inspect
87
+ @@to_s.bind(self).call
88
+ end
84
89
  end
85
90
 
86
91
  private
@@ -1,6 +1,6 @@
1
1
  module Bundler::URI
2
2
  # :stopdoc:
3
- VERSION_CODE = '001001'.freeze
3
+ VERSION_CODE = '001200'.freeze
4
4
  VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze
5
5
  # :startdoc:
6
6
  end
@@ -79,6 +79,5 @@ module Bundler::URI
79
79
  end
80
80
  end
81
81
 
82
- @@schemes['WS'] = WS
83
-
82
+ register_scheme 'WS', WS
84
83
  end
@@ -18,5 +18,6 @@ module Bundler::URI
18
18
  # A Default port of 443 for Bundler::URI::WSS
19
19
  DEFAULT_PORT = 443
20
20
  end
21
- @@schemes['WSS'] = WSS
21
+
22
+ register_scheme 'WSS', WSS
22
23
  end