Class: Fulmar::Infrastructure::Model::Transfer::Tar

Inherits:
Base
  • Object
show all
Defined in:
lib/fulmar/infrastructure/model/transfer/tar.rb

Overview

Implements the rsync transfer

Constant Summary collapse

DEFAULT_CONFIG =
{
  tar: {
    format: 'gz', # 'bz2'
    file_base: nil,
    # exclude: "*.bak",
    # filename: "site.tar.gz"
  }
}

Instance Attribute Summary

Attributes inherited from Base

#config

Instance Method Summary collapse

Methods inherited from Base

config_hash, #prepare, #publish, #test_config

Constructor Details

#initialize(config) ⇒ Tar

Returns a new instance of Tar.



19
20
21
22
23
24
25
# File 'lib/fulmar/infrastructure/model/transfer/tar.rb', line 19

def initialize(config)
  @config = DEFAULT_CONFIG.deep_merge(config)

  @config[:tar][:file_base] = File.basename(@config[:local_path]) if @config[:tar][:file_base].nil?

  super(@config)
end

Instance Method Details

#tar_commandObject

Build the rsync command from the given options



34
35
36
# File 'lib/fulmar/infrastructure/model/transfer/tar.rb', line 34

def tar_command
  "tar #{tar_command_options} '#{filename}' '#{config[:local_path]}'"
end

#transferObject



27
28
29
30
31
# File 'lib/fulmar/infrastructure/model/transfer/tar.rb', line 27

def transfer
  prepare unless @prepared
  @local_shell.run tar_command
  filename
end