Class: Textus::Application::Writes::Publish

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/application/writes/publish.rb

Overview

Copies nested-leaf entries to their ‘publish_each:` targets. Fires `:file_published` for each copy. Mirror of `Build` for the publish half — split out from the old Build per ADR 0007.

Instance Method Summary collapse

Constructor Details

#initialize(ctx:, bus:) ⇒ Publish

Returns a new instance of Publish.



8
9
10
11
# File 'lib/textus/application/writes/publish.rb', line 8

def initialize(ctx:, bus:)
  @ctx = ctx
  @bus = bus
end

Instance Method Details

#call(prefix: nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/textus/application/writes/publish.rb', line 13

def call(prefix: nil)
  repo_root = File.dirname(store.root)
  out = []
  manifest.entries.each do |mentry|
    next unless mentry.nested && mentry.publish_each
    next if prefix && !mentry.key.start_with?(prefix) && !prefix.start_with?("#{mentry.key}.")

    manifest.enumerate(prefix: mentry.key).each do |row|
      next unless row[:manifest_entry].equal?(mentry)
      next if prefix && !row[:key].start_with?(prefix) && row[:key] != prefix

      out << publish_leaf(mentry, row, repo_root)
    end
  end
  { "protocol" => Textus::PROTOCOL, "published_leaves" => out }
end