Sha256: 1bf7e73a507cccfa0a929c7683aa18beb84a681a2718af91b2717a6c5f11cd9a
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
require 'rubygems' require 'rubygems/package' require 'zlib' require 'fileutils' module Util module Tar # un-gzips the given IO, returning the # decompressed version as a StringIO def ungzip(tarfile) z = Zlib::GzipReader.new(tarfile) unzipped = StringIO.new(z.read) z.close unzipped end # untars the given IO into the specified # directory def untar(io, destination) Gem::Package::TarReader.new io do |tar| tar.each do |tarfile| # NOTE skip the root directory of the tarfile destination_file = File.join destination, tarfile.full_name.split('/', 2).last if tarfile.directory? FileUtils.mkdir_p destination_file else destination_directory = File.dirname(destination_file) FileUtils.mkdir_p destination_directory unless File.directory?(destination_directory) File.open destination_file, "wb" do |f| f.print tarfile.read end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
asciidoctor-latex-1.5.0.dev | rake/tar.rb |