class Chef::ChefFS::FileSystem::Repository::ChefRepositoryFileSystemVersionedCookbookDir

Public Instance Methods

cookbook_version() click to toggle source

Override from parent

# File lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb, line 27
def cookbook_version
  loader = Chef::Cookbook::CookbookVersionLoader.new(file_path, chefignore)
  # We need the canonical cookbook name if we are using versioned cookbooks, but we don't
  # want to spend a lot of time adding code to the main Chef libraries
  canonical_name = canonical_cookbook_name(File.basename(file_path))
  raise "When versioned_cookbooks mode is on, cookbook #{file_path} must match format <cookbook_name>-x.y.z" unless canonical_name

  # KLUDGE: We shouldn't have to use instance_variable_set
  loader.instance_variable_set(:@cookbook_name, canonical_name)
  loader.load!
  loader.cookbook_version
end