Sha256: 52af6cc7fe64248fef69cc6634c1193767b2caf089b713cad668fafb441507d8

Contents?: true

Size: 747 Bytes

Versions: 1

Compression:

Stored size: 747 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 file/dir that will be created as a result of unpack
  def creates
    File.join(@dst, dirname)
  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

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-pe_build-0.5.0 lib/pe_build/unpack/tar.rb