Parent

Included Modules

Files

Class/Module Index [+]

Quicksearch

Capistrano::Transfer

Attributes

callback[R]
direction[R]
from[R]
logger[R]
options[R]
sessions[R]
to[R]
transfers[R]
transport[R]

Public Class Methods

new(direction, from, to, sessions, options={}, &block) click to toggle source
# File lib/capistrano/transfer.rb, line 26
def initialize(direction, from, to, sessions, options={}, &block)
  @direction = direction
  @from      = from
  @to        = to
  @sessions  = sessions
  @options   = options
  @callback  = block

  @transport = options.fetch(:via, :sftp)
  @logger    = options.delete(:logger)

  @session_map = {}

  prepare_transfers
end
process(direction, from, to, sessions, options={}, &block) click to toggle source
# File lib/capistrano/transfer.rb, line 10
def self.process(direction, from, to, sessions, options={}, &block)
  new(direction, from, to, sessions, options, &block).process!
end

Public Instance Methods

active?() click to toggle source
# File lib/capistrano/transfer.rb, line 70
def active?
  transfers.any? { |transfer| transfer.active? }
end
operation() click to toggle source
# File lib/capistrano/transfer.rb, line 74
def operation
  "#{direction}load"
end
process!() click to toggle source
# File lib/capistrano/transfer.rb, line 42
def process!
  loop do
    begin
      break unless process_iteration { active? }
    rescue Exception => error
      if error.respond_to?(:session)
        handle_error(error)
      else
        raise
      end
    end
  end

  failed = transfers.select { |txfr| txfr[:failed] }
  if failed.any?
    hosts = failed.map { |txfr| txfr[:server] }
    errors = failed.map { |txfr| "#{txfr[:error]} (#{txfr[:error].message})" }.uniq.join(", ")
    error = TransferError.new("#{operation} via #{transport} failed on #{hosts.join(',')}: #{errors}")
    error.hosts = hosts

    logger.important(error.message) if logger
    raise error
  end

  logger.debug "#{transport} #{operation} complete" if logger
  self
end
sanitized_from() click to toggle source
# File lib/capistrano/transfer.rb, line 78
def sanitized_from
  if from.responds_to?(:read)
    "#<#{from.class}>"
  else
    from
  end
end
sanitized_to() click to toggle source
# File lib/capistrano/transfer.rb, line 86
def sanitized_to
  if to.responds_to?(:read)
    "#<#{to.class}>"
  else
    to
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.