Sha256: f610d93f03e5cbccb06cc275b44ad5c57103d70b3a72150ac852125d7eb83363
Contents?: true
Size: 870 Bytes
Versions: 4
Compression:
Stored size: 870 Bytes
Contents
require 'fileutils' require 'open-uri' # a bunch of things that should never be called in testing due to side effects module Railsthemes class Utils # remove file only if it exists def self.remove_file filepath if File.exists?(filepath) File.delete filepath end end # copy a file, ensuring that the directory is present def self.copy_ensuring_directory_exists src, dest FileUtils.mkdir_p(File.dirname(dest)) # create directory if necessary FileUtils.cp src, dest end # would be nice to put download status in the output (speed, progress, etc.) def self.download_file_to url, save_to File.open(save_to, "wb") do |saved_file| # the following "open" is provided by open-uri open(url) do |read_file| saved_file.write(read_file.read) end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
railsthemes-1.0.3 | lib/railsthemes/utils.rb |
railsthemes-1.0.2 | lib/railsthemes/utils.rb |
railsthemes-1.0.1 | lib/railsthemes/utils.rb |
railsthemes-1.0.0 | lib/railsthemes/utils.rb |