class Mixlib::Archive::LibArchive

def extract(destination, perms: true, ignore: [])

ignore[Array]:: an array of matches of file paths to ignore
perms:: should the extracter use permissions from the archive.
=== Parameters

Extracts the archive to the given +destination+
def extract(destination, perms: true, ignore: [])
  ignore_re = Regexp.union(ignore)
  flags = perms ? ::Archive::EXTRACT_PERM : nil
  FileUtils.mkdir_p(destination)
  # @note Dir.chdir is applied to the process, thus it is not thread-safe
  # and must be synchronized.
  # TODO: figure out a better alternative to chdir
  Mixlib::Archive::LibArchive.mutex_chdir.synchronize do
    Dir.chdir(destination) do
      reader = ::Archive::Reader.open_filename(@archive)
      reader.each_entry do |entry|
        if entry.pathname =~ ignore_re
          Mixlib::Archive::Log.warn "ignoring entry #{entry.pathname}"
          next
        end
        reader.extract(entry, flags.to_i)
      end
      reader.close
    end
  end
end