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

#build_dir, #described_version, #name, #project_dir, #resolved_version, #source

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Fetcher

#fetcher, #initialize, #version

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, included

Constructor Details

This class inherits a constructor from Omnibus::Fetcher

Class Method Details

.resolve_version(version, source) ⇒ String?

Returns:

  • (String, nil)


86
87
88
# File 'lib/omnibus/fetchers/path_fetcher.rb', line 86

def self.resolve_version(version, source)
  version
end

Instance Method Details

#cleantrue, false

Clean the given path by removing the project directory.

Returns:

  • (true, false)

    true if the directory was cleaned, false otherwise



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
69
70
71
# 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, source_options)
  # 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.

Returns:

  • (true, false)


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.

Returns:

  • (String)


79
80
81
# File 'lib/omnibus/fetchers/path_fetcher.rb', line 79

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.

Returns:

  • (String)


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

def version_guid
  "path:#{source_path}"
end