Class: Oddb2xml::BagXmlDownloader

Inherits:
Downloader show all
Defined in:
lib/oddb2xml/downloader.rb

Instance Method Summary collapse

Methods inherited from Downloader

#initialize

Constructor Details

This class inherits a constructor from Oddb2xml::Downloader

Instance Method Details

#downloadObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/oddb2xml/downloader.rb', line 33

def download
  file = 'XMLPublications.zip'
  begin
    response = Mechanize.new.get(@url)
    response.save_as file
    xml = ''
    Zip::ZipFile.foreach(file) do |entry|
      if entry.name =~ /^Preparation/iu
        entry.get_input_stream{ |io| xml = io.read }
      end
    end
    return xml
  rescue Timeout::Error
    retrievable? ? retry : raise
  ensure
    if File.exists? file
      File.unlink file
    end
  end
end

#initObject



30
31
32
# File 'lib/oddb2xml/downloader.rb', line 30

def init
  @url ||= 'http://bag.e-mediat.net/SL2007.Web.External/File.axd?file=XMLPublications.zip'
end