lib/em-ssh/shell.rb
# Connect to the server.
# Does not open the shell; use #open or #split
# You generally won't need to call this on your own.
Connect to the server.
Does not open the shell; use #open or #split
You generally won't need to call this on your own.
Connect to the server . Does not open the shell ; use #open or #split You generally won ' t need to call this on your own .
def connect
        return @session if connected?
        trace = caller
        f = Fiber.current
        ::EM::Ssh.start(host, user, connect_opts) do |connection|
          @connection = connection
          connection.callback do |ssh|
            f.resume(@session = ssh) if f.alive?
          end
          connection.errback do |e|
            e.set_backtrace(trace + Array(e.backtrace))
            f.resume(e) if f.alive?
          end
        end
        return Fiber.yield.tap { |r| raise r if r.is_a?(Exception) }
      end
def connect return @session if connected? trace = caller f = Fiber . current :: EM :: Ssh . start ( host , user , connect_opts ) do | connection | @connection = connection connection . callback do | ssh | f . resume ( @session = ssh ) if f . alive? end connection . errback do | e | e . set_backtrace ( trace + Array ( e . backtrace ) ) f . resume ( e ) if f . alive? end end return Fiber . yield . tap { | r | raise r if r . is_a? ( Exception ) } end
Connect to the server.
Connect to the server .