Sha256: 31a21f666905397115b4a5a04647e110110e95e7c64dc84a3eefc7e52ee1a45c

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

require 'nokogiri'

module RankMirror
	class RemoteFedora
		def initialize(options)
			@mirrors = Array.new
			@options = options
		end

		def fetch
			cache = RankMirror::Cache.new("https://admin.fedoraproject.org/mirrormanager/mirrors").fetch
			doc = Nokogiri::HTML(open(cache))
			doc.xpath("//tr").each do |tr|
				country = tr.element_children[0].content.downcase!
				unless country == "country" || @options.country != country
					tr.element_children[3].element_children.each do |a|
						if a.content == "http"
							if @options.os == "fedora"
								unless a["href"].index("epel")
									status = RankMirror::Status.new(a["href"],@options.os).get
									@mirrors << a["href"] if status[@options.flavor] == true
								end
							else
								if a["href"].index("epel")
									# neu.edu.cn has a wrong epel url on fedora mirror site
									uri = a["href"].index("neu.edu.cn") ? a["href"].sub("fedora/epel","fedora-epel") : a["href"]
									status = RankMirror::Status.new(uri,@options.os).get
									@mirrors << a["href"] if status[@options.flavor] == true
								end
							end
						end
					end
				end
			end
			return @mirrors
		end
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rankmirror-1.1.0 lib/rankmirror/distro/remote/fedora.rb