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

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

Overview

Pluggable post-deploy verification interface.

The deploy loop wants to run the freshly-deployed template through a check framework (ideally the ecoportal-qa gem's check runner). But ecoportal-qa is NOT a hard dependency of eco-helpers, so we do not require it here. Instead the loop calls a small Verifier interface; a concrete verifier is injected. When ecoportal-qa IS on the load path, QaVerifier wires it in; when it isn't, NullVerifier (always-pass, records that qa was unavailable) keeps the loop runnable offline.

A verifier receives the post-deploy template doc and returns a Verdict.

verdict = Verifier.default.verify(post_deploy_doc) verdict.pass? # => true/false verdict.findings # => [ message:, ... ]

Defined Under Namespace

Classes: NullVerifier, QaVerifier, Verdict

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.defaultObject

The verifier the loop uses when none is injected: qa if available, else the null verifier.



43
44
45
# File 'lib/eco/api/usecases/graphql/samples/pages/template/deploy/verifier.rb', line 43

def self.default
  qa_available? ? QaVerifier.new : NullVerifier.new
end

.qa_available?Boolean

Is the ecoportal-qa check framework loadable?

Returns:

  • (Boolean)


48
49
50
51
52
53
54
55
56
57
# File 'lib/eco/api/usecases/graphql/samples/pages/template/deploy/verifier.rb', line 48

def self.qa_available?
  return @qa_available unless @qa_available.nil?

  @qa_available = begin
    require 'ecoportal/qa'
    defined?(::Ecoportal::QA) ? true : false
  rescue LoadError
    false
  end
end

.reset_qa_probe!Object

Reset the memoised availability probe (used by specs that stub the load path).



60
61
62
# File 'lib/eco/api/usecases/graphql/samples/pages/template/deploy/verifier.rb', line 60

def self.reset_qa_probe!
  @qa_available = nil
end

Instance Method Details

#verify(_template_doc) ⇒ Object

Subclass / duck-type contract: return a Verdict for the given template doc.

Raises:

  • (NotImplementedError)


65
66
67
# File 'lib/eco/api/usecases/graphql/samples/pages/template/deploy/verifier.rb', line 65

def verify(_template_doc)
  raise NotImplementedError, "#{self.class} must implement #verify(template_doc)"
end