Class: Smith::Workflow::Graph::RuntimeReadinessReport

Inherits:
Object
  • Object
show all
Extended by:
Dry::Initializer
Defined in:
lib/smith/workflow/graph/runtime_readiness_report.rb

Instance Method Summary collapse

Instance Method Details

#diagnosticsObject



32
33
34
# File 'lib/smith/workflow/graph/runtime_readiness_report.rb', line 32

def diagnostics
  topology_report.diagnostics + runtime_diagnostics
end

#errorsObject



36
37
38
# File 'lib/smith/workflow/graph/runtime_readiness_report.rb', line 36

def errors
  diagnostics.select { |diagnostic| diagnostic.severity == :error }
end

#ready?Boolean Also known as: valid?

Returns:

  • (Boolean)


16
17
18
# File 'lib/smith/workflow/graph/runtime_readiness_report.rb', line 16

def ready?
  errors.empty?
end

#statusObject



21
22
23
24
25
26
# File 'lib/smith/workflow/graph/runtime_readiness_report.rb', line 21

def status
  return :not_ready if errors.any?
  return :warning if warnings.any?

  :ready
end

#suggestionsObject



44
45
46
# File 'lib/smith/workflow/graph/runtime_readiness_report.rb', line 44

def suggestions
  diagnostics.map(&:suggestion).compact.uniq
end

#to_hObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/smith/workflow/graph/runtime_readiness_report.rb', line 48

def to_h
  {
    status: status,
    workflow_class: workflow_class,
    topology_status: topology_status,
    ready: ready?,
    diagnostics: diagnostics.map(&:to_h),
    runtime_diagnostics: runtime_diagnostics.map(&:to_h),
    topology_diagnostics: topology_report.diagnostics.map(&:to_h),
    suggestions: suggestions,
    metrics: metrics,
    graph: topology_report.to_h
  }
end

#topology_statusObject



28
29
30
# File 'lib/smith/workflow/graph/runtime_readiness_report.rb', line 28

def topology_status
  topology_report.status
end

#warningsObject



40
41
42
# File 'lib/smith/workflow/graph/runtime_readiness_report.rb', line 40

def warnings
  diagnostics.select { |diagnostic| diagnostic.severity == :warning }
end