Module: Capistrano::Distribution::Distributor::TarHelper

Included in:
CurlTar, Tar
Defined in:
lib/capistrano/distribution/distributor/tar_helper.rb

Overview

A mixin containing methods useful for distributors that extract Tar files.

Instance Method Summary collapse

Instance Method Details

#compression_optString (private)

Returns the tar compression option to use based on the Abstract#url attribute.

Raises:

  • (RuntimeError)

    if the compression option cannot be guessed.



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/capistrano/distribution/distributor/tar_helper.rb', line 15

def compression_opt
  case url.path
  when %r{\.(tar\.gz|tgz)$}
    '-z'
  when %r{\.(tar\.bz2|tbz2)$}
    '-j'
  when %r{\.tar$}
    ''
  else
    raise "Unable to guess decompression option for URL: #{url}"
  end
end

#strip_components_optString (private)



31
32
33
34
35
# File 'lib/capistrano/distribution/distributor/tar_helper.rb', line 31

def strip_components_opt
  path = subtree.to_s.slice %r#^/?(.*?)/?$#, 1
  components = path.split('/').size
  "--strip-components #{components}"
end