class SSHake::RecordedSession
Attributes
recorder[R]
session[R]
Public Class Methods
new(recorder, session, **options)
click to toggle source
Calls superclass method
SSHake::BaseSession::new
# File lib/sshake/recorded_session.rb, line 13 def initialize(recorder, session, **options) super @recorder = recorder @session = session end
Public Instance Methods
execute(commands, options = nil, &block)
click to toggle source
# File lib/sshake/recorded_session.rb, line 19 def execute(commands, options = nil, &block) options = create_options(options, block) command_to_execute = prepare_commands(commands, options) cached_response = @recorder.play(command_to_execute, options: options, connection: connection_hash) return cached_response if cached_response response = @session.execute(commands, options) record(command_to_execute, options, response) response end
Private Instance Methods
connection_hash()
click to toggle source
# File lib/sshake/recorded_session.rb, line 38 def connection_hash { host: @session.host, user: @session.user, port: @session.port } end
record(command, options, response)
click to toggle source
# File lib/sshake/recorded_session.rb, line 33 def record(command, options, response) @recorder.record(command, response, options: options, connection: connection_hash) @recorder.save end