Parent

Files

Class/Module Index [+]

Quicksearch

Chef::ChefFS::FileSystem::ChefRepositoryFileSystemCookbookDir

Public Class Methods

canonical_cookbook_name(entry_name) click to toggle source

Exposed as a class method so that it can be used elsewhere

# File lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb, line 82
def self.canonical_cookbook_name(entry_name)
  name_match = Chef::ChefFS::FileSystem::CookbookDir::VALID_VERSIONED_COOKBOOK_NAME.match(entry_name)
  return nil if name_match.nil?
  return name_match[1]
end
new(name, parent, file_path = nil) click to toggle source
# File lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb, line 29
def initialize(name, parent, file_path = nil)
  super(name, parent, file_path)
end

Public Instance Methods

can_have_child?(name, is_dir) click to toggle source
# File lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb, line 71
def can_have_child?(name, is_dir)
  if is_dir
    # Only the given directories will be uploaded.
    return CookbookDir::COOKBOOK_SEGMENT_INFO.keys.include?(name.to_sym) && name != 'root_files'
  elsif name == Chef::Cookbook::CookbookVersionLoader::UPLOADED_COOKBOOK_VERSION_FILE
    return false
  end
  super(name, is_dir)
end
can_upload?() click to toggle source
# File lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb, line 96
def can_upload?
  File.exists?(uploaded_cookbook_version_path) || children.size > 0
end
canonical_cookbook_name(entry_name) click to toggle source
# File lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb, line 88
def canonical_cookbook_name(entry_name)
  self.class.canonical_cookbook_name(entry_name)
end
chef_object() click to toggle source
# File lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb, line 33
def chef_object
  begin
    loader = Chef::Cookbook::CookbookVersionLoader.new(file_path, parent.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
    if Chef::Config[:versioned_cookbooks]
      _canonical_name = canonical_cookbook_name(File.basename(file_path))
      fail "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)
    end

    loader.load_cookbooks
    cb = loader.cookbook_version
    if !cb
      Chef::Log.error("Cookbook #{file_path} empty.")
      raise "Cookbook #{file_path} empty."
    end
    cb
  rescue => e
    Chef::Log.error("Could not read #{path_for_printing} into a Chef object: #{e}")
    Chef::Log.error(e.backtrace.join("\n"))
    raise
  end
end
children() click to toggle source
# File lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb, line 60
def children
  begin
    Dir.entries(file_path).sort.
        select { |child_name| can_have_child?(child_name, File.directory?(File.join(file_path, child_name))) }.
        map { |child_name| make_child(child_name) }.
        select { |entry| !(entry.dir? && entry.children.size == 0) }
  rescue Errno::ENOENT
    raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
  end
end
uploaded_cookbook_version_path() click to toggle source
# File lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb, line 92
def uploaded_cookbook_version_path
  File.join(file_path, Chef::Cookbook::CookbookVersionLoader::UPLOADED_COOKBOOK_VERSION_FILE)
end

Protected Instance Methods

make_child(child_name) click to toggle source
# File lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb, line 102
def make_child(child_name)
  segment_info = CookbookDir::COOKBOOK_SEGMENT_INFO[child_name.to_sym] || {}
  ChefRepositoryFileSystemCookbookEntry.new(child_name, self, nil, segment_info[:ruby_only], segment_info[:recursive])
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.