Class: Textus::Domain::Policy::PublishTarget

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/domain/policy/publish_target.rb

Overview

One publish destination (ADR 0094). Exactly one of:

to-target   { to:, template:?, inject_boot:? }  — render data through a
            template, or copy verbatim when no template
tree-target { tree: }                           — ADR 0052 subtree mirror

Provenance is NOT a publish flag — it lives in the data’s ‘_meta`.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ PublishTarget

Returns a new instance of PublishTarget.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/textus/domain/policy/publish_target.rb', line 12

def initialize(raw)
  if raw.key?("provenance")
    raise Textus::BadManifest.new("publish `provenance:` was removed (ADR 0094): provenance lives in the data's `_meta`")
  end

  @to   = raw["to"]
  @tree = raw["tree"]
  raise Textus::BadManifest.new("a publish target needs exactly one of `to:` or `tree:`") unless @to.nil? ^ @tree.nil?

  @template    = raw["template"]
  @inject_boot = raw["inject_boot"] == true
  return unless tree_target? && (@template || @inject_boot)

  raise Textus::BadManifest.new("a tree target takes no template/inject_boot (ADR 0094)")
end

Instance Attribute Details

#inject_bootObject (readonly)

Returns the value of attribute inject_boot.



10
11
12
# File 'lib/textus/domain/policy/publish_target.rb', line 10

def inject_boot
  @inject_boot
end

#templateObject (readonly)

Returns the value of attribute template.



10
11
12
# File 'lib/textus/domain/policy/publish_target.rb', line 10

def template
  @template
end

#toObject (readonly)

Returns the value of attribute to.



10
11
12
# File 'lib/textus/domain/policy/publish_target.rb', line 10

def to
  @to
end

#treeObject (readonly)

Returns the value of attribute tree.



10
11
12
# File 'lib/textus/domain/policy/publish_target.rb', line 10

def tree
  @tree
end

Instance Method Details

#renders?Boolean

Returns:

  • (Boolean)


30
# File 'lib/textus/domain/policy/publish_target.rb', line 30

def renders?     = to_target? && !@template.nil?

#to_target?Boolean

Returns:

  • (Boolean)


28
# File 'lib/textus/domain/policy/publish_target.rb', line 28

def to_target?   = !@to.nil?

#tree_target?Boolean

Returns:

  • (Boolean)


29
# File 'lib/textus/domain/policy/publish_target.rb', line 29

def tree_target? = !@tree.nil?