Class: PackerFiles::Debian::Mirrors

Inherits:
Object
  • Object
show all
Defined in:
lib/PackerFiles/OS/Debian/Mirrors.rb

Constant Summary collapse

@@default =

default debian mirror

'http://mirrors.kernel.org/debian'
@@mirrors =

Default debian mirror list

'https://www.debian.org/mirror/list'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMirrors

Constructor



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/PackerFiles/OS/Debian/Mirrors.rb', line 26

def initialize

   # A Single web page get more than this (in seconds) is SLOW  
   limit   = 1 

   # No. of trials for a web page
   trials  = 4  
   
	 # Get the name of the http proxy
	 @proxy   = ENV['http_proxy'] 

   # Get the host list of mirrors for this country
   code     = Utils::AutoZone.new.country_code.downcase
   @hosts   = country_mirror(code)
	 if @hosts.empty?
	    @hosts   = [@@default] if @hosts.empty?
	    @best    = URI::parse(@@default)
	 else
	    f        = Utils::FastestURL.new(limit, trials)
	    all      = f.best_urls(@hosts).flatten
	    begin 
  @best    = URI::parse(all.first)
	    rescue Exception => e
  puts "Exception: #{e}, All: #{all.to_s}"
  raise e
	    end
	 end
end

Instance Attribute Details

#bestObject (readonly)

Returns the value of attribute best.



22
23
24
# File 'lib/PackerFiles/OS/Debian/Mirrors.rb', line 22

def best
  @best
end

#hostsObject (readonly)

accessors



21
22
23
# File 'lib/PackerFiles/OS/Debian/Mirrors.rb', line 21

def hosts
  @hosts
end

#proxyObject (readonly)

Returns the value of attribute proxy.



23
24
25
# File 'lib/PackerFiles/OS/Debian/Mirrors.rb', line 23

def proxy
  @proxy
end