Class: Chef::Provider::RemoteDirectory

Inherits:
Directory show all
Defined in:
lib/chef/provider/remote_directory.rb

Instance Attribute Summary

Attributes inherited from Chef::Provider

#current_resource, #new_resource, #run_context

Instance Method Summary collapse

Methods inherited from Directory

#action_delete, #load_current_resource

Methods inherited from File

#action_delete, #action_touch, #backup, #compare_content, #load_current_resource, #set_content

Methods included from Mixin::Checksum

#checksum

Methods inherited from Chef::Provider

#action_nothing, build_from_file, #cookbook_name, #initialize, #load_current_resource, #node, #resource_collection

Methods included from Mixin::ConvertToClassName

#convert_to_class_name, #convert_to_snake_case, #filename_to_qualified_string, #snake_case_basename

Methods included from Mixin::EnforceOwnershipAndPermissions

#enforce_ownership_and_permissions

Methods included from Mixin::RecipeDefinitionDSLCore

#method_missing

Methods included from Mixin::Language

#data_bag, #data_bag_item, #platform?, #platform_family?, #search, #value_for_platform, #value_for_platform_family

Constructor Details

This class inherits a constructor from Chef::Provider

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Chef::Mixin::RecipeDefinitionDSLCore

Instance Method Details

#action_createObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/chef/provider/remote_directory.rb', line 33

def action_create
  super

  files_to_purge = Set.new(
    Dir.glob(::File.join(@new_resource.path, '**', '*'), ::File::FNM_DOTMATCH).select do |name|
      name !~ /(?:^|#{Regexp.escape(::File::SEPARATOR)})\.\.?$/
    end
  )
  files_to_transfer.each do |cookbook_file_relative_path|
    create_cookbook_file(cookbook_file_relative_path)
    # the file is removed from the purge list
    files_to_purge.delete(::File.join(@new_resource.path, cookbook_file_relative_path))
    # parent directories are also removed from the purge list
    directories=::File.dirname(::File.join(@new_resource.path, cookbook_file_relative_path)).split(::File::SEPARATOR)
    for i in 0..directories.length-1
      files_to_purge.delete(::File.join(directories[0..i]))
    end
  end
  purge_unmanaged_files(files_to_purge)
end

#action_create_if_missingObject



54
55
56
57
58
# File 'lib/chef/provider/remote_directory.rb', line 54

def action_create_if_missing
  # if this action is called, ignore the existing overwrite flag
  @new_resource.overwrite(false)
  action_create
end