class Chef::Provider::ZipFile

Public Class Methods

new(new_resource, run_context) click to toggle source
Calls superclass method
# File lib/garcon/chef/provider/zip_file.rb, line 76
def initialize(new_resource, run_context)
  super
  __zip__ unless defined?(Zip)
end

Public Instance Methods

action_unzip() click to toggle source
# 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() click to toggle source
# 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() click to toggle source

Load and return the current resource.

@return [Chef::Provider::ZipFile]

@api private

# 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
whyrun_supported?() click to toggle source

Boolean indicating if WhyRun is supported by this provider.

@return [TrueClass, FalseClass]

@api private

# File lib/garcon/chef/provider/zip_file.rb, line 90
def whyrun_supported?
  true
end