lib/bundler/mirror.rb in bundler-1.15.4 vs lib/bundler/mirror.rb in bundler-1.16.0.pre.1
- old
+ new
@@ -1,6 +1,7 @@
# frozen_string_literal: true
+
require "socket"
module Bundler
class Settings
# Class used to build the mirror set and then find a mirror for a given URI
@@ -35,19 +36,21 @@
def parse(key, value)
config = MirrorConfig.new(key, value)
mirror = if config.all?
@all
else
- (@mirrors[config.uri] = @mirrors[config.uri] || Mirror.new)
+ @mirrors[config.uri] ||= Mirror.new
end
config.update_mirror(mirror)
end
private
def fetch_valid_mirror_for(uri)
- mirror = (@mirrors[URI(uri.to_s.downcase)] || @mirrors[URI(uri.to_s).host] || Mirror.new(uri)).validate!(@prober)
+ downcased = uri.to_s.downcase
+ mirror = @mirrors[downcased] || @mirrors[URI(downcased).host] || Mirror.new(uri)
+ mirror.validate!(@prober)
mirror = Mirror.new(uri) unless mirror.valid?
mirror
end
end
@@ -115,10 +118,10 @@
class MirrorConfig
attr_accessor :uri, :value
def initialize(config_line, value)
uri, fallback =
- config_line.match(%r{^mirror\.(all|.+?)(\.fallback_timeout)?\/?$}).captures
+ config_line.match(%r{\Amirror\.(all|.+?)(\.fallback_timeout)?\/?\z}).captures
@fallback = !fallback.nil?
@all = false
if uri == "all"
@all = true
else