mirror of
https://github.com/ruby/ruby.git
synced 2025-08-26 14:34:39 +02:00
[rubygems/rubygems] Upgrade vendored libraries
To match the versions that will be included in final ruby release.
84394919fb
This commit is contained in:
parent
912016f626
commit
a79a1d3028
11 changed files with 951 additions and 222 deletions
|
@ -48,7 +48,7 @@
|
|||
#
|
||||
# == Gem::OptionParser
|
||||
#
|
||||
# === New to \Gem::OptionParser?
|
||||
# === New to +Gem::OptionParser+?
|
||||
#
|
||||
# See the {Tutorial}[optparse/tutorial.rdoc].
|
||||
#
|
||||
|
@ -152,14 +152,14 @@
|
|||
# Gem::OptionParser supports the ability to coerce command line arguments
|
||||
# into objects for us.
|
||||
#
|
||||
# Gem::OptionParser comes with a few ready-to-use kinds of type
|
||||
# Gem::OptionParser comes with a few ready-to-use kinds of type
|
||||
# coercion. They are:
|
||||
#
|
||||
# - Date -- Anything accepted by +Date.parse+
|
||||
# - DateTime -- Anything accepted by +DateTime.parse+
|
||||
# - Time -- Anything accepted by +Time.httpdate+ or +Time.parse+
|
||||
# - URI -- Anything accepted by +URI.parse+
|
||||
# - Shellwords -- Anything accepted by +Shellwords.shellwords+
|
||||
# - Date -- Anything accepted by +Date.parse+ (need to require +optparse/date+)
|
||||
# - DateTime -- Anything accepted by +DateTime.parse+ (need to require +optparse/date+)
|
||||
# - Time -- Anything accepted by +Time.httpdate+ or +Time.parse+ (need to require +optparse/time+)
|
||||
# - URI -- Anything accepted by +URI.parse+ (need to require +optparse/uri+)
|
||||
# - Shellwords -- Anything accepted by +Shellwords.shellwords+ (need to require +optparse/shellwords+)
|
||||
# - String -- Any non-empty string
|
||||
# - Integer -- Any integer. Will convert octal. (e.g. 124, -3, 040)
|
||||
# - Float -- Any float. (e.g. 10, 3.14, -100E+13)
|
||||
|
@ -425,7 +425,7 @@
|
|||
# If you have any questions, file a ticket at http://bugs.ruby-lang.org.
|
||||
#
|
||||
class Gem::OptionParser
|
||||
Gem::OptionParser::Version = "0.3.0"
|
||||
Gem::OptionParser::Version = "0.4.0"
|
||||
|
||||
# :stopdoc:
|
||||
NoArgument = [NO_ARGUMENT = :NONE, nil].freeze
|
||||
|
@ -1775,7 +1775,16 @@ XXX
|
|||
# # params["bar"] = "x" # --bar x
|
||||
# # params["zot"] = "z" # --zot Z
|
||||
#
|
||||
def getopts(*args)
|
||||
# Option +symbolize_names+ (boolean) specifies whether returned Hash keys should be Symbols; defaults to +false+ (use Strings).
|
||||
#
|
||||
# params = ARGV.getopts("ab:", "foo", "bar:", "zot:Z;zot option", symbolize_names: true)
|
||||
# # params[:a] = true # -a
|
||||
# # params[:b] = "1" # -b1
|
||||
# # params[:foo] = "1" # --foo
|
||||
# # params[:bar] = "x" # --bar x
|
||||
# # params[:zot] = "z" # --zot Z
|
||||
#
|
||||
def getopts(*args, symbolize_names: false)
|
||||
argv = Array === args.first ? args.shift : default_argv
|
||||
single_options, *long_options = *args
|
||||
|
||||
|
@ -1804,14 +1813,14 @@ XXX
|
|||
end
|
||||
|
||||
parse_in_order(argv, result.method(:[]=))
|
||||
result
|
||||
symbolize_names ? result.transform_keys(&:to_sym) : result
|
||||
end
|
||||
|
||||
#
|
||||
# See #getopts.
|
||||
#
|
||||
def self.getopts(*args)
|
||||
new.getopts(*args)
|
||||
def self.getopts(*args, symbolize_names: false)
|
||||
new.getopts(*args, symbolize_names: symbolize_names)
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -2084,10 +2093,23 @@ XXX
|
|||
f |= Regexp::IGNORECASE if /i/ =~ o
|
||||
f |= Regexp::MULTILINE if /m/ =~ o
|
||||
f |= Regexp::EXTENDED if /x/ =~ o
|
||||
k = o.delete("imx")
|
||||
k = nil if k.empty?
|
||||
case o = o.delete("imx")
|
||||
when ""
|
||||
when "u"
|
||||
s = s.encode(Encoding::UTF_8)
|
||||
when "e"
|
||||
s = s.encode(Encoding::EUC_JP)
|
||||
when "s"
|
||||
s = s.encode(Encoding::SJIS)
|
||||
when "n"
|
||||
f |= Regexp::NOENCODING
|
||||
else
|
||||
raise Gem::OptionParser::InvalidArgument, "unknown regexp option - #{o}"
|
||||
end
|
||||
else
|
||||
s ||= all
|
||||
end
|
||||
Regexp.new(s || all, f, k)
|
||||
Regexp.new(s, f)
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -2276,8 +2298,8 @@ XXX
|
|||
# rescue Gem::OptionParser::ParseError
|
||||
# end
|
||||
#
|
||||
def getopts(*args)
|
||||
options.getopts(self, *args)
|
||||
def getopts(*args, symbolize_names: false)
|
||||
options.getopts(self, *args, symbolize_names: symbolize_names)
|
||||
end
|
||||
|
||||
#
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue