Class: Chef::Provider::RemoteDirectory

Inherits:
Directory show all
Includes:
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 inherited from Directory

#action_delete, #define_resource_requirements, #load_current_resource, #whyrun_supported?

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, #load_current_resource_attrs, #set_all_access_controls, #set_content, #setup_acl, #update_new_file_state, #whyrun_supported?

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, build_from_file, #cleanup_after_converge, #converge, #cookbook_name, #define_resource_requirements, #events, #initialize, #load_current_resource, #node, #process_resource_requirements, #requirements, #resource_collection, #run_action, #whyrun_mode?, #whyrun_supported?

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

#access_controls, #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


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

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)

  converge_by("Create managed files in directory") do
    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
  end

  converge_by("Purge unmanaged files from directory") do
    purge_unmanaged_files(files_to_purge)
  end
end

#action_create_if_missingObject


60
61
62
63
64
# File 'lib/chef/provider/remote_directory.rb', line 60

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