Class: Omnibus::FileFetcher
- Defined in:
- lib/omnibus/fetchers/file_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 file checksum is different than the path file checksum.
-
#version_for_cache ⇒ String
The version for this item in the cache.
-
#version_guid ⇒ String
The version identifier for this file.
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/file_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/file_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/file_fetcher.rb', line 60 def fetch log.info(log_key) { "Copying from `#{source_file}'" } create_required_directories FileUtils.cp(source_file, target_file) # Reset target shasum on every fetch @target_shasum = nil target_shasum end |
#fetch_required? ⇒ true, false
Fetch if the local file checksum is different than the path file checksum.
27 28 29 |
# File 'lib/omnibus/fetchers/file_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 file 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/file_fetcher.rb', line 80 def version_for_cache "file:#{source_file}|shasum:#{destination_shasum}" end |
#version_guid ⇒ String
The version identifier for this file. This is computed using the file on disk to the source and the shasum of that file on disk.
37 38 39 |
# File 'lib/omnibus/fetchers/file_fetcher.rb', line 37 def version_guid "file:#{source_file}" end |