On this page
class Bundler::Settings::Mirrors
Class
used to build the mirror set and then find a mirror for a given URI
@param prober [Prober object, nil] by default a TCPSocketProbe
, this object
will be used to probe the mirror address to validate that the mirror replies.
Public Class Methods
# File lib/bundler/mirror.rb, line 12
def initialize(prober = nil)
@all = Mirror.new
@prober = prober || TCPSocketProbe.new
@mirrors = {}
end
Public Instance Methods
# File lib/bundler/mirror.rb, line 30
def each
@mirrors.each do |k, v|
yield k, v.uri.to_s
end
end
# File lib/bundler/mirror.rb, line 22
def for(uri)
if @all.validate!(@prober).valid?
@all
else
fetch_valid_mirror_for(Settings.normalize_uri(uri))
end
end
Returns a mirror for the given uri.
Depending on the uri having a valid mirror or not, it may be a
mirror that points to the provided uri
# File lib/bundler/mirror.rb, line 36
def parse(key, value)
config = MirrorConfig.new(key, value)
mirror = if config.all?
@all
else
@mirrors[config.uri] ||= Mirror.new
end
config.update_mirror(mirror)
end
Private Instance Methods
# File lib/bundler/mirror.rb, line 48
def fetch_valid_mirror_for(uri)
downcased = uri.to_s.downcase
mirror = @mirrors[downcased] || @mirrors[URI(downcased).host] || Mirror.new(uri)
mirror.validate!(@prober)
mirror = Mirror.new(uri) unless mirror.valid?
mirror
end
Ruby Core © 1993–2017 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.