Class: Textus::Manifest::Entry::Publish::SubtreeMirror

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/manifest/entry/publish/subtree_mirror.rb

Overview

ADR 0049: the one walk->publish->prune pipeline shared by EachDir (per-leaf subtree, ADR 0046) and Tree (whole-entry mirror, ADR 0047). The two used to be near-duplicate methods (publish_subtree + publish_tree_via, prune_orphans + prune_tree); their only real difference — whether the prune honors the entry’s ‘ignore` — is now the explicit `prune_honors_ignore:` parameter.

Instance Method Summary collapse

Constructor Details

#initialize(entry, pctx) ⇒ SubtreeMirror

Returns a new instance of SubtreeMirror.



12
13
14
15
# File 'lib/textus/manifest/entry/publish/subtree_mirror.rb', line 12

def initialize(entry, pctx)
  @entry = entry
  @pctx  = pctx
end

Instance Method Details

#mirror(base:, walk_root:, target_dir:, key:, envelope:, prune_honors_ignore:) ⇒ Object

base: store dir the entry owns — the root ‘ignored?` globs are

relative to (ADR 0042).

walk_root: dir the glob is rooted at (a single leaf dir for EachDir,

== base for Tree). dst paths mirror rel-to-walk_root.

target_dir: repo-side destination root. key/envelope: emitted per file; envelope is nil for the keyless Tree. prune_honors_ignore: when true a managed file the entry ‘ignore`s

survives the prune (ADR 0047 D4 — lets a derived index live in the
mirrored dir); when false every unwritten managed file is pruned.


26
27
28
29
30
31
# File 'lib/textus/manifest/entry/publish/subtree_mirror.rb', line 26

def mirror(base:, walk_root:, target_dir:, key:, envelope:, prune_honors_ignore:)
  return { written: [], pruned: [] } unless File.directory?(walk_root)

  written = publish_files(base: base, walk_root: walk_root, target_dir: target_dir, key: key, envelope: envelope)
  { written: written, pruned: prune(target_dir, written, prune_honors_ignore) }
end