Sha256: 52c51c9da9a1894ffaea131323922e8ba2336e0fbd5300c63dc8fea4091b1092
Contents?: true
Size: 550 Bytes
Versions: 44
Compression:
Stored size: 550 Bytes
Contents
module DownloadHelper 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
44 entries across 22 versions & 1 rubygems