summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@chef.io>2016-02-06 15:15:23 -0800
committerdanielsdeleo <dan@chef.io>2016-02-16 15:26:43 -0800
commit5c707929ad327e5e10edf8128775c2453aeee5e2 (patch)
treecc1eb544844637db1b1a7c9c08357ebb034d0654
parentc02218871b0cd87b6e2b12f9ab1d1135bd4bbc89 (diff)
downloadchef-5c707929ad327e5e10edf8128775c2453aeee5e2.tar.gz
Fully inline cheffs cookbook entry code
-rw-r--r--lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb125
1 files changed, 123 insertions, 2 deletions
diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb
index 6254e30b29..7ce42039c9 100644
--- a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb
+++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb
@@ -39,7 +39,10 @@ class Chef
#class ChefRepositoryFileSystemCookbookEntry < BaseFSDir
# With BaseFSDir inlined
- class ChefRepositoryFileSystemCookbookEntry < BaseFSObject
+ #class ChefRepositoryFileSystemCookbookEntry < BaseFSObject
+
+ # Fully inlined
+ class ChefRepositoryFileSystemCookbookEntry
# Original initialize
## def initialize(name, parent, file_path = nil, ruby_only = false, recursive = false)
## super(name, parent, file_path)
@@ -59,9 +62,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 = nil, ruby_only = false, recursive = false)
- 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
@ruby_only = ruby_only
@recursive = recursive
@data_handler = nil
@@ -288,6 +314,101 @@ class Chef
children.empty?
end
+ ##############################
+ # inlined from BaseFSObject
+ ##############################
+
+ attr_reader :name
+ attr_reader :parent
+ attr_reader :path
+
+ # unused?
+ ## def compare_to(other)
+ ## nil
+ ## end
+
+ # overriden by 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 by subclass
+ ## def children
+ ## raise NotFoundError.new(self) if !exists?
+ ## []
+ ## end
+
+ # unused?
+ ## def chef_object
+ ## raise NotFoundError.new(self) if !exists?
+ ## nil
+ ## end
+
+ # overridden by subclass
+ ## def create_child(name, file_contents)
+ ## raise NotFoundError.new(self) if !exists?
+ ## raise OperationNotAllowedError.new(:create_child, self)
+ ## end
+
+ # overridden by subclass
+ ## def delete(recurse)
+ ## raise NotFoundError.new(self) if !exists?
+ ## raise OperationNotAllowedError.new(:delete, self)
+ ## end
+
+ # overridden by subclass
+ ## def dir?
+ ## false
+ ## end
+
+ # overridden by subclass
+ ## def exists?
+ ## true
+ ## end
+
+ # Printable path, generally used to distinguish paths in one root from
+ # paths in another.
+ 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
+
+ # this class isnt a root don't need a branch
+ ## def root
+ ## parent ? parent.root : self
+ ## end
+
+ # just the behavior we need
+ def root
+ parent.root
+ end
+
+ # overridden by subclass
+ ## def read
+ ## raise NotFoundError.new(self) if !exists?
+ ## raise OperationNotAllowedError.new(:read, self)
+ ## end
+
+ # overridden by subclass
+ ## def write(file_contents)
+ ## raise NotFoundError.new(self) if !exists?
+ ## raise OperationNotAllowedError.new(:write, self)
+ ## end
end
end
end