Class: Chef::Provider::ZipFile
- Inherits:
-
Chef::Provider
- Object
- Chef::Provider
- Chef::Provider::ZipFile
- Includes:
- Mixin::EnforceOwnershipAndPermissions, Garcon
- Defined in:
- lib/garcon/chef/provider/zip_file.rb
Constant Summary
Constants included from Garcon
Instance Method Summary collapse
- #action_unzip ⇒ Object
- #action_zip ⇒ Object
-
#initialize(new_resource, run_context) ⇒ ZipFile
constructor
A new instance of ZipFile.
-
#load_current_resource ⇒ Chef::Provider::ZipFile
private
Load and return the current resource.
-
#manage_symlink_access? ⇒ Boolean
Implementation components should follow symlinks when managing access control (e.g., use chmod instead of lchmod even if the path we’re managing is a symlink).
-
#whyrun_supported? ⇒ TrueClass, FalseClass
private
Boolean indicating if WhyRun is supported by this provider.
Methods included from Garcon
auto_terminate_all_executors?, auto_terminate_global_executors?, coercer, coercer=, config, configuration, crypto, crypto=, disable_auto_termination_of_all_executors!, disable_auto_termination_of_global_executors!, global_fast_executor, global_io_executor, global_timer_set, included, #inspect, kill_global_executors, monotonic_time, new_fast_executor, new_io_executor, physical_processor_count, processor_count, secret, secret=, shutdown_global_executors, #terminal_dimensions, timer, #to_s, wait_for_global_executors_termination, warn
Constructor Details
#initialize(new_resource, run_context) ⇒ ZipFile
Returns a new instance of ZipFile.
76 77 78 79 |
# File 'lib/garcon/chef/provider/zip_file.rb', line 76 def initialize(new_resource, run_context) super __zip__ unless defined?(Zip) end |
Instance Method Details
#action_unzip ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/garcon/chef/provider/zip_file.rb', line 104 def action_unzip converge_by "Unzip #{r.source} to #{r.path}" do Zip::File.open(cached_file) do |zip| zip.each do |entry| path = ::File.join(r.path, entry.name) FileUtils.mkdir_p(::File.dirname(path)) if r.overwrite && ::File.exist?(path) && !::File.directory?(path) FileUtils.rm(path) end zip.extract(entry, path) end end do_acl_changes ::File.unlink(cached_file) if r.remove_after r.updated_by_last_action(true) end end |
#action_zip ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/garcon/chef/provider/zip_file.rb', line 122 def action_zip if ::File.exists?(r.path) && !r.overwrite Chef::Log.info "#{r.path} already exists - nothing to do" else ::File.unlink(r.path) if ::File.exists?(r.path) if ::File.directory?(r.source) converge_by "Zip #{r.source}" do z = Zip::File.new(r.path, true) Find.find(r.source) do |f| next if f == r.source zip_fname = f.sub(r.source, '') z.add(zip_fname, f) end z.close do_acl_changes r.updated_by_last_action(true) end else Chef::Log.warn 'A valid directory must be specified for ziping.' end end end |
#load_current_resource ⇒ Chef::Provider::ZipFile
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Load and return the current resource.
99 100 101 102 |
# File 'lib/garcon/chef/provider/zip_file.rb', line 99 def load_current_resource @current_resource ||= Chef::Resource::ZipFile.new(r.name) @current_resource end |
#manage_symlink_access? ⇒ Boolean
Implementation components should follow symlinks when managing access control (e.g., use chmod instead of lchmod even if the path we’re managing is a symlink).
149 150 151 |
# File 'lib/garcon/chef/provider/zip_file.rb', line 149 def manage_symlink_access? false end |
#whyrun_supported? ⇒ TrueClass, FalseClass
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Boolean indicating if WhyRun is supported by this provider.
90 91 92 |
# File 'lib/garcon/chef/provider/zip_file.rb', line 90 def whyrun_supported? true end |