Method: Chef::ChefFS::FileSystem::Repository::ChefRepositoryFileSystemVersionedCookbookDir#cookbook_version

Defined in:
lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb

#cookbook_versionObject

Override from parent



27
28
29
30
31
32
33
34
35
36
37
38
# 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