class CookbookOmnifetch::ArtifactserverLocation

def ==(other)

def ==(other)
  raise 'TODO'
  other.is_a?(GitLocation) &&
  other.uri == uri &&
  other.branch == branch &&
  other.tag == tag &&
  other.shortref == shortref &&
  other.rel == rel
end

def cache_key

def cache_key
  "#{dependency.name}-#{cookbook_version}-#{repo_host}"
end

def cache_path

Returns:
  • (Pathname) -
def cache_path
  cache_root.join("#{cache_key}.tgz")
end

def cache_root

Returns:
  • (Pathname) -
def cache_root
  Pathname.new(CookbookOmnifetch.cache_path).join('.cache', 'artifactserver')
end

def cached_cookbook

Returns:
  • (CachedCookbook) -
def cached_cookbook
  raise AbstractFunction,
    "#cached_cookbook must be implemented on #{self.class.name}!"
end

def cookbook_name

def cookbook_name
  dependency.name
end

def http_client(uri)

TODO: DI this.
def http_client(uri)
  Chef::HTTP::Simple.new(uri)
end

def initialize(dependency, options = {})

def initialize(dependency, options = {})
  super
  @uri ||= options[:artifactserver]
  @cookbook_version = options[:version]
end

def install

Returns:
  • (void) -
def install
  FileUtils.mkdir_p(cache_root) unless cache_root.exist?
  http = http_client(uri)
  http.streaming_request(nil) do |tempfile|
    tempfile.close
    FileUtils.mv(tempfile.path, cache_path)
  end
  FileUtils.mkdir_p(staging_root) unless staging_root.exist?
  Dir.mktmpdir(nil, staging_root) do |staging_dir|
    Zlib::GzipReader.open(cache_path) do |gz_file|
      tar = Archive::Tar::Minitar::Input.new(gz_file)
      tar.each do |e|
        tar.extract_entry(staging_dir, e)
      end
    end
    staged_cookbook_path = File.join(staging_dir, cookbook_name)
    validate_cached!(staged_cookbook_path)
    FileUtils.mv(staged_cookbook_path, install_path)
  end
end

def install_path

Returns:
  • (Pathname, nil) -
def install_path
  @install_path ||= CookbookOmnifetch.storage_path.join(cache_key)
end

def installed?

Returns:
  • (Boolean) -
def installed?
  install_path.exist?
end

def lock_data

def lock_data
  out = {}
  out['artifactserver'] = uri
  out['version'] = cookbook_version
  out
end

def repo_host

def repo_host
  @host ||= URI.parse(uri).host
end

def sanitized_version

def sanitized_version
  cookbook_version
end

def staging_root

Returns:
  • (Pathname) -
def staging_root
  Pathname.new(CookbookOmnifetch.cache_path).join('.cache_tmp', 'artifactserver')
end

def to_lock

Returns:
  • (string) -
def to_lock
  raise AbstractFunction,
    "#to_lock must be implemented on #{self.class.name}!"
end