Class: Omnibus::Fetcher

Inherits:
Object
  • Object
show all
Extended by:
Util
Includes:
Digestable, Logging, Util
Defined in:
lib/omnibus/fetcher.rb

Constant Summary

Constants included from Util

Util::SHELLOUT_OPTIONS

Instance Attribute Summary collapse

Abstract methods collapse

Instance Method Summary collapse

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

included

Methods included from Digestable

#digest, #digest_directory, included

Constructor Details

#initialize(manifest_entry, project_dir, build_dir) ⇒ Fetcher

Create a new Fetcher object from the given software.

The parameters correspond to the relevant portions of a software definition that a fetcher needs access to. This avoids strongly coupling the software object with all fetchers.

Parameters:

  • manifest_entry (ManifestEntry)
  • project_dir (String)
  • build_dir (String)

86
87
88
89
90
91
92
93
# File 'lib/omnibus/fetcher.rb', line 86

def initialize(manifest_entry, project_dir, build_dir)
  @name    = manifest_entry.name
  @source  = manifest_entry.locked_source
  @resolved_version = manifest_entry.locked_version
  @described_version = manifest_entry.described_version
  @project_dir = project_dir
  @build_dir = build_dir
end

Instance Attribute Details

#build_dirObject (readonly)

Returns the value of attribute build_dir


73
74
75
# File 'lib/omnibus/fetcher.rb', line 73

def build_dir
  @build_dir
end

#described_versionString (readonly)

The upstream version as described before resolution.

This will usually be the same as resolved_version but may refer toa remote ref name or tag for a source such as git.

Returns:

  • (String)

55
56
57
# File 'lib/omnibus/fetcher.rb', line 55

def described_version
  @described_version
end

#nameString (readonly)

The name of the software this fetcher shall fetch

Returns:

  • (String)

29
30
31
# File 'lib/omnibus/fetcher.rb', line 29

def name
  @name
end

#project_dirString (readonly)

The path where fetched software should live.

Only files under this directory are modified. If the source to fetch is a directory, it is staged rooted here. If it's a file, it's copied underneath this directory. If it's a tarball, it's extracted here. If it's a repo, its checkout is rooted here. You get the idea.

It's named project_dir instead of extract_dir/extract_path because of legacy reasons. This has nothing to do with project definitions or the underlying relative_path for a software definition (except for legacy behavior).

Returns:

  • (String)

72
73
74
# File 'lib/omnibus/fetcher.rb', line 72

def project_dir
  @project_dir
end

#resolved_versionString (readonly)

The exact upstream version that a fetcher should fetch.

For sources that allow aliases (branch name, tags, etc). Users should use the class method resolve_version to determine this before constructing a fetcher.

Returns:

  • (String)

46
47
48
# File 'lib/omnibus/fetcher.rb', line 46

def resolved_version
  @resolved_version
end

#sourceHash (readonly)

The source for this fetcher.

Returns:

  • (Hash)

36
37
38
# File 'lib/omnibus/fetcher.rb', line 36

def source
  @source
end

Instance Method Details

#cleanObject

This method is abstract.

Raises:

  • (NotImplementedError)

112
113
114
# File 'lib/omnibus/fetcher.rb', line 112

def clean
  raise NotImplementedError
end

#fetchObject

This method is abstract.

Raises:

  • (NotImplementedError)

119
120
121
# File 'lib/omnibus/fetcher.rb', line 119

def fetch
  raise NotImplementedError
end

#fetch_required?Boolean

This method is abstract.

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)

105
106
107
# File 'lib/omnibus/fetcher.rb', line 105

def fetch_required?
  raise NotImplementedError
end

#fetcherObject



141
142
143
# File 'lib/omnibus/fetcher.rb', line 141

def fetcher
  self
end

#versionObject

All fetchers should prefer resolved_version to version this is provided for compatibility.


149
150
151
# File 'lib/omnibus/fetcher.rb', line 149

def version
  resolved_version
end

#version_for_cacheObject

This method is abstract.

Raises:

  • (NotImplementedError)

133
134
135
# File 'lib/omnibus/fetcher.rb', line 133

def version_for_cache
  raise NotImplementedError
end

#version_guidObject

This method is abstract.

Raises:

  • (NotImplementedError)

126
127
128
# File 'lib/omnibus/fetcher.rb', line 126

def version_guid
  raise NotImplementedError
end