Sha256: e6995d7e52932c46d486fc94e0c79a0233d5d1dd74035d320026dc5e2605fecd
Contents?: true
Size: 744 Bytes
Versions: 3
Compression:
Stored size: 744 Bytes
Contents
require 'zip' module Pageflow module EntryExportImport # Read and write files from and to zip archives class ZipArchive def initialize(file_name) @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
3 entries across 3 versions & 1 rubygems