Class: PEBuild::Unpack::Tar

Inherits:
Object
  • Object
show all
Defined in:
lib/pe_build/unpack/tar.rb

Direct Known Subclasses

TarGZ

Instance Method Summary collapse

Constructor Details

#initialize(src, dst) ⇒ Tar

Returns a new instance of Tar.

Parameters:

  • src (String)
  • dst (String)


8
9
10
# File 'lib/pe_build/unpack/tar.rb', line 8

def initialize(src, dst)
  @src, @dst = src, dst
end

Instance Method Details

#createsString

Returns The file/dir that will be created as a result of unpack.

Returns:

  • (String)

    The file/dir that will be created as a result of unpack



17
18
19
# File 'lib/pe_build/unpack/tar.rb', line 17

def creates
  File.join(@dst, dirname)
end

#dirnameString

Returns The base directory contained in the tar archive.

Returns:

  • (String)

    The base directory contained in the tar archive



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/pe_build/unpack/tar.rb', line 22

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

#unpackObject



12
13
14
# File 'lib/pe_build/unpack/tar.rb', line 12

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