Class: Eco::API::UseCases::GraphQL::Samples::Pages::Template::Deploy::SyncReadiness
- Inherits:
-
Object
- Object
- Eco::API::UseCases::GraphQL::Samples::Pages::Template::Deploy::SyncReadiness
- Defined in:
- lib/eco/api/usecases/graphql/samples/pages/template/deploy/sync_readiness.rb
Overview
Sync-readiness monitoring.
Given a register subset (its entries) and the register's ACTIVE template, report which entries CAN sync vs which cannot — where "can sync" means: every field the template marks REQUIRED is present on the entry with a non-empty value AND typed correctly (the entry field's type matches the template field's type). This is the pre-flight an integration runs before pushing entries downstream, and the drift-detection the customer-facing integrations mandate needs.
Operates on raw docs (template doc + entry docs) so it is session-less and offline-runnable:
- template doc: the JSON the gem returns for a template (stages/sections/dataFields).
- entry docs: each register entry as { 'id' =>, 'fields' => [ id/label/type/value, ... ] } (or anything exposing the same shape). A field is matched to a template field by id first, then by label — mirroring how the pairing engine falls back.
monitor = SyncReadiness.new(template_doc: tpl, entries: [e1, e2, ...]) monitor.ready # => [EntryReadiness(ready: true), ...] monitor.not_ready # => [EntryReadiness(ready: false, ...), ...] monitor.summary # => { total:, ready:, not_ready: } monitor.report # => human summary
Defined Under Namespace
Classes: EntryReadiness
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
Instance Method Summary collapse
-
#initialize(template_doc:, entries:) ⇒ SyncReadiness
constructor
A new instance of SyncReadiness.
- #not_ready ⇒ Object
- #ready ⇒ Object
- #report ⇒ Object
- #summary ⇒ Object
- #to_h ⇒ Object
- #verdicts ⇒ Object
Constructor Details
#initialize(template_doc:, entries:) ⇒ SyncReadiness
Returns a new instance of SyncReadiness.
48 49 50 51 |
# File 'lib/eco/api/usecases/graphql/samples/pages/template/deploy/sync_readiness.rb', line 48 def initialize(template_doc:, entries:) @template_doc = template_doc || {} @entries = Array(entries) end |
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
44 45 46 |
# File 'lib/eco/api/usecases/graphql/samples/pages/template/deploy/sync_readiness.rb', line 44 def entries @entries end |
Instance Method Details
#not_ready ⇒ Object
61 62 63 |
# File 'lib/eco/api/usecases/graphql/samples/pages/template/deploy/sync_readiness.rb', line 61 def not_ready verdicts.reject(&:ready?) end |
#ready ⇒ Object
57 58 59 |
# File 'lib/eco/api/usecases/graphql/samples/pages/template/deploy/sync_readiness.rb', line 57 def ready verdicts.select(&:ready?) end |
#report ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/eco/api/usecases/graphql/samples/pages/template/deploy/sync_readiness.rb', line 73 def report lines = ["SYNC READINESS: #{summary[:ready]}/#{summary[:total]} entries ready"] not_ready.each do |v| lines << " * entry #{v.entry_id}: NOT READY" v.reasons.each { |r| lines << " - #{r}" } end lines.join("\n") end |
#summary ⇒ Object
65 66 67 |
# File 'lib/eco/api/usecases/graphql/samples/pages/template/deploy/sync_readiness.rb', line 65 def summary { total: verdicts.size, ready: ready.size, not_ready: not_ready.size } end |
#to_h ⇒ Object
69 70 71 |
# File 'lib/eco/api/usecases/graphql/samples/pages/template/deploy/sync_readiness.rb', line 69 def to_h { summary: summary, entries: verdicts.map(&:to_h) } end |
#verdicts ⇒ Object
53 54 55 |
# File 'lib/eco/api/usecases/graphql/samples/pages/template/deploy/sync_readiness.rb', line 53 def verdicts @verdicts ||= @entries.map { |entry| assess(entry) } end |