Class: Textus::Manifest::Entry::Publish::EachDir

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

Overview

publish_each + index_filename (ADR 0046): each leaf is a whole subtree copied into one templated directory, layout preserved, then pruned. The template names the target DIRECTORY (not the index file).

Instance Attribute Summary

Attributes inherited from Mode

#entry

Instance Method Summary collapse

Methods inherited from Each

#publish, #target_for

Methods inherited from Mode

#initialize

Constructor Details

This class inherits a constructor from Textus::Manifest::Entry::Publish::Mode

Instance Method Details

#publish_leaf(row, target_abs, pctx) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/textus/manifest/entry/publish/each_dir.rb', line 9

def publish_leaf(row, target_abs, pctx)
  SubtreeMirror.new(entry, pctx).mirror(
    base: store_base(pctx),
    walk_root: File.dirname(row[:path]),
    target_dir: target_abs,
    key: row[:key],
    envelope: pctx.reader.call(row[:key]),
    prune_honors_ignore: false,
  )
end

#validate!Object

Raises:



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/textus/manifest/entry/publish/each_dir.rb', line 20

def validate!
  used_vars = validate_template_basics
  reject_file_only_vars(used_vars)
  reject_index_filename_segment
  reject_file_looking_segment
  return if used_vars.intersect?(%w[leaf key])

  raise UsageError.new(
    "entry '#{entry.key}': directory-leaf publish_each must reference {leaf} or {key} " \
    "(else every leaf would clobber the same directory).",
  )
end