Parent

Files

Class/Module Index [+]

Quicksearch

Chef::ChefFS::FileSystem::ChefRepositoryFileSystemEntry

ChefRepositoryFileSystemEntry works just like FileSystemEntry, except it pretends files in /cookbooks/chefignore don't exist and it can inflate Chef objects

Attributes

chefignore[R]

Public Class Methods

new(name, parent, file_path = nil) click to toggle source
# File lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb, line 35
def initialize(name, parent, file_path = nil)
  super(name, parent, file_path)
  # Load /cookbooks/chefignore
  if name == "cookbooks" && path == "/cookbooks" # We check name first because it's a faster fail than path
    @chefignore = Chef::Cookbook::Chefignore.new(self.file_path)
  # If we are a cookbook or a cookbook subdirectory, empty directories
  # underneath us are ignored (since they cannot be uploaded)
  elsif parent && parent.name === "cookbooks" && parent.path == "/cookbooks"
    @ignore_empty_directories = true
  elsif parent && parent.ignore_empty_directories?
    @ignore_empty_directories = true
  end
end

Public Instance Methods

chef_object() click to toggle source
# File lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb, line 55
def chef_object
  begin
    if parent.path == "/cookbooks"
      loader = Chef::Cookbook::CookbookVersionLoader.new(file_path, parent.chefignore)
      loader.load_cookbooks
      return loader.cookbook_version
    end

    # Otherwise the information to inflate the object, is in the file (json_class).
    return Chef::JSONCompat.from_json(read)
  rescue
    Chef::Log.error("Could not read #{path_for_printing} into a Chef object: #{$!}")
  end
  nil
end
children() click to toggle source
# File lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb, line 71
def children
  @children ||= Dir.entries(file_path).select { |entry| entry != '.' && entry != '..' && !ignored?(entry) }.
                                       map { |entry| ChefRepositoryFileSystemEntry.new(entry, self) }
end
ignore_empty_directories?() click to toggle source
# File lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb, line 51
def ignore_empty_directories?
  @ignore_empty_directories
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.