class Mixlib::Archive::Tar

def reader(&block)

def reader(&block)
  raw = File.open(archive, "rb")
  file = if is_gzip_file?(archive)
           Mixlib::Archive::Log.debug "gzip file detected"
           Zlib::GzipReader.wrap(raw)
         else
           raw
         end
  raise Mixlib::Archive::TarError, "Unrecognized archive format" unless is_tar_archive?(file)
  Gem::Package::TarReader.new(file, &block)
ensure
  if file
    file.close unless file.closed?
    file = nil # rubocop:disable Lint/UselessAssignment
  end
  if raw
    raw.close unless raw.closed?
    raw = nil # rubocop:disable Lint/UselessAssignment
  end
end