Class: Zip::ZipEntry

Inherits:
Object show all
Defined in:
lib/buildr/packaging/zip.rb

Instance Method Summary collapse

Instance Method Details

#contain?(*patterns) ⇒ Boolean

:call-seq:

contain(patterns*) => boolean

Returns true if this ZIP file entry matches against all the arguments. An argument may be a string or regular expression.

Returns:

  • (Boolean)


66
67
68
69
70
# File 'lib/buildr/packaging/zip.rb', line 66

def contain?(*patterns)
  content = Zip::ZipFile.open(zipfile) { |zip| zip.file.read(@name) }
  patterns.map { |pattern| Regexp === pattern ? pattern : Regexp.new(Regexp.escape(pattern.to_s)) }.
    all? { |pattern| content =~ pattern }
end

#empty?Boolean

:call-seq:

empty?() => boolean

Returns true if this entry is empty.

Returns:

  • (Boolean)


57
58
59
# File 'lib/buildr/packaging/zip.rb', line 57

def empty?()
  Zip::ZipFile.open(zipfile) { |zip| zip.file.read(@name) }.empty?
end

#exist?Boolean

:call-seq:

exist() => boolean

Returns true if this entry exists.

Returns:

  • (Boolean)


49
50
51
# File 'lib/buildr/packaging/zip.rb', line 49

def exist?()
  Zip::ZipFile.open(zipfile) { |zip| zip.file.exist?(@name) }
end