class Onboard::Extract
Attributes
archive[R]
link[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
longlink(entry)
click to toggle source
# File lib/onboard/extract.rb, line 20 def longlink(entry) return File.join path, entry.read.strip if entry.full_name == TAR_LONGLINK end
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
xlink(dst, entry)
click to toggle source
# File lib/onboard/extract.rb, line 39 def xlink(dst, entry) return false unless entry.header.typeflag == '2' # Symlink! File.symlink entry.header.linkname, dst end