Class: RankMirror::Status

Inherits:
Object
  • Object
show all
Defined in:
lib/rankmirror/status.rb

Instance Method Summary collapse

Constructor Details

#initialize(uri, distro) ⇒ Status

Returns a new instance of Status.



5
6
7
8
9
# File 'lib/rankmirror/status.rb', line 5

def initialize(uri,distro)
	uri << "/" unless /^.*\/$/.match(uri)
	@uri = uri
	@distro = distro
end

Instance Method Details

#getObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/rankmirror/status.rb', line 11

def get
	if RankMirror::Reachable.new(@uri,500).reachable?
		case @distro
		when "opensuse"
			tumbleweed = "tumbleweed/repo/oss/suse/repodata/"
			leap4220 = "distribution/leap/42.2/repo/oss/suse/repodata/"
			leap4210 = "distribution/leap/42.1/repo/oss/suse/repodata/"
			leap4230 = "distribution/leap/42.3/repo/oss/suse/repodata/"
			
			checklist = {"tumbleweed"=>tumbleweed,"leap4220"=>leap4220,"leap4210"=>leap4210,"leap4230"=>leap4230}
			mirror = OpenStruct.new
			
			checklist.each do |k,v|
				if RankMirror::Reachable.new(@uri + v,500).reachable?
					mirror[k] = true
				else
					mirror[k] = false
				end
			end
			return mirror
		when "packman"
			tumbleweed = "Tumbleweed"
			leap4220 = "Leap_42.2"
			leap4210 = "Leap_42.1"
			leap4230 = "Leap_42.3"
			checklist = {"tumbleweed"=>tumbleweed,"leap4220"=>leap4220,"leap4210"=>leap4210,"leap4230"=>leap4230}

			mirror = OpenStruct.new

			checklist.each do |k,v|
				if RankMirror::Reachable.new(@uri + "openSUSE_" + v + "/Essentials/repodata/",500).reachable?
					mirror[k] = true
				else
					mirror[k] = false
				end
			end
			return mirror
		when "fedora"
			mirror = OpenStruct.new
			check = ["20","21","22","23","24","25"]
			check.each do |k|
				if RankMirror::Reachable.new(@uri + "releases/" + k + "/Everything/x86_64/os/repodata/repomd.xml",500).reachable?
					mirror["fedora" + k] = true
				else
					mirror["fedora" + k] = false
				end
			end
			return mirror
		when "epel"
			mirror = OpenStruct.new
			check = ["4","5","6","7"]
			check.each do |k|
				if RankMirror::Reachable.new(@uri + "/" + k + "/x86_64/repodata/repomd.xml",500).reachable?
					mirror["epel" + k] = true
				else
					mirror["epel" + k] = false
				end
			end
			return mirror
		else
		end
	else
		return nil
	end
end