Class: Bundler::Settings::Mirrors
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/bundler/mirror.rb |
Overview
Class used to build the mirror set and then find a mirror for a given ::Bundler::URI
Class Method Summary
- .new(prober = nil) ⇒ Mirrors constructor
Instance Method Summary
- #each
-
#for(uri)
Returns a mirror for the given uri.
- #parse(key, value)
- #fetch_valid_mirror_for(uri) private
Constructor Details
.new(prober = nil) ⇒ Mirrors
# File 'lib/bundler/mirror.rb', line 12
def initialize(prober = nil) @all = Mirror.new @prober = prober || TCPSocketProbe.new @mirrors = {} end
Instance Method Details
#each
[ GitHub ]# File 'lib/bundler/mirror.rb', line 30
def each @mirrors.each do |k, v| yield k, v.uri.to_s end end
#fetch_valid_mirror_for(uri) (private)
[ GitHub ]#for(uri)
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 22
def for(uri) if @all.validate!(@prober).valid? @all else fetch_valid_mirror_for(Settings.normalize_uri(uri)) end end
#parse(key, value)
[ GitHub ]# 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