Class: Buildr::TarTask
- Inherits:
-
ArchiveTask
- Object
- Rake::FileTask
- ArchiveTask
- Buildr::TarTask
- Defined in:
- lib/buildr/packaging/tar.rb
Overview
The TarTask creates a new Tar file. You can include any number of files and and directories, use exclusion patterns, and include files into specific directories.
To create a GZipped Tar, either set the gzip option to true, or use the .tgz or .gz suffix.
For example:
tar("test.tgz").tap do |task|
task.include "srcs"
task.include "README", "LICENSE"
end
See Buildr#tar and ArchiveTask.
Instance Attribute Summary collapse
-
#gzip ⇒ Object
To create a GZipped Tar, either set this option to true, or use the .tgz/.gz suffix.
-
#mode ⇒ Object
Permission mode for files contained in the Tar.
Instance Method Summary collapse
-
#entries ⇒ Object
:nodoc:.
-
#entry(entry_name) ⇒ Object
:call-seq: entry(name) => Entry.
-
#initialize(*args, &block) ⇒ TarTask
constructor
:nodoc:.
-
#with_uncompressed_tar(&block) ⇒ Object
:call-seq: with_uncompressed_tar { |tar_entries| … }.
Methods inherited from ArchiveTask
#clean, #contain?, #empty?, #exclude, #include, #invoke_prerequisites, #merge, #needed?, #path, #root, #with
Methods inherited from Rake::FileTask
Constructor Details
#initialize(*args, &block) ⇒ TarTask
:nodoc:
40 41 42 43 44 |
# File 'lib/buildr/packaging/tar.rb', line 40 def initialize(*args, &block) #:nodoc: super self.gzip = name =~ /\.t?gz$/ self.mode = '0755' end |
Instance Attribute Details
#gzip ⇒ Object
To create a GZipped Tar, either set this option to true, or use the .tgz/.gz suffix.
36 37 38 |
# File 'lib/buildr/packaging/tar.rb', line 36 def gzip @gzip end |
#mode ⇒ Object
Permission mode for files contained in the Tar. Defaults to 0755.
38 39 40 |
# File 'lib/buildr/packaging/tar.rb', line 38 def mode @mode end |
Instance Method Details
#entries ⇒ Object
:nodoc:
56 57 58 59 60 |
# File 'lib/buildr/packaging/tar.rb', line 56 def entries() #:nodoc: tar_entries = nil with_uncompressed_tar { |tar| tar_entries = tar.entries } tar_entries end |
#entry(entry_name) ⇒ Object
:call-seq:
entry(name) => Entry
Returns a Tar file entry. You can use this to check if the entry exists and its contents, for example:
package(:tar).entry("src/LICENSE").should contain(/Apache Software License/)
52 53 54 |
# File 'lib/buildr/packaging/tar.rb', line 52 def entry(entry_name) Buildr::TarEntry.new(self, entry_name) end |
#with_uncompressed_tar(&block) ⇒ Object
:call-seq:
with_uncompressed_tar { |tar_entries| ... }
Yields an Archive::Tar::Minitar::Input object to the provided block. Opening, closing and Gzip-decompressing is automatically taken care of.
67 68 69 70 71 72 73 |
# File 'lib/buildr/packaging/tar.rb', line 67 def with_uncompressed_tar &block if gzip Zlib::GzipReader.open(name) { |tar| Archive::Tar::Minitar.open(tar, &block) } else Archive::Tar::Minitar.open(name, &block) end end |