module Jxedt module ZipUtils def self.zip(path, zip_name: nil, to_dir: nil) basename = File.basename(path) zip_name = basename if zip_name.nil? out_path = to_dir.nil? ? "#{zip_name}.zip" : "#{to_dir}/#{zip_name}.zip" cmd = [] cmd << "cd" << File.dirname(path) cmd << "&& zip -r --symlinks" << out_path << basename cmd << "&& cd -" `#{cmd.join(" ")}` end def self.unzip(path, to_dir: nil) cmd = [] cmd << "unzip -nq" << path cmd << "-d" << to_dir unless to_dir.nil? `#{cmd.join(" ")}` end end end