Class: Chef::ChefFS::FileSystem::Repository::ChefRepositoryFileSystemVersionedCookbookDir

Inherits:
ChefRepositoryFileSystemCookbookDir show all
Defined in:
lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb

Instance Attribute Summary

Attributes inherited from ChefRepositoryFileSystemCookbookEntry

#file_path, #name, #parent, #path, #recursive, #ruby_only

Instance Method Summary collapse

Methods inherited from ChefRepositoryFileSystemCookbookDir

#can_have_child?, #can_upload?, #canonical_cookbook_name, canonical_cookbook_name, #chef_object, #chefignore, #children, #create, #dir?, #fs_entry_valid?, #name_valid?, #uploaded_cookbook_version_path, #write

Methods inherited from ChefRepositoryFileSystemCookbookEntry

#can_have_child?, #child, #children, #compare_to, #create_child, #delete, #dir?, #exists?, #initialize, #path_for_printing, #read, #root, #write, #write_pretty_json

Constructor Details

This class inherits a constructor from Chef::ChefFS::FileSystem::Repository::ChefRepositoryFileSystemCookbookEntry

Instance Method Details

#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