class Bundler::Settings::Mirrors
用于构建镜像集,然后为给定的 URI
查找镜像的类。
@param prober [Prober 对象, nil] 默认情况下是 TCPSocketProbe
,此对象
will be used to probe the mirror address to validate that the mirror replies.
公共类方法
new(prober = nil) 单击以切换源代码
# File bundler/mirror.rb, line 12 def initialize(prober = nil) @all = Mirror.new @prober = prober || TCPSocketProbe.new @mirrors = {} end
公共实例方法
each() { |k, uri.to_s| ... } 单击以切换源代码
# File bundler/mirror.rb, line 30 def each @mirrors.each do |k, v| yield k, v.uri.to_s end end
for(uri) 单击以切换源代码
为给定的 URI 返回一个镜像。
根据 URI 是否有有效的镜像,它可能是一个
mirror that points to the provided uri
# File 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
parse(key, value) 单击以切换源代码
# File 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
私有实例方法
fetch_valid_mirror_for(uri) 单击以切换源代码
# File bundler/mirror.rb, line 48 def fetch_valid_mirror_for(uri) downcased = uri.to_s.downcase mirror = @mirrors[downcased] || @mirrors[Gem::URI(downcased).host] || Mirror.new(uri) mirror.validate!(@prober) mirror = Mirror.new(uri) unless mirror.valid? mirror end