Class: Textus::Application::Write::Publish::Impl

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

Instance Method Summary collapse

Constructor Details

#initialize(ctx:, caps:, rpc:, session:, hook_context:) ⇒ Impl

Returns a new instance of Impl.



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/textus/application/write/publish.rb', line 23

def initialize(ctx:, caps:, rpc:, session:, hook_context:)
  @ctx          = ctx
  @caps         = caps
  @manifest     = caps.manifest
  @file_store   = caps.file_store
  @events       = caps.events
  @root         = caps.root
  @rpc          = rpc
  @session      = session
  @hook_context = hook_context
end

Instance Method Details

#call(prefix: nil) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/textus/application/write/publish.rb', line 35

def call(prefix: nil)
  built  = []
  leaves = []
  context = build_context

  @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 then leaves.concat(result[:value])
    end
  end

  { "protocol" => Textus::PROTOCOL, "built" => built, "published_leaves" => leaves }
end