Sha256: 186c040f661b929cc4a425f2263a808116db2b06fcf2872cd42cfc74bc97eb32
Contents?: true
Size: 1.8 KB
Versions: 1
Compression:
Stored size: 1.8 KB
Contents
require 'zip/zipfilesystem' module VMC::Cli class ZipUtil class << self def entry_lines(file) contents = nil unless VMC::Cli::Config.nozip contents = `unzip -l #{file} 2> /dev/null` contents = nil if $? != 0 end # Do Ruby version if told to or native version failed unless contents entries = [] Zip::ZipFile.foreach(file) { |zentry| entries << zentry } contents = entries.join("\n") end contents end def unpack(file, dest) unless VMC::Cli::Config.nozip FileUtils.mkdir(dest) `unzip -q #{file} -d #{dest} 2> /dev/null` return unless $? != 0 end # Do Ruby version if told to or native version failed Zip::ZipFile.foreach(file) do |zentry| epath = "#{dest}/#{zentry}" dirname = File.dirname(epath) FileUtils.mkdir_p(dirname) unless File.exists?(dirname) zentry.extract(epath) unless File.exists?(epath) end end def pack(dir, zipfile) exclude = ['..', '.', '*~', '#*#', '*.log'] unless VMC::Cli::Config.nozip excludes = exclude.map { |e| "\\#{e}" } excludes = excludes.join(' ') Dir.chdir(dir) do `zip -q -r -x #{excludes} #{zipfile} . 2> /dev/null` return unless $? != 0 end end # Do Ruby version if told to or native version failed Zip::ZipFile::open(zipfile, true) do |zf| Dir.glob("#{dir}/**/*", File::FNM_DOTMATCH).each do |f| process = true exclude.each { |e| process = false if File.fnmatch(e, File.basename(f)) } zf.add(f.sub("#{dir}/",''), f) if (process && File.exists?(f)) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vmc-0.2.4 | lib/cli/zip_util.rb |