bundler 4.1.0.beta3 → 4.1.1
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.
- checksums.yaml +4 -4
- data/bundler.gemspec +5 -3
- data/lib/bundler/build_metadata.rb +2 -2
- data/lib/bundler/checksum.rb +17 -2
- data/lib/bundler/cli/clean.rb +19 -3
- data/lib/bundler/cli/exec.rb +1 -1
- data/lib/bundler/cli/install.rb +1 -1
- data/lib/bundler/cli/lock.rb +12 -0
- data/lib/bundler/cli/outdated.rb +1 -4
- data/lib/bundler/cli/update.rb +1 -1
- data/lib/bundler/cli.rb +2 -0
- data/lib/bundler/definition.rb +152 -7
- data/lib/bundler/dependency.rb +17 -2
- data/lib/bundler/dsl.rb +9 -2
- data/lib/bundler/errors.rb +8 -0
- data/lib/bundler/fetcher/downloader.rb +7 -3
- data/lib/bundler/index.rb +7 -2
- data/lib/bundler/injector.rb +1 -1
- data/lib/bundler/inline.rb +19 -9
- data/lib/bundler/installer.rb +19 -0
- data/lib/bundler/lazy_specification.rb +46 -25
- data/lib/bundler/lockfile_generator.rb +21 -9
- data/lib/bundler/lockfile_parser.rb +21 -5
- data/lib/bundler/man/bundle-lock.1 +8 -2
- data/lib/bundler/man/bundle-lock.1.ronn +15 -1
- data/lib/bundler/man/bundle-plugin.1 +61 -0
- data/lib/bundler/man/bundle-plugin.1.ronn +84 -0
- data/lib/bundler/man/gemfile.5 +3 -1
- data/lib/bundler/man/gemfile.5.ronn +11 -3
- data/lib/bundler/match_platform.rb +3 -3
- data/lib/bundler/match_remote_metadata.rb +6 -0
- data/lib/bundler/mirror.rb +7 -5
- data/lib/bundler/plugin/index.rb +14 -11
- data/lib/bundler/remote_specification.rb +5 -0
- data/lib/bundler/resolver/candidate.rb +5 -0
- data/lib/bundler/resolver.rb +89 -7
- data/lib/bundler/ruby_dsl.rb +2 -1
- data/lib/bundler/rubygems_ext.rb +54 -9
- data/lib/bundler/rubygems_integration.rb +2 -4
- data/lib/bundler/runtime.rb +29 -11
- data/lib/bundler/settings.rb +2 -3
- data/lib/bundler/source/git/git_proxy.rb +18 -6
- data/lib/bundler/source/git.rb +0 -2
- data/lib/bundler/spec_set.rb +54 -14
- data/lib/bundler/stub_specification.rb +4 -0
- data/lib/bundler/vendored_securerandom.rb +5 -2
- data/lib/bundler/vendored_uri.rb +18 -3
- data/lib/bundler/version.rb +1 -1
- data/lib/bundler/worker.rb +4 -0
- data/lib/bundler.rb +1 -1
- data/lib/rubygems/compact_index_client/http_fetcher.rb +3 -1
- data/lib/rubygems/vendor/pub_grub/lib/pub_grub/term.rb +1 -1
- data/lib/rubygems/yaml_serializer/builder.rb +261 -0
- data/lib/rubygems/yaml_serializer/core.rb +41 -0
- data/lib/rubygems/yaml_serializer/emitter.rb +197 -0
- data/lib/rubygems/yaml_serializer/nodes.rb +10 -0
- data/lib/rubygems/yaml_serializer/parser.rb +531 -0
- data/lib/rubygems/yaml_serializer/psych_errors.rb +11 -0
- metadata +8 -4
- data/lib/rubygems/vendor/uri/lib/uri.rb +0 -108
- data/lib/rubygems/yaml_serializer.rb +0 -908
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Gem
|
|
4
|
+
module YAMLSerializer
|
|
5
|
+
class Emitter
|
|
6
|
+
STRING_ESCAPES = {
|
|
7
|
+
"\\" => "\\\\",
|
|
8
|
+
"\"" => "\\\"",
|
|
9
|
+
"\0" => "\\0",
|
|
10
|
+
"\a" => "\\a",
|
|
11
|
+
"\b" => "\\b",
|
|
12
|
+
"\t" => "\\t",
|
|
13
|
+
"\n" => "\\n",
|
|
14
|
+
"\v" => "\\v",
|
|
15
|
+
"\f" => "\\f",
|
|
16
|
+
"\r" => "\\r",
|
|
17
|
+
"\e" => "\\e",
|
|
18
|
+
}.freeze
|
|
19
|
+
|
|
20
|
+
def emit(obj)
|
|
21
|
+
res = "---#{emit_node(obj, 0)}"
|
|
22
|
+
res << "...\n" if @open_ended
|
|
23
|
+
res
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def emit_node(obj, indent, quote: false)
|
|
29
|
+
case obj
|
|
30
|
+
when Gem::Specification then emit_specification(obj, indent)
|
|
31
|
+
when Gem::Version then emit_version(obj, indent)
|
|
32
|
+
when Gem::Platform then emit_platform(obj, indent)
|
|
33
|
+
when Gem::Requirement then emit_requirement(obj, indent)
|
|
34
|
+
when Gem::Dependency then emit_dependency(obj, indent)
|
|
35
|
+
when Hash then emit_hash(obj, indent)
|
|
36
|
+
when Array then emit_array(obj, indent)
|
|
37
|
+
when Time then emit_time(obj)
|
|
38
|
+
when String then emit_string(obj, indent, quote: quote)
|
|
39
|
+
when NilClass
|
|
40
|
+
"\n"
|
|
41
|
+
when Numeric, Symbol, TrueClass, FalseClass
|
|
42
|
+
" #{obj.inspect}\n"
|
|
43
|
+
else
|
|
44
|
+
" #{quote_string(obj.to_s)}\n"
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def emit_specification(spec, indent)
|
|
49
|
+
parts = [" !ruby/object:Gem::Specification\n"]
|
|
50
|
+
parts << "#{pad(indent)}name:#{emit_node(spec.name, indent + 2)}"
|
|
51
|
+
parts << "#{pad(indent)}version:#{emit_node(spec.version, indent + 2)}"
|
|
52
|
+
parts << "#{pad(indent)}platform: #{spec.platform}\n"
|
|
53
|
+
if spec.platform.to_s != spec.original_platform.to_s
|
|
54
|
+
parts << "#{pad(indent)}original_platform: #{spec.original_platform}\n"
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
attributes = Gem::Specification.attribute_names.map(&:to_s).sort - %w[name version platform]
|
|
58
|
+
attributes.each do |name|
|
|
59
|
+
val = spec.instance_variable_get("@#{name}")
|
|
60
|
+
next if val.nil?
|
|
61
|
+
parts << "#{pad(indent)}#{name}:#{emit_node(val, indent + 2)}"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
res = parts.join
|
|
65
|
+
res << "\n" unless res.end_with?("\n")
|
|
66
|
+
res
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def emit_version(ver, indent)
|
|
70
|
+
" !ruby/object:Gem::Version\n" \
|
|
71
|
+
"#{pad(indent)}version: #{emit_node(ver.version.to_s, indent + 2).lstrip}"
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def emit_platform(plat, indent)
|
|
75
|
+
" !ruby/object:Gem::Platform\n" \
|
|
76
|
+
"#{pad(indent)}cpu:#{emit_node(plat.cpu, indent + 2)}" \
|
|
77
|
+
"#{pad(indent)}os:#{emit_node(plat.os, indent + 2)}" \
|
|
78
|
+
"#{pad(indent)}version:#{emit_node(plat.version, indent + 2)}"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def emit_requirement(req, indent)
|
|
82
|
+
" !ruby/object:Gem::Requirement\n" \
|
|
83
|
+
"#{pad(indent)}requirements:#{emit_node(req.requirements, indent + 2)}"
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def emit_dependency(dep, indent)
|
|
87
|
+
[
|
|
88
|
+
" !ruby/object:Gem::Dependency\n",
|
|
89
|
+
"#{pad(indent)}name: #{emit_node(dep.name, indent + 2).lstrip}",
|
|
90
|
+
"#{pad(indent)}requirement:#{emit_node(dep.requirement, indent + 2)}",
|
|
91
|
+
"#{pad(indent)}type: #{emit_node(dep.type, indent + 2).lstrip}",
|
|
92
|
+
"#{pad(indent)}prerelease: #{emit_node(dep.prerelease?, indent + 2).lstrip}",
|
|
93
|
+
"#{pad(indent)}version_requirements:#{emit_node(dep.requirement, indent + 2)}",
|
|
94
|
+
].join
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def emit_hash(hash, indent)
|
|
98
|
+
if hash.empty?
|
|
99
|
+
" {}\n"
|
|
100
|
+
else
|
|
101
|
+
parts = ["\n"]
|
|
102
|
+
hash.each do |k, v|
|
|
103
|
+
is_symbol = k.is_a?(Symbol) || (k.is_a?(String) && k.start_with?(":"))
|
|
104
|
+
key_str = k.is_a?(Symbol) ? k.inspect : k.to_s
|
|
105
|
+
key_str = quote_string(key_str) if !is_symbol && needs_quoting?(key_str, key: true)
|
|
106
|
+
parts << "#{pad(indent)}#{key_str}:#{emit_node(v, indent + 2, quote: is_symbol)}"
|
|
107
|
+
end
|
|
108
|
+
parts.join
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def emit_array(arr, indent)
|
|
113
|
+
if arr.empty?
|
|
114
|
+
" []\n"
|
|
115
|
+
else
|
|
116
|
+
parts = ["\n"]
|
|
117
|
+
arr.each do |v|
|
|
118
|
+
parts << "#{pad(indent)}-#{emit_node(v, indent + 2)}"
|
|
119
|
+
end
|
|
120
|
+
parts.join
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def emit_time(time)
|
|
125
|
+
" #{time.utc.strftime("%Y-%m-%d %H:%M:%S.%N Z")}\n"
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def emit_string(str, indent, quote: false)
|
|
129
|
+
# A CR cannot be represented in a block scalar because parsing
|
|
130
|
+
# normalizes CRLF line breaks to LF, so quote and escape instead.
|
|
131
|
+
if str.include?("\n") && !str.include?("\r")
|
|
132
|
+
emit_block_scalar(str, indent)
|
|
133
|
+
elsif needs_quoting?(str, quote)
|
|
134
|
+
" #{quote_string(str)}\n"
|
|
135
|
+
else
|
|
136
|
+
" #{str}\n"
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def emit_block_scalar(str, indent)
|
|
141
|
+
# The root node has no parent to be indented from, so indent its
|
|
142
|
+
# content by one level like libyaml does.
|
|
143
|
+
indent = 2 if indent.zero?
|
|
144
|
+
parts = [" |#{block_scalar_header(str)}\n"]
|
|
145
|
+
str.each_line do |line|
|
|
146
|
+
parts << (line == "\n" ? line : "#{pad(indent)}#{line}")
|
|
147
|
+
end
|
|
148
|
+
res = parts.join
|
|
149
|
+
res << "\n" unless res.end_with?("\n")
|
|
150
|
+
res
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# Mirrors libyaml: an explicit indentation indicator when the first
|
|
154
|
+
# line is empty or starts with a space (a parser would otherwise take
|
|
155
|
+
# that whitespace as the block indentation and drop it), "-" when the
|
|
156
|
+
# content does not end with a line break and "+" when it ends with
|
|
157
|
+
# more than one, which also requires a document end marker.
|
|
158
|
+
def block_scalar_header(str)
|
|
159
|
+
header = +""
|
|
160
|
+
header << "2" if str.start_with?(" ", "\n")
|
|
161
|
+
if !str.end_with?("\n")
|
|
162
|
+
header << "-"
|
|
163
|
+
elsif str.end_with?("\n\n") || str == "\n"
|
|
164
|
+
header << "+"
|
|
165
|
+
@open_ended = true
|
|
166
|
+
end
|
|
167
|
+
header
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def needs_quoting?(str, quote = false, key: false)
|
|
171
|
+
quote || str.empty? || str != str.strip || str =~ /[[:cntrl:]]/ ||
|
|
172
|
+
str =~ /^[!*&:@%$"'|`]/ || str =~ /^-?\d+(\.\d+)?$/ || str =~ /^[<>=-]/ ||
|
|
173
|
+
str == "true" || str == "false" || str == "nil" || str == "null" || str == "~" ||
|
|
174
|
+
(key ? colon_needs_quoting_in_key?(str) : str.include?(":")) ||
|
|
175
|
+
str.include?("#") || str.include?("[") || str.include?("]") ||
|
|
176
|
+
str.include?("{") || str.include?("}") || str.include?(",")
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# The serializer that RubyGems 4.0 and Bundler 4.0 ship keeps quotes as
|
|
180
|
+
# part of a key, so keys like Bundler's mirror settings for a URL stay
|
|
181
|
+
# plain where YAML allows it, as libyaml writes them. A ":" only ends a
|
|
182
|
+
# plain key when a space or the line end follows it, and a key that
|
|
183
|
+
# starts with a letter is not read as a number or a time.
|
|
184
|
+
def colon_needs_quoting_in_key?(str)
|
|
185
|
+
str.include?(":") && (!str.match?(/\A[[:alpha:]]/) || str.match?(/:(?!\S)/))
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def quote_string(str)
|
|
189
|
+
%("#{str.gsub(/[\\"]|[[:cntrl:]]/) {|c| STRING_ESCAPES[c] || format("\\x%02X", c.ord) }}")
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def pad(indent)
|
|
193
|
+
" " * indent
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
end
|