Class: Buildr::TarEntry

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(tar_task, entry_name) ⇒ TarEntry

Returns a new instance of TarEntry.



120
121
122
123
# File 'lib/buildr/packaging/tar.rb', line 120

def initialize(tar_task, entry_name)
  @tar_task = tar_task
  @entry_name = entry_name
end

Instance Method Details

#contain?(*patterns) ⇒ Boolean

:call-seq:

contain?(*patterns) => boolean

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

Returns:

  • (Boolean)


130
131
132
133
134
# File 'lib/buildr/packaging/tar.rb', line 130

def contain?(*patterns)
  content = read_content_from_tar
  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)


140
141
142
# File 'lib/buildr/packaging/tar.rb', line 140

def empty?()
  read_content_from_tar.nil?
end

#exist?Boolean

:call-seq:

exist() => boolean

Returns true if this entry exists.

Returns:

  • (Boolean)


148
149
150
151
152
# File 'lib/buildr/packaging/tar.rb', line 148

def exist?()
  exist = false
  @tar_task.with_uncompressed_tar { |tar| exist = tar.any? { |entry| entry.name == @entry_name } }
  exist
end

#to_sObject

:nodoc:



154
155
156
# File 'lib/buildr/packaging/tar.rb', line 154

def to_s #:nodoc:
  @entry_name
end