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, #compare_group, #compare_mode, #compare_owner, #load_current_resource, #set_content, #set_group, #set_mode, #set_owner

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::RecipeDefinitionDSLCore

#method_missing

Methods included from Mixin::Language

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

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
# 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)
    files_to_purge.delete(::File.dirname(::File.join(@new_resource.path, cookbook_file_relative_path)))
    files_to_purge.delete(::File.join(@new_resource.path, cookbook_file_relative_path))
  end
  purge_unmanaged_files(files_to_purge)
end

#action_create_if_missingObject


49
50
51
52
53
# File 'lib/chef/provider/remote_directory.rb', line 49

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