class CookbookOmnifetch::ChefServerLocation

Attributes

cookbook_version[R]
uri[R]

Public Class Methods

new(dependency, options = {}) click to toggle source
Calls superclass method CookbookOmnifetch::BaseLocation::new
# File lib/cookbook-omnifetch/chef_server.rb, line 10
def initialize(dependency, options = {})
  super
  @cookbook_version = options[:version]
  @http_client = options[:http_client] || default_chef_server_http_client
  @uri ||= options[:chef_server]
end

Public Instance Methods

cache_key() click to toggle source
# File lib/cookbook-omnifetch/chef_server.rb, line 56
def cache_key
  "#{dependency.name}-#{cookbook_version}"
end
cached_cookbook() click to toggle source

@see BaseLocation#cached_cookbook

# File lib/cookbook-omnifetch/chef_server.rb, line 61
def cached_cookbook
  @cached_cookbook ||= CookbookOmnifetch.cached_cookbook_class.from_path(install_path)
end
cookbook_name() click to toggle source
# File lib/cookbook-omnifetch/chef_server.rb, line 17
def cookbook_name
  dependency.name
end
http_client() click to toggle source
# File lib/cookbook-omnifetch/chef_server.rb, line 40
def http_client
  @http_client
end
install() click to toggle source
# File lib/cookbook-omnifetch/chef_server.rb, line 29
def install
  installer.install
end
install_path() click to toggle source

The path where this cookbook would live in the store, if it were installed.

@return [Pathname, nil]

# File lib/cookbook-omnifetch/chef_server.rb, line 48
def install_path
  @install_path ||= CookbookOmnifetch.storage_path.join(cache_key)
end
installed?() click to toggle source

Determine if this revision is installed.

@return [Boolean]

# File lib/cookbook-omnifetch/chef_server.rb, line 36
def installed?
  install_path.exist?
end
installer() click to toggle source
# File lib/cookbook-omnifetch/chef_server.rb, line 25
def installer
  MetadataBasedInstaller.new(http_client: http_client, url_path: url_path, install_path: install_path)
end
lock_data() click to toggle source
# File lib/cookbook-omnifetch/chef_server.rb, line 52
def lock_data
  { "chef_server" => uri, "version" => cookbook_version }
end
url_path() click to toggle source
# File lib/cookbook-omnifetch/chef_server.rb, line 21
def url_path
  "/cookbooks/#{cookbook_name}/#{cookbook_version}"
end

Private Instance Methods

default_chef_server_http_client() click to toggle source
# File lib/cookbook-omnifetch/chef_server.rb, line 67
def default_chef_server_http_client
  CookbookOmnifetch.default_chef_server_http_client
end