class ChefCLI::Policyfile::CookbookLocationSpecification

def ==(other)

def ==(other)
  other.is_a?(self.class) &&
    other.name == name &&
    other.version_constraint == version_constraint &&
    other.source_options == source_options
end

def cache_key

def cache_key
  installer.cache_key
end

def cached_cookbook

def cached_cookbook
  # TODO: handle 'bad' return values here (cookbook not installed yet)
  installer.cached_cookbook
end

def cookbook_has_recipe?(recipe_name)

def cookbook_has_recipe?(recipe_name)
  expected_path = cookbook_path.join("recipes/#{recipe_name}.rb")
  expected_path_yml = cookbook_path.join("recipes/#{recipe_name}.yml")
  expected_path.exist? || expected_path_yml.exist?
end

def cookbook_path

def cookbook_path
  if installer.respond_to?(:expanded_path)
    installer.expanded_path
  else
    installer.install_path.expand_path
  end
end

def dependencies

def dependencies
  cached_cookbook.dependencies
end

def ensure_cached

def ensure_cached
  unless installer.installed?
    installer.install
  end
end

def errors

def errors
  error_messages = []
  if source_options_invalid?
    error_messages << "Cookbook `#{name}' has invalid source options `#{source_options.inspect}'"
  end
  error_messages
end

def initialize(name, version_constraint, source_options, storage_config)

def initialize(name, version_constraint, source_options, storage_config)
  @name = name
  @version_constraint = Semverse::Constraint.new(version_constraint)
  @source_options = source_options
  @source_type = SOURCE_TYPES.find { |type| source_options.key?(type) }
  @storage_config = storage_config
end

def installed?

def installed?
  installer.installed?
end

def installer

def installer
  # TODO: handle 'bad' return values here (invalid source_options, etc.)
  @installer ||= CookbookOmnifetch.init(self, source_options)
end

def mirrors_canonical_upstream?

def mirrors_canonical_upstream?
  %i{git github artifactserver chef_server chef_server_artifact artifactory}.include?(source_type)
end

def relative_path

def relative_path
  installer.relative_path.to_s
end

def source_options_for_lock

def source_options_for_lock
  installer.lock_data
end

def source_options_invalid?

def source_options_invalid?
  !source_options.empty? && installer.nil?
end

def to_s

def to_s
  # Note, this may appear in exceptions
  s = "Cookbook '#{name}'"
  s << " #{version_constraint}"
  s << " #{source_options}" unless source_options.empty?
  s
end

def uri

def uri
  installer.uri
end

def valid?

def valid?
  errors.empty?
end

def version

def version
  cached_cookbook.version
end

def version_fixed?

def version_fixed?
  %i{git github path chef_server_artifact}.include?(@source_type)
end