Module: SeleniumPrep::Downloader
- Extended by:
- Downloader
- Includes:
- URLs
- Included in:
- Downloader
- Defined in:
- lib/selenium-prep/downloader.rb
Constant Summary
Constants included from URLs
URLs::BASE_URL, URLs::DRIVERS, URLs::SERVER
Instance Method Summary collapse
Instance Method Details
#download ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/selenium-prep/downloader.rb', line 13 def download ConfigChecker.new hydra = Typhoeus::Hydra.new(max_concurrency: 3) urls.each do |url| file = file_for url download = File.open(file, 'wb') puts "[ #{Time.now} ] Downloading #{file}" request = Typhoeus::Request.new url request.on_body do |payload| download.write payload end request.on_complete do |response| download.close puts "[ #{Time.now} ] Finished downloading #{file}" end hydra.queue request end hydra.run end |