Class: RailsDoctor::ToolRun

Inherits:
Struct
  • Object
show all
Defined in:
lib/rails_doctor/models.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**kwargs) ⇒ ToolRun

Returns a new instance of ToolRun.



77
78
79
80
81
82
83
# File 'lib/rails_doctor/models.rb', line 77

def initialize(**kwargs)
  super
  self.available = true if available.nil?
  self.skipped = false if skipped.nil?
  self.status ||= default_status
  self. ||= {}
end

Instance Attribute Details

#availableObject

Returns the value of attribute available

Returns:

  • (Object)

    the current value of available



63
64
65
# File 'lib/rails_doctor/models.rb', line 63

def available
  @available
end

#commandObject

Returns the value of attribute command

Returns:

  • (Object)

    the current value of command



63
64
65
# File 'lib/rails_doctor/models.rb', line 63

def command
  @command
end

#duration_msObject

Returns the value of attribute duration_ms

Returns:

  • (Object)

    the current value of duration_ms



63
64
65
# File 'lib/rails_doctor/models.rb', line 63

def duration_ms
  @duration_ms
end

#exit_statusObject

Returns the value of attribute exit_status

Returns:

  • (Object)

    the current value of exit_status



63
64
65
# File 'lib/rails_doctor/models.rb', line 63

def exit_status
  @exit_status
end

#metadataObject

Returns the value of attribute metadata

Returns:

  • (Object)

    the current value of metadata



63
64
65
# File 'lib/rails_doctor/models.rb', line 63

def 
  @metadata
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



63
64
65
# File 'lib/rails_doctor/models.rb', line 63

def name
  @name
end

#skip_reasonObject

Returns the value of attribute skip_reason

Returns:

  • (Object)

    the current value of skip_reason



63
64
65
# File 'lib/rails_doctor/models.rb', line 63

def skip_reason
  @skip_reason
end

#skippedObject

Returns the value of attribute skipped

Returns:

  • (Object)

    the current value of skipped



63
64
65
# File 'lib/rails_doctor/models.rb', line 63

def skipped
  @skipped
end

#statusObject

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



63
64
65
# File 'lib/rails_doctor/models.rb', line 63

def status
  @status
end

#stderrObject

Returns the value of attribute stderr

Returns:

  • (Object)

    the current value of stderr



63
64
65
# File 'lib/rails_doctor/models.rb', line 63

def stderr
  @stderr
end

#stdoutObject

Returns the value of attribute stdout

Returns:

  • (Object)

    the current value of stdout



63
64
65
# File 'lib/rails_doctor/models.rb', line 63

def stdout
  @stdout
end

Instance Method Details

#default_statusObject



104
105
106
107
108
109
# File 'lib/rails_doctor/models.rb', line 104

def default_status
  return "skipped" if skipped
  return "completed" if exit_status.nil? || exit_status.zero?

  "nonzero_exit"
end

#to_h(include_raw: false) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/rails_doctor/models.rb', line 85

def to_h(include_raw: false)
  hash = {
    name: name,
    available: available,
    skipped: skipped,
    command: command,
    exit_status: exit_status,
    duration_ms: duration_ms,
    skip_reason: skip_reason,
    status: status,
    metadata: 
  }.compact
  if include_raw
    hash[:stdout] = stdout
    hash[:stderr] = stderr
  end
  hash
end