Class: SSHake::BaseSession

Inherits:
Object
  • Object
show all
Defined in:
lib/sshake/base_session.rb

Direct Known Subclasses

Mock::Session, RecordedSession, Session

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*_args, klogger: nil, **options) ⇒ BaseSession

Returns a new instance of BaseSession.



26
27
28
29
# File 'lib/sshake/base_session.rb', line 26

def initialize(*_args, klogger: nil, **options)
  @id = SecureRandom.hex(4)
  @klogger = klogger || SSHake.klogger
end

Instance Attribute Details

#idString (readonly)

An ID for this session

Returns:

  • (String)


19
20
21
# File 'lib/sshake/base_session.rb', line 19

def id
  @id
end

#kloggerKlogger?

A logger for this session

Returns:

  • (Klogger, nil)


14
15
16
# File 'lib/sshake/base_session.rb', line 14

def klogger
  @klogger
end

#raise_on_errorBoolean

Specify the default behaviour for raising erors

Returns:

  • (Boolean)


24
25
26
# File 'lib/sshake/base_session.rb', line 24

def raise_on_error
  @raise_on_error
end

Instance Method Details

#connectvoid

This method returns an undefined value.

Connect to the SSH server



34
35
36
# File 'lib/sshake/base_session.rb', line 34

def connect
  raise 'Override #connect in sub-sessions'
end

#connected?Boolean

Is there an established SSH connection

Returns:

  • (Boolean)


41
42
43
# File 'lib/sshake/base_session.rb', line 41

def connected?
  raise 'Override #connected? in sub-sessions'
end

#disconnectvoid

This method returns an undefined value.

Disconnect the underlying SSH connection



48
49
50
# File 'lib/sshake/base_session.rb', line 48

def disconnect
  raise 'Override #disconnect in sub-sessions'
end

#execute(_commands, _options = nil) ⇒ Object

Execute a command



59
60
61
# File 'lib/sshake/base_session.rb', line 59

def execute(_commands, _options = nil)
  raise 'Override #execute in sub-sessions'
end

#kill!Object

Kill the underlying connection



53
54
55
# File 'lib/sshake/base_session.rb', line 53

def kill!
  raise 'Override #kill! in sub-sessions'
end

#write_data(_path, _data, _options = nil) ⇒ Object



63
64
65
# File 'lib/sshake/base_session.rb', line 63

def write_data(_path, _data, _options = nil)
  raise 'Override #write_data in sub-sessions'
end