Sha256: 6a224884f059676979e68b58857a775d349583b6d566a2ccbc7bb8d3f628b0ce
Contents?: true
Size: 833 Bytes
Versions: 33
Compression:
Stored size: 833 Bytes
Contents
require 'zip' module Pageflow module EntryExportImport # Read and write files from and to zip archives class ZipArchive def initialize(file_name) Zip.force_entry_names_encoding = 'UTF-8' Zip.write_zip64_support = true @file = Zip::File.open(file_name, Zip::File::CREATE) end def include?(path) @file.find_entry(path).present? end def glob(pattern) @file.glob(pattern).map(&:name) end def add(path, stream) @file.get_output_stream(path) { |f| IO.copy_stream(stream, f) } end def extract_to_tempfile(path) Tempfile.open do |f| IO.copy_stream(@file.get_input_stream(path), f) f.rewind yield f end end def close @file.close end end end end
Version data entries
33 entries across 33 versions & 1 rubygems