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.



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

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)


163
164
165
166
167
# File 'lib/buildr/packaging/tar.rb', line 163

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)


173
174
175
# File 'lib/buildr/packaging/tar.rb', line 173

def empty?()
  read_content_from_tar.nil?
end

#exist?Boolean

:call-seq:

exist() => boolean

Returns true if this entry exists.

Returns:

  • (Boolean)


181
182
183
184
185
# File 'lib/buildr/packaging/tar.rb', line 181

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

#to_sObject

:nodoc:



187
188
189
# File 'lib/buildr/packaging/tar.rb', line 187

def to_s #:nodoc:
  @entry_name
end