Class: Eco::API::UseCases::GraphQL::Samples::Pages::Template::Deploy::Verifier::Verdict

Inherits:
Struct
  • Object
show all
Defined in:
lib/eco/api/usecases/graphql/samples/pages/template/deploy/verifier.rb

Overview

A verification verdict. pass? is the gate; findings carries per-check detail.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#findingsObject

Returns the value of attribute findings

Returns:

  • (Object)

    the current value of findings



19
20
21
# File 'lib/eco/api/usecases/graphql/samples/pages/template/deploy/verifier.rb', line 19

def findings
  @findings
end

#passObject

Returns the value of attribute pass

Returns:

  • (Object)

    the current value of pass



19
20
21
# File 'lib/eco/api/usecases/graphql/samples/pages/template/deploy/verifier.rb', line 19

def pass
  @pass
end

#verifierObject

Returns the value of attribute verifier

Returns:

  • (Object)

    the current value of verifier



19
20
21
# File 'lib/eco/api/usecases/graphql/samples/pages/template/deploy/verifier.rb', line 19

def verifier
  @verifier
end

Instance Method Details

#failuresObject



24
25
26
# File 'lib/eco/api/usecases/graphql/samples/pages/template/deploy/verifier.rb', line 24

def failures
  Array(findings).select { |f| %i[error fail].include?((f[:severity] || f['severity'])&.to_sym) }
end

#pass?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/eco/api/usecases/graphql/samples/pages/template/deploy/verifier.rb', line 20

def pass?
  pass ? true : false
end

#reportObject



32
33
34
35
36
37
38
39
# File 'lib/eco/api/usecases/graphql/samples/pages/template/deploy/verifier.rb', line 32

def report
  head = "VERIFY (#{verifier}): #{pass? ? 'PASS' : 'FAIL'}"
  return head if Array(findings).empty?

  ([head] + Array(findings).map do |f|
    "  - [#{f[:severity] || f['severity']}] #{f[:message] || f['message']}"
  end).join("\n")
end

#to_hObject



28
29
30
# File 'lib/eco/api/usecases/graphql/samples/pages/template/deploy/verifier.rb', line 28

def to_h
  { pass: pass?, verifier: verifier, findings: Array(findings) }
end