Class: Bundler::Settings::Mirrors

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/mirror.rb

Overview

Class used to build the mirror set and then find a mirror for a given URI

Instance Method Summary collapse

Constructor Details

#initialize(prober = nil) ⇒ Mirrors

Returns a new instance of Mirrors.



12
13
14
15
16
# File 'lib/bundler/mirror.rb', line 12

def initialize(prober = nil)
  @all = Mirror.new
  @prober = prober || TCPSocketProbe.new
  @mirrors = {}
end

Instance Method Details

#eachObject



30
31
32
33
34
# File 'lib/bundler/mirror.rb', line 30

def each
  @mirrors.each do |k, v|
    yield k, v.uri.to_s
  end
end

#for(uri) ⇒ Object

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


22
23
24
25
26
27
28
# 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) ⇒ Object



36
37
38
39
40
41
42
43
44
# 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