Class: Dependabot::CommandHelpers::ProcessStatus

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/command_helpers.rb

Instance Method Summary collapse

Constructor Details

#initialize(process_status, custom_exitstatus = nil) ⇒ ProcessStatus

Returns a new instance of ProcessStatus.



38
39
40
41
# File 'lib/dependabot/command_helpers.rb', line 38

def initialize(process_status, custom_exitstatus = nil)
  @process_status = process_status
  @custom_exitstatus = custom_exitstatus
end

Instance Method Details

#exitstatusObject



45
46
47
# File 'lib/dependabot/command_helpers.rb', line 45

def exitstatus
  @custom_exitstatus || @process_status&.exitstatus || 0
end

#pidObject



57
58
59
# File 'lib/dependabot/command_helpers.rb', line 57

def pid
  @process_status&.pid
end

#success?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/dependabot/command_helpers.rb', line 51

def success?
  @custom_exitstatus.nil? ? @process_status&.success? || false : @custom_exitstatus.zero?
end

#termsigObject



62
63
64
# File 'lib/dependabot/command_helpers.rb', line 62

def termsig
  @process_status&.termsig
end

#to_sObject



68
69
70
71
72
73
74
# File 'lib/dependabot/command_helpers.rb', line 68

def to_s
  if @custom_exitstatus
    "pid #{pid || 'unknown'}: exit #{@custom_exitstatus} (custom status)"
  else
    @process_status&.to_s || "unknown status"
  end
end