class Oddb2xml::SwissmedicInfoDownloader

Public Instance Methods

download() click to toggle source
# File lib/oddb2xml/downloader.rb, line 353
def download
  file = File.join(DOWNLOADS, "swissmedic_info.zip")
  report_download(@url, file)
  FileUtils.rm_f(file, verbose: true) unless Oddb2xml.skip_download?
  unless File.exist?(file)
    begin
      response = nil
      if (home = @agent.get(@url))
        form = home.form_with(id: "Form1")
        bttn = form.button_with(name: "ctl00$MainContent$btnOK")
        if (page = form.submit(bttn))
          form = page.form_with(id: "Form1")
          bttn = form.button_with(name: "ctl00$MainContent$BtnYes")
          response = form.submit(bttn)
        end
      end
      if response
        response.save_as(file)
        response = nil # win
      end
    rescue Timeout::Error, Errno::ETIMEDOUT
      retrievable? ? retry : raise
    rescue NoMethodError
      # pass
    ensure
      Oddb2xml.download_finished(file)
    end
  end
  read_xml_from_zip(/^AipsDownload_/iu, file)
end
init() click to toggle source
Calls superclass method Oddb2xml::Downloader#init
# File lib/oddb2xml/downloader.rb, line 347
def init
  super
  @agent.ignore_bad_chunking = true
  @url ||= "http://download.swissmedicinfo.ch/Accept.aspx?ReturnUrl=%2f"
end