Class: Graphiti::Audit::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/graphiti/audit/report.rb

Defined Under Namespace

Classes: Cell

Constant Summary collapse

ANSI =
{red: 31, green: 32, yellow: 33, blue: 34, magenta: 35, cyan: 36, bold: 1, dim: 2}.freeze
ISSUE_HEADINGS =
{
  broken_relationship: "raised while being inspected",
  missing_association_method: "will raise when the relationship is included: the model has no association method",
  missing_guard_method: "will raise whenever the resource renders: the readable guard is not defined",
  missing_sideload_filter: "will raise when the relationship is included: the related resource is missing the filter"
}.freeze
CHECKLIST =
{
  broken_relationship: ["all relationships inspectable", "relationship", "raised while being inspected"],
  missing_association_method: ["all association methods defined", "association method", "missing"],
  missing_guard_method: ["all readable guards defined", "readable guard", "missing"],
  missing_sideload_filter: ["all sideload filters declared", "sideload filter", "missing"],
  loads_on_every_render: ["all id-rendering loads preloaded", "relationship", "loading ids without preloading"]
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(rows, color: $stdout.tty?) ⇒ Report

Returns a new instance of Report.



27
28
29
30
# File 'lib/graphiti/audit/report.rb', line 27

def initialize(rows, color: $stdout.tty?)
  @rows = rows
  @color = color
end

Instance Method Details

#to_sObject



32
33
34
35
36
# File 'lib/graphiti/audit/report.rb', line 32

def to_s
  return "graphiti: no relationships found.\n" if @rows.empty?

  (body + [summary]).join("\n")
end