Class: Oddb2xml::BagXmlDownloader
Instance Method Summary
collapse
Methods inherited from Downloader
#initialize
Instance Method Details
#download ⇒ Object
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
|
#init ⇒ Object
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
|