Class: RankMirror::RemoteOSS
- Inherits:
-
Object
- Object
- RankMirror::RemoteOSS
- Defined in:
- lib/rankmirror/distro/remote/oss.rb
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(options) ⇒ RemoteOSS
constructor
A new instance of RemoteOSS.
Constructor Details
#initialize(options) ⇒ RemoteOSS
Returns a new instance of RemoteOSS.
5 6 7 8 9 |
# File 'lib/rankmirror/distro/remote/oss.rb', line 5 def initialize() @mirrors = [] @continent = "" @options = end |
Instance Method Details
#fetch ⇒ Object
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 |
# File 'lib/rankmirror/distro/remote/oss.rb', line 11 def fetch cache = RankMirror::Cache.new("http://mirrors.opensuse.org").fetch doc = Nokogiri::HTML(open(cache)) doc.root.element_children.last.element_children[-2].element_children[-1].element_children.each do |tr| unless tr.children[1].attribute("class").nil? @continent = tr.children[1].inner_text.delete!(":").delete("\s").downcase! else if @continent == @options.continent || @options.continent == "world" country = tr.children[1].inner_text.strip! unless country.nil? tumbleweed = tr.children[15].children[0].nil? ? false : true leap4220 = tr.children[17].children[0].nil? ? false : true leap4210 = tr.children[27].children[0].nil? ? false : true ftpobj = tr.children[7].children[0] ftp = ftpobj.nil? ? nil : ftpobj.attribute("href").inner_text httpobj = tr.children[5].children[0] http = httpobj.nil? ? ftp : httpobj.attribute("href").inner_text unless leap4210 || leap4220 || tumbleweed status = RankMirror::Status.new(http,@options.os).get unless status.nil? tumbleweed = status["tumbleweed"] leap4220 = status["leap4220"] leap4210 = status["leap4210"] end end @mirrors << http if eval(@options.flavor) end end end end return @mirrors end |