LemonCore.Doctor.Report (lemon_core v0.1.0)

View Source

Aggregates diagnostic check results and renders them as text or JSON.

Usage

checks = [...list of %Check{}...]
report = Report.from_checks(checks)

Report.print(report)                     # human-readable output
Report.print(report, verbose: true)      # include pass/skip details
Report.to_json(report)                   # JSON string
Report.ok?(report)                       # true if no failures

Summary

Functions

Builds a Report from a list of Check structs.

Returns true when no checks have :fail status.

Returns the overall status atom (:pass, :warn, or :fail).

Prints a formatted report to the Mix shell.

Serialises the report to a JSON string.

Types

t()

@type t() :: %LemonCore.Doctor.Report{
  checks: [LemonCore.Doctor.Check.t()],
  fail: non_neg_integer(),
  pass: non_neg_integer(),
  skip: non_neg_integer(),
  warn: non_neg_integer()
}

Functions

from_checks(checks)

@spec from_checks([LemonCore.Doctor.Check.t()]) :: t()

Builds a Report from a list of Check structs.

ok?(report)

@spec ok?(t()) :: boolean()

Returns true when no checks have :fail status.

overall(report)

@spec overall(t()) :: :pass | :warn | :fail

Returns the overall status atom (:pass, :warn, or :fail).

print(report, opts \\ [])

@spec print(
  t(),
  keyword()
) :: :ok

Prints a formatted report to the Mix shell.

Options

  • :verbose - include pass and skip results (default: false)

to_json(report)

@spec to_json(t()) :: String.t()

Serialises the report to a JSON string.