bundler 2.3.26 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +48 -0
- data/README.md +2 -2
- data/bundler.gemspec +2 -2
- data/exe/bundle +1 -4
- data/lib/bundler/build_metadata.rb +2 -2
- data/lib/bundler/cli/add.rb +1 -1
- data/lib/bundler/cli/check.rb +1 -1
- data/lib/bundler/cli/common.rb +1 -0
- data/lib/bundler/cli/console.rb +2 -2
- data/lib/bundler/cli/doctor.rb +4 -6
- data/lib/bundler/cli/gem.rb +62 -40
- data/lib/bundler/cli/install.rb +2 -3
- data/lib/bundler/cli/lock.rb +8 -5
- data/lib/bundler/cli/outdated.rb +1 -3
- data/lib/bundler/cli/viz.rb +1 -1
- data/lib/bundler/cli.rb +43 -2
- data/lib/bundler/compact_index_client/cache.rb +1 -1
- data/lib/bundler/compact_index_client/updater.rb +40 -39
- data/lib/bundler/constants.rb +1 -1
- data/lib/bundler/definition.rb +61 -31
- data/lib/bundler/dependency.rb +12 -11
- data/lib/bundler/digest.rb +1 -1
- data/lib/bundler/dsl.rb +1 -1
- data/lib/bundler/env.rb +1 -1
- data/lib/bundler/environment_preserver.rb +1 -0
- data/lib/bundler/errors.rb +1 -11
- data/lib/bundler/fetcher/compact_index.rb +9 -11
- data/lib/bundler/fetcher/dependency.rb +1 -1
- data/lib/bundler/fetcher/downloader.rb +2 -5
- data/lib/bundler/fetcher.rb +2 -6
- data/lib/bundler/force_platform.rb +18 -0
- data/lib/bundler/friendly_errors.rb +0 -3
- data/lib/bundler/gem_version_promoter.rb +52 -86
- data/lib/bundler/graph.rb +3 -3
- data/lib/bundler/index.rb +5 -13
- data/lib/bundler/injector.rb +1 -1
- data/lib/bundler/inline.rb +2 -2
- data/lib/bundler/installer/parallel_installer.rb +0 -31
- data/lib/bundler/installer.rb +6 -16
- data/lib/bundler/lazy_specification.rb +5 -1
- data/lib/bundler/lockfile_parser.rb +5 -5
- data/lib/bundler/man/bundle-add.1 +1 -1
- data/lib/bundler/man/bundle-binstubs.1 +1 -1
- data/lib/bundler/man/bundle-cache.1 +1 -1
- data/lib/bundler/man/bundle-check.1 +1 -1
- data/lib/bundler/man/bundle-clean.1 +1 -1
- data/lib/bundler/man/bundle-config.1 +1 -1
- data/lib/bundler/man/bundle-console.1 +1 -1
- data/lib/bundler/man/bundle-doctor.1 +1 -1
- data/lib/bundler/man/bundle-exec.1 +1 -1
- data/lib/bundler/man/bundle-gem.1 +27 -37
- data/lib/bundler/man/bundle-gem.1.ronn +5 -5
- data/lib/bundler/man/bundle-help.1 +1 -1
- data/lib/bundler/man/bundle-info.1 +1 -1
- data/lib/bundler/man/bundle-init.1 +1 -1
- data/lib/bundler/man/bundle-inject.1 +1 -1
- data/lib/bundler/man/bundle-install.1 +1 -30
- data/lib/bundler/man/bundle-install.1.ronn +0 -29
- data/lib/bundler/man/bundle-list.1 +1 -1
- data/lib/bundler/man/bundle-lock.1 +1 -1
- data/lib/bundler/man/bundle-open.1 +1 -1
- data/lib/bundler/man/bundle-outdated.1 +1 -1
- data/lib/bundler/man/bundle-platform.1 +2 -2
- data/lib/bundler/man/bundle-platform.1.ronn +1 -1
- data/lib/bundler/man/bundle-plugin.1 +1 -1
- data/lib/bundler/man/bundle-pristine.1 +1 -1
- data/lib/bundler/man/bundle-remove.1 +1 -1
- data/lib/bundler/man/bundle-show.1 +1 -1
- data/lib/bundler/man/bundle-update.1 +1 -1
- data/lib/bundler/man/bundle-version.1 +1 -1
- data/lib/bundler/man/bundle-viz.1 +1 -1
- data/lib/bundler/man/bundle.1 +1 -1
- data/lib/bundler/man/gemfile.5 +1 -1
- data/lib/bundler/mirror.rb +5 -7
- data/lib/bundler/plugin/index.rb +4 -4
- data/lib/bundler/plugin/installer/rubygems.rb +0 -4
- data/lib/bundler/resolver/base.rb +7 -11
- data/lib/bundler/resolver/candidate.rb +92 -0
- data/lib/bundler/resolver/incompatibility.rb +15 -0
- data/lib/bundler/resolver/package.rb +63 -0
- data/lib/bundler/resolver/root.rb +25 -0
- data/lib/bundler/resolver/spec_group.rb +26 -36
- data/lib/bundler/resolver.rb +285 -277
- data/lib/bundler/rubygems_ext.rb +11 -6
- data/lib/bundler/rubygems_gem_installer.rb +4 -2
- data/lib/bundler/rubygems_integration.rb +1 -9
- data/lib/bundler/runtime.rb +1 -5
- data/lib/bundler/settings.rb +0 -6
- data/lib/bundler/shared_helpers.rb +1 -0
- data/lib/bundler/source/git/git_proxy.rb +190 -67
- data/lib/bundler/source/git.rb +15 -17
- data/lib/bundler/source/metadata.rb +0 -1
- data/lib/bundler/source/path/installer.rb +1 -22
- data/lib/bundler/source/path.rb +5 -5
- data/lib/bundler/source/rubygems.rb +13 -67
- data/lib/bundler/source_list.rb +8 -2
- data/lib/bundler/spec_set.rb +7 -9
- data/lib/bundler/templates/Executable +1 -1
- data/lib/bundler/templates/Executable.bundler +4 -9
- data/lib/bundler/templates/Executable.standalone +2 -0
- data/lib/bundler/templates/newgem/Cargo.toml.tt +7 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +3 -0
- data/lib/bundler/templates/newgem/README.md.tt +6 -4
- data/lib/bundler/templates/newgem/Rakefile.tt +2 -1
- data/lib/bundler/templates/newgem/circleci/config.yml.tt +12 -0
- data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +15 -0
- data/lib/bundler/templates/newgem/ext/newgem/{extconf.rb.tt → extconf-c.rb.tt} +0 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
- data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +12 -0
- data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +10 -0
- data/lib/bundler/templates/newgem/gitignore.tt +3 -0
- data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +8 -0
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +8 -2
- data/lib/bundler/ui/shell.rb +35 -12
- data/lib/bundler/ui/silent.rb +21 -5
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +3 -3
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +0 -1
- data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +3 -1
- data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1350 -408
- data/lib/bundler/vendor/net-http-persistent/README.rdoc +1 -1
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1 -1
- data/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +189 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +151 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +53 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +124 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +409 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +240 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +1 -1
- data/lib/bundler/vendor/uri/lib/uri/common.rb +64 -16
- data/lib/bundler/vendor/uri/lib/uri/file.rb +7 -1
- data/lib/bundler/vendor/uri/lib/uri/ftp.rb +2 -1
- data/lib/bundler/vendor/uri/lib/uri/generic.rb +27 -7
- data/lib/bundler/vendor/uri/lib/uri/http.rb +40 -2
- data/lib/bundler/vendor/uri/lib/uri/https.rb +2 -1
- data/lib/bundler/vendor/uri/lib/uri/ldap.rb +1 -1
- data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +2 -1
- data/lib/bundler/vendor/uri/lib/uri/mailto.rb +2 -2
- data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +13 -7
- data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +10 -5
- data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
- data/lib/bundler/vendor/uri/lib/uri/ws.rb +1 -2
- data/lib/bundler/vendor/uri/lib/uri/wss.rb +2 -1
- data/lib/bundler/vendor/uri/lib/uri.rb +3 -2
- data/lib/bundler/vendored_persistent.rb +1 -33
- data/lib/bundler/{vendored_tmpdir.rb → vendored_pub_grub.rb} +1 -1
- data/lib/bundler/version.rb +5 -1
- data/lib/bundler/worker.rb +5 -7
- data/lib/bundler.rb +20 -64
- metadata +33 -32
- data/lib/bundler/templates/newgem/travis.yml.tt +0 -6
- data/lib/bundler/vendor/molinillo/LICENSE +0 -9
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +0 -88
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +0 -36
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +0 -66
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +0 -62
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +0 -63
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +0 -61
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +0 -126
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +0 -46
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +0 -36
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +0 -164
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -255
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +0 -149
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +0 -6
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +0 -112
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +0 -67
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +0 -839
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +0 -46
- data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +0 -58
- data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -11
- data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +0 -154
- data/lib/bundler/vendored_molinillo.rb +0 -4
- data/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
|
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
|
-
|
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
|
-
|
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
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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!(
|
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
|
-
|
319
|
-
|
320
|
-
|
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
|
-
|
99
|
+
register_scheme 'FILE', File
|
94
100
|
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
|
-
|
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
|
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
|
-
|
1518
|
-
|
1519
|
-
|
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
|
-
|
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
|
@@ -15,7 +15,7 @@ module Bundler::URI
|
|
15
15
|
# RFC6068, the mailto URL scheme.
|
16
16
|
#
|
17
17
|
class MailTo < Generic
|
18
|
-
include
|
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
|
-
|
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
|
-
|
326
|
-
|
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
|
-
|
6
|
-
|
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
|
-
|
83
|
-
|
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
|