Module: Sources::CLDR::Downloader
- Defined in:
- lib/countries/sources/cldr/downloader.rb
Class Method Summary collapse
Class Method Details
.download_folder(type) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/countries/sources/cldr/downloader.rb', line 14 def download_folder(type) folder = File.join(ISO3166_ROOT_PATH, 'tmp', 'cldr', 'trunk', 'common', type) FileUtils.mkdir_p(folder) doc = Nokogiri::HTML get(type + '/') doc.css('a[href]').map { |e| e.attributes['href'].value }.each do |href| next if href == '../' File.write(File.join(folder, href), get([type, href].join('/'))) end end |
.get(path) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/countries/sources/cldr/downloader.rb', line 24 def get(path) url = URI("http://www.unicode.org/repos/cldr/trunk/common/#{path}") http = Net::HTTP.new(url.host, url.port) request = Net::HTTP::Get.new(url) response = http.request(request) response.read_body end |
.subdivisions ⇒ Object
10 11 12 |
# File 'lib/countries/sources/cldr/downloader.rb', line 10 def subdivisions download_folder('subdivisions') end |