Class: ChefFS::FileSystem::ChefRepositoryFileSystemRootDir
- Inherits:
-
BaseFSDir
- Object
- BaseFSObject
- BaseFSDir
- ChefFS::FileSystem::ChefRepositoryFileSystemRootDir
- Defined in:
- lib/chef_fs/file_system/chef_repository_file_system_root_dir.rb
Instance Attribute Summary collapse
-
#child_paths ⇒ Object
readonly
Returns the value of attribute child_paths.
Attributes inherited from BaseFSObject
Instance Method Summary collapse
- #can_have_child?(name, is_dir) ⇒ Boolean
- #children ⇒ Object
- #create_child(name, file_contents = nil) ⇒ Object
-
#fs_description ⇒ Object
Used to print out the filesystem.
-
#initialize(child_paths) ⇒ ChefRepositoryFileSystemRootDir
constructor
A new instance of ChefRepositoryFileSystemRootDir.
- #json_class ⇒ Object
Methods inherited from BaseFSDir
Methods inherited from BaseFSObject
#chef_object, #child, #compare_to, #delete, #dir?, #exists?, #path_for_printing, #read, #root, #write
Constructor Details
#initialize(child_paths) ⇒ ChefRepositoryFileSystemRootDir
Returns a new instance of ChefRepositoryFileSystemRootDir.
36 37 38 39 |
# File 'lib/chef_fs/file_system/chef_repository_file_system_root_dir.rb', line 36 def initialize(child_paths) super("", nil) @child_paths = child_paths end |
Instance Attribute Details
#child_paths ⇒ Object (readonly)
Returns the value of attribute child_paths.
41 42 43 |
# File 'lib/chef_fs/file_system/chef_repository_file_system_root_dir.rb', line 41 def child_paths @child_paths end |
Instance Method Details
#can_have_child?(name, is_dir) ⇒ Boolean
47 48 49 |
# File 'lib/chef_fs/file_system/chef_repository_file_system_root_dir.rb', line 47 def can_have_child?(name, is_dir) child_paths.has_key?(name) && is_dir end |
#children ⇒ Object
43 44 45 |
# File 'lib/chef_fs/file_system/chef_repository_file_system_root_dir.rb', line 43 def children @children ||= child_paths.keys.sort.map { |name| make_child_entry(name) }.select { |child| !child.nil? } end |
#create_child(name, file_contents = nil) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/chef_fs/file_system/chef_repository_file_system_root_dir.rb', line 51 def create_child(name, file_contents = nil) child_paths[name].each do |path| Dir.mkdir(path) end child = make_child_entry(name) @children = nil child end |
#fs_description ⇒ Object
Used to print out the filesystem
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/chef_fs/file_system/chef_repository_file_system_root_dir.rb', line 65 def fs_description repo_path = File.dirname(child_paths['cookbooks'][0]) result = "repository at #{repo_path}\n" if Chef::Config[:versioned_cookbooks] result << " Multiple versions per cookbook\n" else result << " One version per cookbook\n" end child_paths.each_pair do |name, paths| if paths.any? { |path| File.dirname(path) != repo_path } result << " #{name} at #{paths.join(', ')}\n" end end result end |
#json_class ⇒ Object
60 61 62 |
# File 'lib/chef_fs/file_system/chef_repository_file_system_root_dir.rb', line 60 def json_class nil end |