class Distillery::Archiver::Archive
Allow archive file processing
All the operations are forwarded to an {Archiver} instance which is able to process the selected archive file.
Public Class Methods
Returns a new instance of Archive
.
@param file [String] file holding the archive
@raise [ArchiverNotFound] an archiver able to process this file
has not been found
# File lib/distillery/archiver/archive.rb, line 21 def initialize(file) @file = file @archiver = Archiver.for_file(file) if @archiver.nil? raise ArchiverNotFound, "no archiver avalaible for this file" end end
Public Instance Methods
Delete the entry from the archive
@param entry [String] entry name
@return [Boolean] operation status
# File lib/distillery/archiver/archive.rb, line 94 def delete!(entry) @archiver.delete!(@file, entry) end
Iterate over each archive entry
@yieldparam entry [String] entry name @yieldparam io [InputStream] input stream
@return [self,Enumerator]
# File lib/distillery/archiver/archive.rb, line 38 def each(&block) @archiver.each(@file, &block) self end
Is the archive emtpy?
@return [Boolean]
# File lib/distillery/archiver/archive.rb, line 57 def empty? @archiver.empty?(@file) end
List of entries for the archive
@return [Array<String>]
# File lib/distillery/archiver/archive.rb, line 48 def entries @archiver.entries(@file) end
Allow to perform read operation on an archive entry
@param entry [String] entry name
@yieldparam io [InputStream] input stream for reading
@return block value
# File lib/distillery/archiver/archive.rb, line 70 def reader(entry, &block) @archiver.reader(@file, entry, &block) end
Allow to perform write operation on an archive entry
@param entry [String] entry name
@yieldparam io [OutputStream] output stream for writing
@return block value
# File lib/distillery/archiver/archive.rb, line 83 def writer(entry, &block) @archiver.writer(@file, entry, &block) end