class MxxRu::Externals::Impl::WebDownloader
Constants
- SUPPORTED_DOWNLOADERS
Public Class Methods
downloader_option(downloader_id, *values)
click to toggle source
# File lib/mxx_ru/externals.rb, line 215 def WebDownloader.downloader_option(downloader_id, *values) @@downloader_options[downloader_id].push(*values) end
new()
click to toggle source
# File lib/mxx_ru/externals.rb, line 190 def initialize @downloader_type, @downloader_version = *detect_downloader_type if Rake.verbose puts "#{@downloader_type.downloader_id} v.#{@downloader_version} found" end end
preffered_downloader(downloader_id)
click to toggle source
# File lib/mxx_ru/externals.rb, line 206 def WebDownloader.preffered_downloader(downloader_id) found = SUPPORTED_DOWNLOADERS.find do |klass| downloader_id == klass.downloader_id ? klass : nil end raise "Unsupported downloader: #{downloader_id}" unless found @@preffered_downloaders.push(found) end
Public Instance Methods
make_downloader(options_holder)
click to toggle source
# File lib/mxx_ru/externals.rb, line 198 def make_downloader(options_holder) id = @downloader_type.downloader_id @downloader_type.new( merge_options( options_holder.downloader_options_for(id), @@downloader_options[id])) end
Private Instance Methods
detect_downloader_type()
click to toggle source
# File lib/mxx_ru/externals.rb, line 220 def detect_downloader_type r = search_downloader_in(@@preffered_downloaders) r = search_downloader_in(SUPPORTED_DOWNLOADERS) unless r raise "No web downloader found (curl, wget)" unless r r end
merge_options(head, tail)
click to toggle source
# File lib/mxx_ru/externals.rb, line 233 def merge_options(head, tail) r = head.dup r.push(*tail) end
search_downloader_in(sequence)
click to toggle source
# File lib/mxx_ru/externals.rb, line 227 def search_downloader_in(sequence) version = nil downloader = sequence.find {|klass| version = klass.check_presence} downloader ? [downloader, version] : nil end