Sha256: 953a2cb3080c650dfe9b85978ca34d1a8fd1246f04908537459816511ebc50cf

Contents?: true

Size: 734 Bytes

Versions: 1

Compression:

Stored size: 734 Bytes

Contents

require 'archive/tar/minitar'

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(file_stream, @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(file_stream)

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

    base
  end

  private

  def file_stream
    File.open(@src, 'rb')
  end
end
end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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