module Ftpmock::GetHelper

Public Instance Methods

fetched?(localfile) click to toggle source
# File lib/ftpmock/helpers/get_helper.rb, line 34
def fetched?(localfile)
  File.exist?(localfile)
end
path_for(cache_path, remotefile) click to toggle source
# File lib/ftpmock/helpers/get_helper.rb, line 38
def path_for(cache_path, remotefile)
  path = cache_path.join('get')
  remotefile = PathHelper.simplify(remotefile)
  ret = path.join(remotefile)
  FileUtils.mkdir_p(ret.dirname.to_s)
  ret
end
read(cache_path, chdir, remotefile, localfile) click to toggle source

reads from cache to localfile

true/false

# File lib/ftpmock/helpers/get_helper.rb, line 8
def read(cache_path, chdir, remotefile, localfile)
  # chdir =
  remotefile = PathHelper.join(PathHelper.simplify(chdir), remotefile).to_s
  # localfile = PathHelper.join(chdir, localfile).to_s

  cached_path = path_for(cache_path, remotefile)

  File.exist?(cached_path) && FileUtils.cp(cached_path, localfile)

  fetched?(localfile)
end
write(cache_path, chdir, remotefile, localfile) click to toggle source

writes to cache from localfile

# File lib/ftpmock/helpers/get_helper.rb, line 21
def write(cache_path, chdir, remotefile, localfile)
  return false unless File.exist?(localfile)

  # chdir =
  remotefile = PathHelper.join(PathHelper.simplify(chdir), remotefile).to_s
  # localfile = PathHelper.join(chdir, localfile).to_s

  cached_path = path_for(cache_path, remotefile)
  FileUtils.cp(localfile, cached_path)

  File.exist?(cached_path)
end