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.



41
42
43
44
# File 'lib/dependabot/command_helpers.rb', line 41

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

Instance Method Details

#exitstatusObject



48
49
50
# File 'lib/dependabot/command_helpers.rb', line 48

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

#pidObject



60
61
62
# File 'lib/dependabot/command_helpers.rb', line 60

def pid
  @process_status&.pid
end

#success?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/dependabot/command_helpers.rb', line 54

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

#termsigObject



65
66
67
# File 'lib/dependabot/command_helpers.rb', line 65

def termsig
  @process_status&.termsig
end

#to_sObject



71
72
73
74
75
76
77
# File 'lib/dependabot/command_helpers.rb', line 71

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