123456789_123456789_123456789_123456789_123456789_

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

Instance Method Summary

Constructor Details

.new(prober = nil) ⇒ Mirrors

[ GitHub ]

  
# 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 ]

  
# File 'lib/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

#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
[ GitHub ]

  
# 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