Class: Chef::Provider::RemoteDirectory

Inherits:
Directory show all
Includes:
Mixin::EnforceOwnershipAndPermissions, Mixin::FileClass
Defined in:
lib/chef/provider/remote_directory.rb

Constant Summary

Constants included from Mixin::ShellOut

Mixin::ShellOut::DEPRECATED_OPTIONS

Instance Attribute Summary

Attributes inherited from Chef::Provider

#action, #current_resource, #new_resource, #run_context

Instance Method Summary collapse

Methods included from Mixin::FileClass

#file_class

Methods included from Mixin::EnforceOwnershipAndPermissions

#access_controls, #enforce_ownership_and_permissions

Methods inherited from Directory

#action_delete, #define_resource_requirements, #load_current_resource

Methods inherited from File

#action_delete, #action_touch, #backup, #compare_content, #define_resource_requirements, #deploy_tempfile, #diff_current, #diff_current_from_content, #is_binary?, #load_current_resource, #set_all_access_controls, #set_content, #setup_acl, #update_new_file_state

Methods included from Mixin::ShellOut

#run_command_compatible_options, #shell_out, #shell_out!

Methods included from Mixin::Checksum

#checksum

Methods inherited from Chef::Provider

#action_nothing, #cleanup_after_converge, #cookbook_name, #define_resource_requirements, #events, #initialize, #load_current_resource, #node, #process_resource_requirements, #requirements, #resource_collection, #run_action, #set_updated_status, #whyrun_mode?

Methods included from DSL::Recipe

#method_missing

Methods included from Mixin::ConvertToClassName

#convert_to_class_name, #convert_to_snake_case, #filename_to_qualified_string, #snake_case_basename

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::DSL::Recipe

Instance Method Details

#action_createObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/chef/provider/remote_directory.rb', line 37

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



58
59
60
61
62
# File 'lib/chef/provider/remote_directory.rb', line 58

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