module Chef::Steel::FileTools

Public Instance Methods

clean_up(tmp_dir) click to toggle source

Remove the temporary directory using a naive guard to ensure we're deleting what we expect.

# File lib/chef/steel/filetools.rb, line 25
def clean_up(tmp_dir)
  info "\nCleaning up temporary directory '#{tmp_dir}"
  re_tmp_dir = Regexp.new('chef-steel')
  FileUtils.rm_rf(tmp_dir) if tmp_dir.match(re_tmp_dir)
end
copy_file(src, dst) click to toggle source

Copy a file from its source to its destination.

# File lib/chef/steel/filetools.rb, line 19
def copy_file(src, dst)
  FileUtils.cp(src, dst)
end
same_file?(local_file, remote_file) click to toggle source

Compare two files' digests to determine if they're the same file. Returns true/false based on the comparison of digest strings.

# File lib/chef/steel/filetools.rb, line 12
def same_file?(local_file, remote_file)
  local_digest = Digest::SHA256.file(local_file).hexdigest
  remote_digest = Digest::SHA256.file(remote_file).hexdigest
  local_digest == remote_digest
end