module Ftpmock::PutHelper

Public Instance Methods

cached?(cache_path, remotefile) click to toggle source
# File lib/ftpmock/helpers/put_helper.rb, line 5
def cached?(cache_path, remotefile)
  path = path_for(cache_path, remotefile)
  path.exist?
end
compare(cache_path, localfile, remotefile) click to toggle source

Array

# File lib/ftpmock/helpers/put_helper.rb, line 20
def compare(cache_path, localfile, remotefile)
  return [] unless cached?(cache_path, remotefile)

  path = path_for(cache_path, remotefile)
  diff = StringUtils.diff(localfile, path)
  diff.split("\n")
end
exist?(localfile) click to toggle source
# File lib/ftpmock/helpers/put_helper.rb, line 10
def exist?(localfile)
  File.exist?(localfile)
end
path_for(cache_path, remotefile) click to toggle source

def expire(cache_path, remotefile)

path = path_for(cache_path, remotefile)
path.exist? && path.delete

end

# File lib/ftpmock/helpers/put_helper.rb, line 33
def path_for(cache_path, remotefile)
  path = cache_path.join('put')
  FileUtils.mkdir_p(path)
  path.join(remotefile.tr('/', '-'))
end
write(cache_path, localfile, remotefile) click to toggle source
# File lib/ftpmock/helpers/put_helper.rb, line 14
def write(cache_path, localfile, remotefile)
  path = path_for(cache_path, remotefile)
  FileUtils.cp(localfile, path)
end