Class: Textus::Write::Build
- Inherits:
-
Object
- Object
- Textus::Write::Build
- Extended by:
- Contract::DSL
- Defined in:
- lib/textus/write/build.rb
Overview
Single-pass build use case (the verb ‘build`, ADR 0061): dispatches polymorphically to each entry’s ‘publish_via` method — the copy-out step (`publish` is the output-destination concept the verb drives, not the verb). Derived entries materialize their body via Materializer; Nested entries mirror their subtree via publish_tree; Leaf and Intake entries copy their stored body to publish_to targets. The Build layer owns wiring (context, accumulation) but not per-kind logic.
Return shape: { “protocol”, “built”, “published_leaves” }
Instance Method Summary collapse
- #call(prefix: nil) ⇒ Object
-
#initialize(container:, call:) ⇒ Build
constructor
A new instance of Build.
Methods included from Contract::DSL
arg, around, cli, cli_stdin, contract, contract?, summary, surfaces, verb, view
Constructor Details
#initialize(container:, call:) ⇒ Build
Returns a new instance of Build.
21 22 23 24 25 |
# File 'lib/textus/write/build.rb', line 21 def initialize(container:, call:) @container = container @call = call @manifest = container.manifest end |
Instance Method Details
#call(prefix: nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/textus/write/build.rb', line 27 def call(prefix: nil) built = [] leaves = [] pruned = [] context = build_context @manifest.data.entries.each do |mentry| next if prefix && !entry_matches_prefix?(mentry, prefix) result = mentry.publish_via(context, prefix: prefix) next if result.nil? case result[:kind] when :built then built << result[:value] when :leaves leaves.concat(result[:value]) pruned.concat(result[:pruned]) if result[:pruned] end end { "protocol" => Textus::PROTOCOL, "built" => built, "published_leaves" => leaves, "pruned" => pruned } end |