Module: Textus::Builder::InjectMeta

Defined in:
lib/textus/builder/pipeline.rb

Class Method Summary collapse

Class Method Details

.call(content_hash, mentry) ⇒ Object

Returns a new hash with _meta as the first key, per SPEC §6 ordering. Carries only deterministic provenance (‘from`/`reduce`/`template`) — 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.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/textus/builder/pipeline.rb', line 12

def self.call(content_hash, mentry)
  meta = {}
  if mentry.is_a?(Textus::Manifest::Entry::Derived)
    src = mentry.source
    if src.is_a?(Textus::Manifest::Entry::Derived::Projection)
      from = Array(src.select).compact
      meta["from"] = from unless from.empty?
      meta["reduce"] = src.transform if src.transform
    end
  end
  meta["template"] = mentry.template if mentry.template

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