Module: Zip

Defined in:
lib/pik/contrib/unzip.rb,
lib/pik/contrib/zip/zip.rb,
lib/pik/contrib/zip/zipfilesystem.rb

Defined Under Namespace

Modules: ZipFileSystem Classes: Compressor, Decompressor, Deflater, Inflater, NullCompressor, NullDecompressor, NullInputStream, PassThruCompressor, PassThruDecompressor, ZipCentralDirectory, ZipCompressionMethodError, ZipDestinationFileExistsError, ZipEntry, ZipEntryExistsError, ZipEntryNameError, ZipEntrySet, ZipError, ZipExtraField, ZipFile, ZipInputStream, ZipInternalError, ZipOutputStream, ZipStreamableDirectory, ZipStreamableStream

Constant Summary collapse

VERSION =
'0.9.1'
RUBY_MINOR_VERSION =
RUBY_VERSION.split(".")[1].to_i
RUNNING_ON_WINDOWS =
/mswin32|cygwin|mingw|bccwin/ =~ RUBY_PLATFORM
EMPTY_FILE_RETURNS_EMPTY_STRING_FIRST =

Ruby 1.7.x compatibility In ruby 1.6.x and 1.8.0 reading from an empty stream returns an empty string the first time and then nil.

not so in 1.7.x
RUBY_MINOR_VERSION != 7

Class Method Summary collapse

Class Method Details

.fake_unzip(zipfilename, regexp, target_dir) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/pik/contrib/unzip.rb', line 5

def self.fake_unzip(zipfilename, regexp, target_dir)
  Zip::ZipFile.open(zipfilename) do |zipfile|
    Zip::ZipFile.foreach(zipfilename) do |entry|
      if regexp =~ entry.name
        zipfile.extract(entry, File.join(target_dir, File.basename(entry.name))) { true }
      end
    end
  end
end