summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@chef.io>2016-02-05 16:19:22 -0800
committerdanielsdeleo <dan@chef.io>2016-02-16 15:26:43 -0800
commit737a39ed4b5a6da724718dce6508abadfafa4a04 (patch)
tree25ac7a58c1cc05aa8fe98ec2a9f3802695700da6
parent51df1d29ec3ee1d7890bb4f9a5e8ddc011b88411 (diff)
downloadchef-737a39ed4b5a6da724718dce6508abadfafa4a04.tar.gz
Completely inline cheffs cookboks dir superclasses
-rw-r--r--lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbooks_dir.rb124
1 files changed, 122 insertions, 2 deletions
diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbooks_dir.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbooks_dir.rb
index 7d74295e6a..61c5a599f5 100644
--- a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbooks_dir.rb
+++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbooks_dir.rb
@@ -35,7 +35,10 @@ class Chef
#class ChefRepositoryFileSystemCookbooksDir < BaseFSDir
# With BaseFSDir inlined
- class ChefRepositoryFileSystemCookbooksDir < BaseFSObject
+ #class ChefRepositoryFileSystemCookbooksDir < BaseFSObject
+
+ # With BaseFSObject inlined
+ class ChefRepositoryFileSystemCookbooksDir
# Original initialize
## def initialize(name, parent, file_path)
@@ -60,9 +63,32 @@ class Chef
## @file_path = file_path || "#{parent.file_path}/#{name}"
## end
+ # BaseFSObject#initialize
+ ## def initialize(name, parent)
+ ## @parent = parent
+ ## @name = name
+ ## if parent
+ ## @path = Chef::ChefFS::PathUtils::join(parent.path, name)
+ ## else
+ ## if name != ""
+ ## raise ArgumentError, "Name of root object must be empty string: was '#{name}' instead"
+ ## end
+ ## @path = "/"
+ ## end
+ ## end
+
# inlined initialize
def initialize(name, parent, file_path)
- super(name, parent)
+ @parent = parent
+ @name = name
+ ## if parent
+ @path = Chef::ChefFS::PathUtils::join(parent.path, name)
+ ## else
+ ## if name != ""
+ ## raise ArgumentError, "Name of root object must be empty string: was '#{name}' instead"
+ ## end
+ ## @path = "/"
+ ## end
@file_path = file_path || "#{parent.file_path}/#{name}"
@data_handler = nil
begin
@@ -292,6 +318,100 @@ class Chef
children.empty?
end
+ ##############################
+ # Inlined from BaseFSObject
+ ##############################
+
+ attr_reader :name
+ attr_reader :parent
+ attr_reader :path
+
+ # Unused?
+ ## def compare_to(other)
+ ## nil
+ ## end
+
+ # overridden in subclass
+ ## def can_have_child?(name, is_dir)
+ ## false
+ ## end
+
+ def child(name)
+ if can_have_child?(name, true) || can_have_child?(name, false)
+ result = make_child_entry(name)
+ end
+ result || NonexistentFSObject.new(name, self)
+ end
+
+ # overridden in subclass
+ ## def children
+ ## raise NotFoundError.new(self) if !exists?
+ ## []
+ ## end
+
+ # unused
+ ## def chef_object
+ ## raise NotFoundError.new(self) if !exists?
+ ## nil
+ ## end
+
+ # overridden in subclass
+ ## def create_child(name, file_contents)
+ ## raise NotFoundError.new(self) if !exists?
+ ## raise OperationNotAllowedError.new(:create_child, self)
+ ## end
+
+ # overridden in subclass
+ ## def delete(recurse)
+ ## raise NotFoundError.new(self) if !exists?
+ ## raise OperationNotAllowedError.new(:delete, self)
+ ## end
+
+ # overridden and also not used
+ ## def dir?
+ ## false
+ ## end
+
+ # overridden
+ ## def exists?
+ ## true
+ ## end
+
+ # overridden
+ ## def path_for_printing
+ ## if parent
+ ## parent_path = parent.path_for_printing
+ ## if parent_path == "."
+ ## name
+ ## else
+ ## Chef::ChefFS::PathUtils::join(parent.path_for_printing, name)
+ ## end
+ ## else
+ ## name
+ ## end
+ ## end
+
+ # we're never root, don't need to branch here
+ ## def root
+ ## parent ? parent.root : self
+ ## end
+
+ def root
+ parent.root
+ end
+
+ # overridden and unused
+ ## def read
+ ## raise NotFoundError.new(self) if !exists?
+ ## raise OperationNotAllowedError.new(:read, self)
+ ## end
+
+ # overridden and unused
+ ## def write(file_contents)
+ ## raise NotFoundError.new(self) if !exists?
+ ## raise OperationNotAllowedError.new(:write, self)
+ ## end
+
end
end
end