Class: Textus::Manifest::Entry::Publish::Each
- Defined in:
- lib/textus/manifest/entry/publish/each.rb
Overview
Shared base for the two key-driven publish_each modes (EachFile, EachDir). Owns the leaf enumeration, the ‘…` target templating, and the per-leaf repo-escape guard. Subclasses implement `#publish_leaf`, returning `{ written:, pruned: }`, and the discriminator half of `#validate!`.
Instance Attribute Summary
Attributes inherited from Mode
Instance Method Summary collapse
- #publish(pctx, prefix: nil) ⇒ Object
-
#target_for(full_key) ⇒ Object
Expand this entry’s publish_each template for a full leaf key.
Methods inherited from Mode
Constructor Details
This class inherits a constructor from Textus::Manifest::Entry::Publish::Mode
Instance Method Details
#publish(pctx, prefix: nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/textus/manifest/entry/publish/each.rb', line 11 def publish(pctx, prefix: nil) leaves = [] pruned = [] pctx.manifest.resolver.enumerate(prefix: entry.key).each do |row| next unless row[:manifest_entry].equal?(entry) next if prefix && !row[:key].start_with?(prefix) && row[:key] != prefix target_abs = guarded_target(pctx, row) result = publish_leaf(row, target_abs, pctx) pruned.concat(result[:pruned]) result[:written].each do |w| leaves << { "key" => row[:key], "source" => w["source"], "target" => w["target"] } end end { kind: :leaves, value: leaves, pruned: pruned } end |
#target_for(full_key) ⇒ Object
Expand this entry’s publish_each template for a full leaf key.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/textus/manifest/entry/publish/each.rb', line 30 def target_for(full_key) entry_segs = entry.key.split(".") key_segs = full_key.split(".") raise UsageError.new("key '#{full_key}' is not under entry '#{entry.key}'") unless key_segs[0, entry_segs.length] == entry_segs remaining = key_segs[entry_segs.length..] || [] Template.( entry.publish_each, "leaf" => remaining.join("/"), "basename" => remaining.last || "", "key" => full_key, "ext" => ext, ) end |