class Onboard::Extract

Attributes

archive[R]
path[R]

Public Class Methods

new(archive, link, path) click to toggle source
# File lib/onboard/extract.rb, line 14
def initialize(archive, link, path)
  @archive = archive
  @link = link
  @path = path
end

Public Instance Methods

x(dst = nil) click to toggle source
# File lib/onboard/extract.rb, line 44
def x(dst = nil)
  Gem::Package::TarReader.new(Zlib::GzipReader.open archive) do |tar|
    tar.each do |entry|
      dst = longlink(entry)
      dst ||= File.join path, entry.full_name
      xdir(dst, entry)
      xfile(dst, entry)
      xlink(dst, entry)
      dst = nil
    end
  end
end
xdir(dst, entry) click to toggle source
# File lib/onboard/extract.rb, line 24
def xdir(dst, entry)
  return false unless entry.directory?
  FileUtils.rm_rf dst unless File.directory? dst
  FileUtils.mkdir_p dst, :mode => entry.header.mode, :verbose => false
end
xfile(dst, entry) click to toggle source
# File lib/onboard/extract.rb, line 30
def xfile(dst, entry)
  return false unless entry.file?
  FileUtils.rm_rf dst unless File.file? dst
  File.open dst, 'wb' do |f|
    f.print entry.read
  end
  FileUtils.chmod entry.header.mode, dst, :verbose => false
end