class Bundler::Settings::Mirrors - bundler-1.15.4 Documentation

# 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

new(prober = nil) click to toggle source

    # File lib/bundler/mirror.rb, line 10
    def initialize(prober = nil)
      @all = Mirror.new
      @prober = prober || TCPSocketProbe.new
      @mirrors = {}
    end

### Public Instance Methods

each() { |k, uri.to_s| ... } click to toggle source

    # File lib/bundler/mirror.rb, line 28
    def each
      @mirrors.each do |k, v|
        yield k, v.uri.to_s
      end
    end

for(uri) click to toggle source

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 20
    def for(uri)
      if @all.validate!(@prober).valid?
        @all
      else
        fetch_valid_mirror_for(Settings.normalize_uri(uri))
      end
    end

parse(key, value) click to toggle source

    # File lib/bundler/mirror.rb, line 34
    def parse(key, value)
      config = MirrorConfig.new(key, value)
      mirror = if config.all?
        @all
      else
        (@mirrors[config.uri] = @mirrors[config.uri] || Mirror.new)
      end
      config.update_mirror(mirror)
    end

### Private Instance Methods

fetch_valid_mirror_for(uri) click to toggle source

    # File lib/bundler/mirror.rb, line 46
    def fetch_valid_mirror_for(uri)
      mirror = (@mirrors[URI(uri.to_s.downcase)] || @mirrors[URI(uri.to_s).host] || Mirror.new(uri)).validate!(@prober)
      mirror = Mirror.new(uri) unless mirror.valid?
      mirror
    end