class Fulmar::Infrastructure::Model::Transfer::Tar

Implements the rsync transfer

Constants

DEFAULT_CONFIG

Public Class Methods

new(config) click to toggle source
# 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

Public Instance Methods

tar_command() click to toggle source

Build the rsync command from the given options

# File lib/fulmar/infrastructure/model/transfer/tar.rb, line 34
def tar_command
  "tar #{tar_command_options} '#{filename}' '#{config[:local_path]}'"
end
transfer() click to toggle source
# File lib/fulmar/infrastructure/model/transfer/tar.rb, line 27
def transfer
  prepare unless @prepared
  @local_shell.run tar_command
  filename
end

Protected Instance Methods

extension() click to toggle source
# File lib/fulmar/infrastructure/model/transfer/tar.rb, line 45
def extension
  @config[:tar][:format].blank? ? '.tar' : '.tar.' + @config[:tar][:format]
end
filename() click to toggle source
# File lib/fulmar/infrastructure/model/transfer/tar.rb, line 40
def filename
  return @config[:tar][:filename] unless @config[:tar][:filename].blank?
  @config[:tar][:file_base] + '_' + Time.now.strftime('%Y-%m-%d') + extension
end
tar_command_options() click to toggle source

Assembles all rsync command line parameters from the configuration options

# File lib/fulmar/infrastructure/model/transfer/tar.rb, line 50
def tar_command_options
  options = ['-c']
  options << '-j' if @config[:tar][:format] == 'bz2'
  options << '-z' if @config[:tar][:format] == 'gz'
  options << "--exclude #{@config[:tar][:exclude]}" if @config[:tar][:exclude]
  options << '-f'
  options.join(' ')
end