Class: Sxn::Security::SecureCommandExecutor::CommandResult

Inherits:
Object
  • Object
show all
Defined in:
lib/sxn/security/secure_command_executor.rb

Overview

Command execution result

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exit_status, stdout, stderr, command, duration) ⇒ CommandResult

Returns a new instance of CommandResult.



26
27
28
29
30
31
32
# File 'lib/sxn/security/secure_command_executor.rb', line 26

def initialize(exit_status, stdout, stderr, command, duration)
  @exit_status = exit_status
  @stdout = stdout || ""
  @stderr = stderr || ""
  @command = command
  @duration = duration
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



24
25
26
# File 'lib/sxn/security/secure_command_executor.rb', line 24

def command
  @command
end

#durationObject (readonly)

Returns the value of attribute duration.



24
25
26
# File 'lib/sxn/security/secure_command_executor.rb', line 24

def duration
  @duration
end

#exit_statusObject (readonly)

Returns the value of attribute exit_status.



24
25
26
# File 'lib/sxn/security/secure_command_executor.rb', line 24

def exit_status
  @exit_status
end

#stderrObject (readonly)

Returns the value of attribute stderr.



24
25
26
# File 'lib/sxn/security/secure_command_executor.rb', line 24

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



24
25
26
# File 'lib/sxn/security/secure_command_executor.rb', line 24

def stdout
  @stdout
end

Instance Method Details

#failure?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/sxn/security/secure_command_executor.rb', line 38

def failure?
  !success?
end

#success?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/sxn/security/secure_command_executor.rb', line 34

def success?
  @exit_status.zero?
end

#to_hObject



42
43
44
45
46
47
48
49
50
51
# File 'lib/sxn/security/secure_command_executor.rb', line 42

def to_h
  {
    exit_status: @exit_status,
    stdout: @stdout,
    stderr: @stderr,
    command: @command,
    duration: @duration,
    success: success?
  }
end