class Omnibus::PathFetcher

Public Class Methods

resolve_version(version, source) click to toggle source

@return [String, nil]

# File lib/omnibus/fetchers/path_fetcher.rb, line 87
def self.resolve_version(version, source)
  version
end

Public Instance Methods

clean() click to toggle source

Clean the given path by removing the project directory.

@return [true, false]

true if the directory was cleaned, false otherwise.
Since we do not currently use the cache to sync files and
always fetch from source, there is no need to clean anything.
The fetch step (which needs to be called before clean) would
have already removed anything extraneous.
# File lib/omnibus/fetchers/path_fetcher.rb, line 51
def clean
  true
end
fetch() click to toggle source

Fetch any new files by copying them to the project_dir.

@return [void]

# 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, source_options)
  # Reset target shasum on every fetch
  @target_shasum = nil
  target_shasum
end
fetch_required?() click to toggle source

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

@return [true, false]

# File lib/omnibus/fetchers/path_fetcher.rb, line 27
def fetch_required?
  target_shasum != destination_shasum
end
version_for_cache() click to toggle source

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.

@return [String]

# File lib/omnibus/fetchers/path_fetcher.rb, line 80
def version_for_cache
  "path:#{source_path}|shasum:#{destination_shasum}"
end
version_guid() click to toggle source

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.

@return [String]

# File lib/omnibus/fetchers/path_fetcher.rb, line 37
def version_guid
  "path:#{source_path}"
end

Private Instance Methods

destination_shasum() click to toggle source

The shasum of the directory outside of the project.

@return [String]

# File lib/omnibus/fetchers/path_fetcher.rb, line 129
def destination_shasum
  @destination_shasum ||= digest_directory(source_path, :sha256, source_options)
end
source_options() click to toggle source

Options to pass to the underlying FileSyncer

@return [Hash]

# File lib/omnibus/fetchers/path_fetcher.rb, line 107
def source_options
  if source[:options] && source[:options].is_a?(Hash)
    source[:options]
  else
    {}
  end
end
source_path() click to toggle source

The path on disk to pull the files from.

@return [String]

# File lib/omnibus/fetchers/path_fetcher.rb, line 98
def source_path
  source[:path]
end
target_shasum() click to toggle source

The shasum of the directory inside the project.

@return [String]

# File lib/omnibus/fetchers/path_fetcher.rb, line 120
def target_shasum
  @target_shasum ||= digest_directory(project_dir, :sha256, source_options)
end