Class: Omnibus::PathFetcher

Inherits:
Fetcher
  • Object
show all
Defined in:
lib/omnibus/fetchers/path_fetcher.rb

Constant Summary

Constants included from Util

Util::SHELLOUT_OPTIONS

Instance Attribute Summary

Attributes inherited from Fetcher

#software

Instance Method Summary collapse

Methods inherited from Fetcher

#initialize

Methods included from Util

#copy_file, #create_directory, #create_file, #create_link, included, #remove_directory, #remove_file, #shellout, #shellout!, #windows_safe_path

Methods included from Logging

included

Methods included from Digestable

#digest, #digest_directory

Constructor Details

This class inherits a constructor from Omnibus::Fetcher

Instance Method Details

#cleantrue, false

Clean the given path by removing the project directory.


47
48
49
50
51
52
53
54
55
56
# File 'lib/omnibus/fetchers/path_fetcher.rb', line 47

def clean
  if File.exist?(project_dir)
    log.info(log_key) { "Cleaning project directory `#{project_dir}'" }
    FileUtils.rm_rf(project_dir)
    fetch
    true
  else
    false
  end
end

#fetchvoid

This method returns an undefined value.

Fetch any new files by copying them to the project_dir.


63
64
65
66
67
68
# File 'lib/omnibus/fetchers/path_fetcher.rb', line 63

def fetch
  log.info(log_key) { "Copying from `#{source_path}'" }

  create_required_directories
  FileSyncer.sync(source_path, project_dir)
end

#fetch_required?true, false

Fetch if the local directory checksum is different than the path directory checksum.


27
28
29
# File 'lib/omnibus/fetchers/path_fetcher.rb', line 27

def fetch_required?
  target_shasum != destination_shasum
end

#version_for_cacheString

The version for this item in the cache. The is the shasum of the directory on disk.


76
77
78
# File 'lib/omnibus/fetchers/path_fetcher.rb', line 76

def version_for_cache
  "path:#{source_path}|shasum:#{target_shasum}"
end

#version_guidString

The version identifier for this path. This is computed using the path on disk to the source and the recursive shasum of that path on disk.


37
38
39
# File 'lib/omnibus/fetchers/path_fetcher.rb', line 37

def version_guid
  "path:#{source_path}"
end