Class: Chef::ChefFS::FileSystem::ChefServer::CookbookSubdir

Inherits:
BaseFSDir show all
Defined in:
lib/chef/chef_fs/file_system/chef_server/cookbook_subdir.rb

Instance Attribute Summary collapse

Attributes inherited from BaseFSObject

#name, #parent, #path

Instance Method Summary collapse

Methods inherited from BaseFSDir

#dir?, #empty?

Methods inherited from BaseFSObject

#chef_object, #child, #compare_to, #create_child, #delete, #dir?, #exists?, #path_for_printing, #read, #root, #write

Constructor Details

#initialize(name, parent, ruby_only, recursive) ⇒ CookbookSubdir

Returns a new instance of CookbookSubdir.



26
27
28
29
30
31
# File 'lib/chef/chef_fs/file_system/chef_server/cookbook_subdir.rb', line 26

def initialize(name, parent, ruby_only, recursive)
  super(name, parent)
  @children = []
  @ruby_only = ruby_only
  @recursive = recursive
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



34
35
36
# File 'lib/chef/chef_fs/file_system/chef_server/cookbook_subdir.rb', line 34

def children
  @children
end

#versionsObject (readonly)

Returns the value of attribute versions.



33
34
35
# File 'lib/chef/chef_fs/file_system/chef_server/cookbook_subdir.rb', line 33

def versions
  @versions
end

Instance Method Details

#add_child(child) ⇒ Object



36
37
38
# File 'lib/chef/chef_fs/file_system/chef_server/cookbook_subdir.rb', line 36

def add_child(child)
  @children << child
end

#can_have_child?(name, is_dir) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
43
44
45
46
47
# File 'lib/chef/chef_fs/file_system/chef_server/cookbook_subdir.rb', line 40

def can_have_child?(name, is_dir)
  if is_dir
    return false unless @recursive
  else
    return false if @ruby_only && name !~ /\.rb$/
  end
  true
end

#make_child_entry(name) ⇒ Object



49
50
51
52
# File 'lib/chef/chef_fs/file_system/chef_server/cookbook_subdir.rb', line 49

def make_child_entry(name)
  result = @children.find { |child| child.name == name } if @children
  result || NonexistentFSObject.new(name, self)
end

#restObject



54
55
56
# File 'lib/chef/chef_fs/file_system/chef_server/cookbook_subdir.rb', line 54

def rest
  parent.rest
end