Class: AppleEpf::DownloadProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/apple_epf/download_processor.rb

Direct Known Subclasses

AriaDownloadProcessor, CurbDownloadProcessor

Instance Method Summary collapse

Constructor Details

#initialize(apple_filename_full, download_to) ⇒ DownloadProcessor

Returns a new instance of DownloadProcessor.



4
5
6
7
# File 'lib/apple_epf/download_processor.rb', line 4

def initialize(apple_filename_full, download_to)
  @apple_filename_full = apple_filename_full
  @download_to = download_to
end

Instance Method Details

#download_and_checkObject



9
10
11
# File 'lib/apple_epf/download_processor.rb', line 9

def download_and_check
  raise 'should be implemented in subclass'
end

#get_file_md5Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/apple_epf/download_processor.rb', line 13

def get_file_md5
  begin
    curl = Curl::Easy.new("#{@apple_filename_full}.md5")
    curl.http_auth_types = :basic
    curl.username = AppleEpf.apple_id
    curl.password = AppleEpf.apple_password
    curl.perform
    @md5_checksum = curl.body_str.match(/.*=(.*)/)[1].strip
  rescue NoMethodError
    raise AppleEpf::Md5CompareError.new('Md5 of downloaded file is not the same as apple provide')
  end
end