Class: Insika::Soak::Report::Result

Inherits:
Data
  • Object
show all
Defined in:
lib/insika/soak/report.rb

Overview

The verdict plus its evidence. reasons name every breach; for a fail the report-only metrics point the leak hunt. :invalid carries NO metrics at all — a tampered file must not produce rates.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#envelope_shaObject (readonly)

Returns the value of attribute envelope_sha

Returns:

  • (Object)

    the current value of envelope_sha



18
19
20
# File 'lib/insika/soak/report.rb', line 18

def envelope_sha
  @envelope_sha
end

#metricsObject (readonly)

Returns the value of attribute metrics

Returns:

  • (Object)

    the current value of metrics



18
19
20
# File 'lib/insika/soak/report.rb', line 18

def metrics
  @metrics
end

#reasonsObject (readonly)

Returns the value of attribute reasons

Returns:

  • (Object)

    the current value of reasons



18
19
20
# File 'lib/insika/soak/report.rb', line 18

def reasons
  @reasons
end

#run_idObject (readonly)

Returns the value of attribute run_id

Returns:

  • (Object)

    the current value of run_id



18
19
20
# File 'lib/insika/soak/report.rb', line 18

def run_id
  @run_id
end

#verdictObject (readonly)

Returns the value of attribute verdict

Returns:

  • (Object)

    the current value of verdict



18
19
20
# File 'lib/insika/soak/report.rb', line 18

def verdict
  @verdict
end

Instance Method Details

#pass?Boolean

Returns:

  • (Boolean)


19
# File 'lib/insika/soak/report.rb', line 19

def pass? = verdict == :pass

#to_hObject



21
22
23
24
25
26
27
# File 'lib/insika/soak/report.rb', line 21

def to_h
  {
    "verdict" => verdict.to_s, "reasons" => reasons,
    "metrics" => metrics.each_with_object({}) { |(k, v), acc| acc[k.to_s] = v },
    "envelope_sha" => envelope_sha, "run_id" => run_id
  }
end

#to_s(color: false) ⇒ Object

Human report (Doctor::Report idiom).



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/insika/soak/report.rb', line 30

def to_s(color: false)
  head = "SOAK #{run_id}#{verdict.to_s.upcase}"
  head += "  [#{envelope_sha}]" unless envelope_sha.nil?
  lines = [head]
  unless reasons.empty?
    lines << "  breaches:"
    reasons.each { |r| lines << "    - #{r}" }
  end
  lines.concat(metric_lines) if verdict != :invalid
  lines << leak_hunt if verdict == :fail && leak_hunt
  lines.join("\n")
end