class Imagemaster3000::Utils::Tmp

Public Class Methods

destroy(file) click to toggle source
# File lib/imagemaster3000/utils/tmp.rb, line 16
def self.destroy(file)
  return unless file

  logger.debug "Closing tempfile #{file.path.inspect}"
  file.close
  file.unlink
end
download(url) click to toggle source
# File lib/imagemaster3000/utils/tmp.rb, line 6
def self.download(url)
  file = Tempfile.new('imagemaster3000')
  logger.debug "Downloading file from url #{url} to tempfile #{file.path.inspect}"
  download = URI.parse(url).open
  IO.copy_stream(download, file)

  file.rewind
  file
end