Class: MxxRu::Externals::Impl::WebDownloader
- Inherits:
-
Object
- Object
- MxxRu::Externals::Impl::WebDownloader
- Includes:
- Singleton
- Defined in:
- lib/mxx_ru/externals.rb
Constant Summary collapse
- SUPPORTED_DOWNLOADERS =
[WgetDownloder, CurlDownloder]
- @@preffered_downloaders =
[]
- @@downloader_options =
Hash.new{|h,k| h[k] = []}
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ WebDownloader
constructor
A new instance of WebDownloader.
- #make_downloader(options_holder) ⇒ Object
Constructor Details
#initialize ⇒ WebDownloader
Returns a new instance of WebDownloader.
190 191 192 193 194 195 196 |
# 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 |
Class Method Details
.downloader_option(downloader_id, *values) ⇒ Object
215 216 217 |
# File 'lib/mxx_ru/externals.rb', line 215 def WebDownloader.downloader_option(downloader_id, *values) @@downloader_options[downloader_id].push(*values) end |
.preffered_downloader(downloader_id) ⇒ Object
206 207 208 209 210 211 212 213 |
# 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 |
Instance Method Details
#make_downloader(options_holder) ⇒ Object
198 199 200 201 202 203 204 |
# File 'lib/mxx_ru/externals.rb', line 198 def make_downloader() id = @downloader_type.downloader_id @downloader_type.new( ( .(id), @@downloader_options[id])) end |