Module: Textus::Produce::Acquire::Projection::InjectMeta

Defined in:
lib/textus/produce/acquire/projection.rb

Overview

Injects provenance metadata as the first key in the serialized output. Carries only deterministic provenance (‘from`/`reduce`) — the volatile `generated_at` is deliberately NOT stamped, so the built artifact is content-addressed and a rebuild is a byte-for-byte no-op (ADR 0070). Build time lives out of the tracked artifact.

Class Method Summary collapse

Class Method Details

.call(content_hash, mentry) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/textus/produce/acquire/projection.rb', line 20

def self.call(content_hash, mentry)
  meta = {}
  if mentry.derived?
    src = mentry.source
    if src.projection?
      from = Array(src.select).compact
      meta["from"] = from unless from.empty?
      meta["reduce"] = src.transform if src.transform
    end
  end

  out = { "_meta" => meta }
  content_hash.each { |k, v| out[k] = v unless k == "_meta" }
  out
end