Skip to content

Commit f1201bc

Browse files
hsbtmatzbot
authored andcommitted
[ruby/rubygems] Update vendored resolv to 0.7.0
ruby/rubygems@844a05543b
1 parent 5ebccee commit f1201bc

1 file changed

Lines changed: 30 additions & 14 deletions

File tree

lib/rubygems/vendor/resolv/lib/resolv.rb

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require_relative '../../../vendored_timeout'
55
require 'io/wait'
66
require_relative '../../../vendored_securerandom'
7+
require 'rbconfig'
78

89
# Gem::Resolv is a thread-aware DNS resolver library written in Ruby. Gem::Resolv can
910
# handle multiple DNS requests concurrently without blocking the entire Ruby
@@ -33,7 +34,8 @@
3334

3435
class Gem::Resolv
3536

36-
VERSION = "0.6.2"
37+
# The version string
38+
VERSION = "0.7.0"
3739

3840
##
3941
# Looks up the first IP address for +name+.
@@ -173,21 +175,19 @@ class ResolvError < StandardError; end
173175

174176
class ResolvTimeout < Gem::Timeout::Error; end
175177

176-
WINDOWS = /mswin|cygwin|mingw|bccwin/ =~ RUBY_PLATFORM || ::RbConfig::CONFIG['host_os'] =~ /mswin/
177-
private_constant :WINDOWS
178-
179178
##
180179
# Gem::Resolv::Hosts is a hostname resolver that uses the system hosts file.
181180

182181
class Hosts
183-
if WINDOWS
182+
if /mswin|cygwin|mingw|bccwin/ =~ RUBY_PLATFORM || ::RbConfig::CONFIG['host_os'] =~ /mswin/
184183
begin
185184
require 'win32/resolv' unless defined?(Win32::Resolv)
186-
DefaultFileName = Win32::Resolv.get_hosts_path || IO::NULL
185+
hosts = Win32::Resolv.get_hosts_path || IO::NULL
187186
rescue LoadError
188187
end
189188
end
190-
DefaultFileName ||= '/etc/hosts'
189+
# The default file name for host names
190+
DefaultFileName = hosts || '/etc/hosts'
191191

192192
##
193193
# Creates a new Gem::Resolv::Hosts, using +filename+ for its data source.
@@ -525,6 +525,8 @@ def each_resource(name, typeclass, &proc)
525525
}
526526
end
527527

528+
# :stopdoc:
529+
528530
def fetch_resource(name, typeclass)
529531
lazy_initialize
530532
truncated = {}
@@ -1021,8 +1023,7 @@ def Config.parse_resolv_conf(filename)
10211023
def Config.default_config_hash(filename="/etc/resolv.conf")
10221024
if File.exist? filename
10231025
Config.parse_resolv_conf(filename)
1024-
elsif WINDOWS
1025-
require 'win32/resolv' unless defined?(Win32::Resolv)
1026+
elsif defined?(Win32::Resolv)
10261027
search, nameserver = Win32::Resolv.get_resolv_info
10271028
config_hash = {}
10281029
config_hash[:nameserver] = nameserver if nameserver
@@ -2926,15 +2927,21 @@ class HTTPS < ServiceBinding
29262927

29272928
class IPv4
29282929

2929-
##
2930-
# Regular expression IPv4 addresses must match.
2931-
29322930
Regex256 = /0
29332931
|1(?:[0-9][0-9]?)?
29342932
|2(?:[0-4][0-9]?|5[0-5]?|[6-9])?
2935-
|[3-9][0-9]?/x
2933+
|[3-9][0-9]?/x # :nodoc:
2934+
2935+
##
2936+
# Regular expression IPv4 addresses must match.
29362937
Regex = /\A(#{Regex256})\.(#{Regex256})\.(#{Regex256})\.(#{Regex256})\z/
29372938

2939+
##
2940+
# Creates a new IPv4 address from +arg+ which may be:
2941+
#
2942+
# IPv4:: returns +arg+.
2943+
# String:: +arg+ must match the IPv4::Regex constant
2944+
29382945
def self.create(arg)
29392946
case arg
29402947
when IPv4
@@ -3243,13 +3250,15 @@ def make_udp_requester # :nodoc:
32433250

32443251
end
32453252

3246-
module LOC
3253+
module LOC # :nodoc:
32473254

32483255
##
32493256
# A Gem::Resolv::LOC::Size
32503257

32513258
class Size
32523259

3260+
# Regular expression LOC size must match.
3261+
32533262
Regex = /^(\d+\.*\d*)[m]$/
32543263

32553264
##
@@ -3275,6 +3284,7 @@ def self.create(arg)
32753284
end
32763285
end
32773286

3287+
# Internal use; use self.create.
32783288
def initialize(scalar)
32793289
@scalar = scalar
32803290
end
@@ -3312,6 +3322,8 @@ def hash # :nodoc:
33123322

33133323
class Coord
33143324

3325+
# Regular expression LOC Coord must match.
3326+
33153327
Regex = /^(\d+)\s(\d+)\s(\d+\.\d+)\s([NESW])$/
33163328

33173329
##
@@ -3341,6 +3353,7 @@ def self.create(arg)
33413353
end
33423354
end
33433355

3356+
# Internal use; use self.create.
33443357
def initialize(coordinates,orientation)
33453358
unless coordinates.kind_of?(String)
33463359
raise ArgumentError.new("Coord must be a 32bit unsigned integer in hex format: #{coordinates.inspect}")
@@ -3403,6 +3416,8 @@ def hash # :nodoc:
34033416

34043417
class Alt
34053418

3419+
# Regular expression LOC Alt must match.
3420+
34063421
Regex = /^([+-]*\d+\.*\d*)[m]$/
34073422

34083423
##
@@ -3428,6 +3443,7 @@ def self.create(arg)
34283443
end
34293444
end
34303445

3446+
# Internal use; use self.create.
34313447
def initialize(altitude)
34323448
@altitude = altitude
34333449
end

0 commit comments

Comments
 (0)