module SoManyDevices::DownloadsHelper

Constants

PATH
TIMEOUT

Public Instance Methods

clear_downloads() click to toggle source
# File lib/so_many_devices/downloads_helper.rb, line 33
def clear_downloads
  FileUtils.rm_f(downloads)
end
download() click to toggle source
# File lib/so_many_devices/downloads_helper.rb, line 10
def download
  downloads.first
end
download_content() click to toggle source
# File lib/so_many_devices/downloads_helper.rb, line 14
def download_content
  wait_for_download
  File.read(download)
end
downloaded?() click to toggle source
# File lib/so_many_devices/downloads_helper.rb, line 25
def downloaded?
  !downloading? && downloads.any?
end
downloading?() click to toggle source
# File lib/so_many_devices/downloads_helper.rb, line 29
def downloading?
  downloads.grep(/\.crdownload$/).any?
end
downloads() click to toggle source
# File lib/so_many_devices/downloads_helper.rb, line 6
def downloads
  Dir["#{PATH}/*"]
end
wait_for_download() click to toggle source
# File lib/so_many_devices/downloads_helper.rb, line 19
def wait_for_download
  Timeout.timeout(TIMEOUT) do
    sleep 0.1 until downloaded?
  end
end