Sha256: f3214832d05da26d1935503037ba507d5324740d5c29e1dcee40e391d9065bbb

Contents?: true

Size: 620 Bytes

Versions: 7

Compression:

Stored size: 620 Bytes

Contents

require 'archive/tar/minitar'
require 'zlib'

module PEBuild
module Unpack
class Tar

  # @param src [String]
  # @param dst [String]
  def initialize(src, dst)
    @src, @dst = src, dst
  end

  def unpack
    ::Archive::Tar::Minitar.unpack(zip, @dst)
  end

  # @return [String] The base directory contained in the tar archive
  def dirname
    input = ::Archive::Tar::Minitar::Input.new(zip)

    base = nil
    input.each do |entry|
      path = entry.name
      base = path.split(File::SEPARATOR).first
    end

    base
  end

  private

  def zip
    Zlib::GzipReader.new(File.open(@src, 'rb'))
  end
end
end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
vagrant-pe_build-0.4.3 lib/pe_build/unpack/tar.rb
vagrant-pe_build-0.4.2 lib/pe_build/unpack/tar.rb
vagrant-pe_build-0.4.1 lib/pe_build/unpack/tar.rb
vagrant-pe_build-0.4.0 lib/pe_build/unpack/tar.rb
vagrant-pe_build-0.3.0 lib/pe_build/unpack/tar.rb
vagrant-pe_build-0.2.0 lib/pe_build/unpack/tar.rb
vagrant-pe_build-0.1.0 lib/pe_build/unpack/tar.rb