Class: Capistrano::Forwarding::Remote

Inherits:
Object
  • Object
show all
Includes:
Processable
Defined in:
lib/capistrano/forwarding/remote.rb

Defined Under Namespace

Classes: Forwarding

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(forwardings, sessions, options = {}) ⇒ Remote

Returns a new instance of Remote.



62
63
64
65
66
67
68
69
70
# File 'lib/capistrano/forwarding/remote.rb', line 62

def initialize(forwardings, sessions, options = {})
  @forwardings = sessions.map do |session|
    forwardings.map do |forwarding|
      Forwarding.new(forwarding, session)
    end
  end.flatten
  @sessions = sessions
  @options = options
end

Instance Attribute Details

#forwardingsObject (readonly)

Returns the value of attribute forwardings.



56
57
58
# File 'lib/capistrano/forwarding/remote.rb', line 56

def forwardings
  @forwardings
end

#optionsObject (readonly)

Returns the value of attribute options.



56
57
58
# File 'lib/capistrano/forwarding/remote.rb', line 56

def options
  @options
end

#sessionsObject (readonly)

Returns the value of attribute sessions.



56
57
58
# File 'lib/capistrano/forwarding/remote.rb', line 56

def sessions
  @sessions
end

Class Method Details

.forward(forwardings, sessions, options = {}, &block) ⇒ Object



58
59
60
# File 'lib/capistrano/forwarding/remote.rb', line 58

def self.forward(forwardings, sessions, options = {}, &block)
  new(forwardings, sessions, options).forward!(&block)
end

Instance Method Details

#forward! {|sessions| ... } ⇒ Object

Yields:



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/capistrano/forwarding/remote.rb', line 72

def forward!
  start(options[:timeout])

  # If we use run or similar command in the block for the connections,
  # the forwardings are also processed by the loop of these commands.
  # See lib/capistrano/command.rb and lib/capistrano/processable.rb.
  yield(sessions) if block_given?

  # Since we may still have channels which are not completely processed by the
  # loop of these commands, run the loop for taking care of them until
  # all channels has been gone.
  loop unless options[:no_wait]

  stop(options[:timeout])
end