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.
22 23 24 25 26 |
# File 'lib/textus/write/build.rb', line 22 def initialize(container:, call:) @container = container @call = call @manifest = container.manifest end |
Instance Method Details
#call(prefix: nil) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/textus/write/build.rb', line 28 def call(prefix: nil) build_role = @manifest.policy.actor_for("build") or raise Textus::UsageError.new( "no role holds the 'build' capability", hint: "declare a role with `can: [build]` in .textus/manifest.yaml", ) build_call = Textus::Call.build( role: build_role, correlation_id: @call.correlation_id, dry_run: @call.dry_run, ) built = [] leaves = [] pruned = [] context = build_context(build_call) @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 |