Sha256: 29c53bddfb1c665e21cf2cfbfae19ecbfb2ffd211e935954decb76fef86ad5cc
Contents?: true
Size: 552 Bytes
Versions: 5
Compression:
Stored size: 552 Bytes
Contents
module DownloadHelpers TIMEOUT = 1 PATH = Rails.root.join("tmp/downloads") extend self def downloads Dir[PATH.join("*")] end def download downloads.first end def download_content wait_for_download File.read(download) end def wait_for_download Timeout.timeout(TIMEOUT) do sleep 0.1 until downloaded? end end def downloaded? !downloading? && downloads.any? end def downloading? downloads.grep(/\.part$/).any? end def clear_downloads FileUtils.rm_f(downloads) end end
Version data entries
5 entries across 5 versions & 1 rubygems