Class: Oddb2xml::ZurroseDownloader

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

Instance Attribute Summary

Attributes inherited from Downloader

#agent, #type, #url

Instance Method Summary collapse

Methods inherited from Downloader

#init, #initialize, #report_download

Constructor Details

This class inherits a constructor from Oddb2xml::Downloader

Instance Method Details

#downloadObject



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/oddb2xml/downloader.rb', line 155

def download
  @url ||= 'http://pillbox.oddb.org/TRANSFER.ZIP'
  zipfile = File.join(WorkDir, 'transfer.zip')
  download_as(zipfile)
  dest = File.join(Downloads, 'transfer.dat')
  cmd = "unzip -o '#{zipfile}' -d '#{Downloads}'"
  system(cmd)
  if @options[:artikelstamm]
    cmd = "iconv -f ISO8859-1 -t utf-8 -o #{dest.sub('.dat','.utf8')} #{dest}"
    Oddb2xml.log(cmd)
    system(cmd)
  end
  # read file and convert it to utf-8
  File.open(dest, 'r:iso-8859-1:utf-8').read
ensure
  FileUtils.rm(zipfile) if File.exist?(dest) && File.exist?(zipfile)
end