Class Capistrano::Transfer
In: lib/capistrano/transfer.rb
lib/capistrano/transfer.rb
Parent: Object

Methods

Included Modules

Processable Processable

Classes and Modules

Class Capistrano::Transfer::SFTPTransferWrapper

Attributes

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

Public Class methods

[Source]

    # File lib/capistrano/transfer.rb, line 26
26:     def initialize(direction, from, to, sessions, options={}, &block)
27:       @direction = direction
28:       @from      = from
29:       @to        = to
30:       @sessions  = sessions
31:       @options   = options
32:       @callback  = block
33: 
34:       @transport = options.fetch(:via, :sftp)
35:       @logger    = options.delete(:logger)
36: 
37:       @session_map = {}
38: 
39:       prepare_transfers
40:     end

[Source]

    # File lib/capistrano/transfer.rb, line 26
26:     def initialize(direction, from, to, sessions, options={}, &block)
27:       @direction = direction
28:       @from      = from
29:       @to        = to
30:       @sessions  = sessions
31:       @options   = options
32:       @callback  = block
33: 
34:       @transport = options.fetch(:via, :sftp)
35:       @logger    = options.delete(:logger)
36: 
37:       @session_map = {}
38: 
39:       prepare_transfers
40:     end

[Source]

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

[Source]

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

Public Instance methods

[Source]

    # File lib/capistrano/transfer.rb, line 70
70:     def active?
71:       transfers.any? { |transfer| transfer.active? }
72:     end

[Source]

    # File lib/capistrano/transfer.rb, line 70
70:     def active?
71:       transfers.any? { |transfer| transfer.active? }
72:     end

[Source]

    # File lib/capistrano/transfer.rb, line 74
74:     def operation
75:       "#{direction}load"
76:     end

[Source]

    # File lib/capistrano/transfer.rb, line 74
74:     def operation
75:       "#{direction}load"
76:     end

[Source]

    # File lib/capistrano/transfer.rb, line 42
42:     def process!
43:       loop do
44:         begin
45:           break unless process_iteration { active? }
46:         rescue Exception => error
47:           if error.respond_to?(:session)
48:             handle_error(error)
49:           else
50:             raise
51:           end
52:         end
53:       end
54: 
55:       failed = transfers.select { |txfr| txfr[:failed] }
56:       if failed.any?
57:         hosts = failed.map { |txfr| txfr[:server] }
58:         errors = failed.map { |txfr| "#{txfr[:error]} (#{txfr[:error].message})" }.uniq.join(", ")
59:         error = TransferError.new("#{operation} via #{transport} failed on #{hosts.join(',')}: #{errors}")
60:         error.hosts = hosts
61: 
62:         logger.important(error.message) if logger
63:         raise error
64:       end
65: 
66:       logger.debug "#{transport} #{operation} complete" if logger
67:       self
68:     end

[Source]

    # File lib/capistrano/transfer.rb, line 42
42:     def process!
43:       loop do
44:         begin
45:           break unless process_iteration { active? }
46:         rescue Exception => error
47:           if error.respond_to?(:session)
48:             handle_error(error)
49:           else
50:             raise
51:           end
52:         end
53:       end
54: 
55:       failed = transfers.select { |txfr| txfr[:failed] }
56:       if failed.any?
57:         hosts = failed.map { |txfr| txfr[:server] }
58:         errors = failed.map { |txfr| "#{txfr[:error]} (#{txfr[:error].message})" }.uniq.join(", ")
59:         error = TransferError.new("#{operation} via #{transport} failed on #{hosts.join(',')}: #{errors}")
60:         error.hosts = hosts
61: 
62:         logger.important(error.message) if logger
63:         raise error
64:       end
65: 
66:       logger.debug "#{transport} #{operation} complete" if logger
67:       self
68:     end

[Source]

    # File lib/capistrano/transfer.rb, line 78
78:     def sanitized_from
79:       if from.responds_to?(:read)
80:         "#<#{from.class}>"
81:       else
82:         from
83:       end
84:     end

[Source]

    # File lib/capistrano/transfer.rb, line 78
78:     def sanitized_from
79:       if from.responds_to?(:read)
80:         "#<#{from.class}>"
81:       else
82:         from
83:       end
84:     end

[Source]

    # File lib/capistrano/transfer.rb, line 86
86:     def sanitized_to
87:       if to.responds_to?(:read)
88:         "#<#{to.class}>"
89:       else
90:         to
91:       end
92:     end

[Source]

    # File lib/capistrano/transfer.rb, line 86
86:     def sanitized_to
87:       if to.responds_to?(:read)
88:         "#<#{to.class}>"
89:       else
90:         to
91:       end
92:     end

[Validate]