class Distillery::Archiver::Zip
Use of rubyzip as archiver
Public Class Methods
new()
click to toggle source
# File lib/distillery/archiver/zip.rb, line 30 def initialize end
registering()
click to toggle source
Perform registration of the various archive format supported by this archiver provider
@return [void]
# File lib/distillery/archiver/zip.rb, line 25 def self.registering Archiver.register(Zip.new) end
Public Instance Methods
delete!(file, entry)
click to toggle source
(see Archiver#delete!
)
# File lib/distillery/archiver/zip.rb, line 46 def delete!(file, entry) ::Zip::File.open(file) {|zip_file| zip_file.remove(entry) ? true : false } rescue Errno::ENOENT false end
each(file, &block)
click to toggle source
(see Archiver#each
)
# File lib/distillery/archiver/zip.rb, line 73 def each(file, &block) return to_enum(:each, file) if block.nil? ::Zip::File.open(file) {|zip_file| zip_file.each {|zip_entry| next unless zip_entry.ftype == :file block.call(zip_entry.name, InputStream.new(zip_entry.get_input_stream)) } } end
extensions()
click to toggle source
(see Archiver#extensions
)
# File lib/distillery/archiver/zip.rb, line 34 def extensions [ 'zip' ] end
mimetypes()
click to toggle source
(see Archiver#mimetypes
)
# File lib/distillery/archiver/zip.rb, line 40 def mimetypes [ 'application/zip' ] end
reader(file, entry, &block)
click to toggle source
(see Archiver#reader
)
# File lib/distillery/archiver/zip.rb, line 55 def reader(file, entry, &block) ::Zip::File.open(file) {|zip_file| zip_file.get_input_stream(entry) {|is| block.call(InputStream.new(is)) } } end
writer(file, entry, &block)
click to toggle source
(see Archiver#writer
)
# File lib/distillery/archiver/zip.rb, line 64 def writer(file, entry, &block) ::Zip::File.open(file, ::Zip::File::CREATE) {|zip_file| zip_file.get_output_stream(entry) {|os| block.call(OutputStream.new(os)) } } end