Class: Omnibus::PathFetcher
- Defined in:
- lib/omnibus/fetchers/path_fetcher.rb
Constant Summary
Constants included from Util
Instance Attribute Summary
Attributes inherited from Fetcher
#build_dir, #described_version, #name, #project_dir, #resolved_version, #source
Class Method Summary collapse
Instance Method Summary collapse
-
#clean ⇒ true, false
Clean the given path by removing the project directory.
-
#fetch ⇒ void
Fetch any new files by copying them to the
project_dir
. -
#fetch_required? ⇒ true, false
Fetch if the local directory checksum is different than the path directory checksum.
-
#version_for_cache ⇒ String
The version for this item in the cache.
-
#version_guid ⇒ String
The version identifier for this path.
Methods inherited from Fetcher
#fetcher, #initialize, #version
Methods included from Util
#compiler_safe_path, #copy_file, #create_directory, #create_file, #create_link, included, #path_key, #remove_directory, #remove_file, #retry_block, #shellout, #shellout!, #windows_safe_path
Methods included from Logging
Methods included from Digestable
#digest, #digest_directory, included
Constructor Details
This class inherits a constructor from Omnibus::Fetcher
Class Method Details
.resolve_version(version, source) ⇒ String?
87 88 89 |
# File 'lib/omnibus/fetchers/path_fetcher.rb', line 87 def self.resolve_version(version, source) version end |
Instance Method Details
#clean ⇒ true, false
Clean the given path by removing the project directory.
51 52 53 |
# File 'lib/omnibus/fetchers/path_fetcher.rb', line 51 def clean true end |
#fetch ⇒ void
This method returns an undefined value.
Fetch any new files by copying them to the project_dir
.
60 61 62 63 64 65 66 67 68 |
# File 'lib/omnibus/fetchers/path_fetcher.rb', line 60 def fetch log.info(log_key) { "Copying from `#{source_path}'" } create_required_directories FileSyncer.sync(source_path, project_dir, ) # Reset target shasum on every fetch @target_shasum = nil target_shasum 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_cache ⇒ String
The version for this item in the cache. The is the shasum of the directory on disk.
This method is called before clean but after fetch. Since fetch automatically cleans, target vs. destination sha doesn’t matter. Change this if that assumption changes.
80 81 82 |
# File 'lib/omnibus/fetchers/path_fetcher.rb', line 80 def version_for_cache "path:#{source_path}|shasum:#{destination_shasum}" end |
#version_guid ⇒ String
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 |