Class: Bundler::Settings::Mirrors
- Inherits:
-
Object
- Object
- Bundler::Settings::Mirrors
- 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
- #each ⇒ Object
-
#for(uri) ⇒ Object
Returns a mirror for the given uri.
-
#initialize(prober = nil) ⇒ Mirrors
constructor
A new instance of Mirrors.
- #parse(key, value) ⇒ Object
Constructor Details
#initialize(prober = nil) ⇒ Mirrors
Returns a new instance of Mirrors.
9 10 11 12 13 |
# File 'lib/bundler/mirror.rb', line 9 def initialize(prober = nil) @all = Mirror.new @prober = prober || TCPSocketProbe.new @mirrors = {} end |
Instance Method Details
#each ⇒ Object
27 28 29 30 31 |
# File 'lib/bundler/mirror.rb', line 27 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
19 20 21 22 23 24 25 |
# File 'lib/bundler/mirror.rb', line 19 def for(uri) if @all.validate!(@prober).valid? @all else fetch_valid_mirror_for(Settings.normalize_uri(uri)) end end |
#parse(key, value) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/bundler/mirror.rb', line 33 def parse(key, value) config = MirrorConfig.new(key, value) if config.all? mirror = @all else mirror = (@mirrors[config.uri] = @mirrors[config.uri] || Mirror.new) end config.update_mirror(mirror) end |