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.



117
118
119
120
# File 'lib/buildr/packaging/tar.rb', line 117

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)


127
128
129
130
131
# File 'lib/buildr/packaging/tar.rb', line 127

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)


137
138
139
# File 'lib/buildr/packaging/tar.rb', line 137

def empty?()
  read_content_from_tar.nil?
end

#exist?Boolean

:call-seq:

exist() => boolean

Returns true if this entry exists.

Returns:

  • (Boolean)


145
146
147
148
149
# File 'lib/buildr/packaging/tar.rb', line 145

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

#to_sObject

:nodoc:



151
152
153
# File 'lib/buildr/packaging/tar.rb', line 151

def to_s #:nodoc:
  @entry_name
end