summaryrefslogtreecommitdiff
blob: 0794df356cc23179a5e566fd14ec52ae9913aca3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/ruby

MIRROR_DATA="https://api.gentoo.org/mirrors/distfiles.xml"

%w[ rexml/document open-uri ].each {|lib| require lib }

m = URI.parse(MIRROR_DATA).read
x = REXML::Document.new(m)

REXML::XPath.each(x, '//*/mirrorgroup[@country]') {|el|
  country = el.attributes['country']

  el.each_element('mirror/uri/') do |mirror|
    puts "#{country.downcase} #{mirror[0].to_s}"
  end

}