Class: Textus::Protocol::Manifest::Entry::Publish::Tree
- Inherits:
-
Mode
- Object
- Mode
- Textus::Protocol::Manifest::Entry::Publish::Tree
show all
- Defined in:
- lib/textus/protocol/manifest/entry/publish.rb
Overview
publish.tree: mirror this entry's whole subtree to one target dir.
Instance Attribute Summary
Attributes inherited from Mode
#entry
Instance Method Summary
collapse
Methods inherited from Mode
#initialize
Instance Method Details
#keyless? ⇒ Boolean
128
|
# File 'lib/textus/protocol/manifest/entry/publish.rb', line 128
def keyless? = true
|
#publish(pctx, prefix: nil) ⇒ Object
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
# File 'lib/textus/protocol/manifest/entry/publish.rb', line 130
def publish(pctx, prefix: nil)
target_rel = entry.publish_tree
target_dir = repo_abs(pctx, target_rel)
unless inside_repo?(pctx, target_dir)
raise Textus::PublishError.new(
"entry '#{entry.key}': publish_tree target '#{target_rel}' escapes repo root",
)
end
result = SubtreeMirror.new(entry, pctx).mirror(
walk_root: store_base(pctx),
target_dir: target_dir,
key: entry.key,
envelope: nil,
)
{ kind: :leaves, value: result[:written], pruned: result[:pruned] }
end
|
#validate! ⇒ Object
148
149
150
151
152
153
154
155
156
157
158
159
|
# File 'lib/textus/protocol/manifest/entry/publish.rb', line 148
def validate!
publish_tree = entry.publish_tree
raise UsageError.new("entry '#{entry.key}': publish.tree must be a string") unless publish_tree.is_a?(String)
used_vars = publish_tree.scan(/\{([a-z]+)\}/).flatten
return if used_vars.empty?
raise UsageError.new(
"entry '#{entry.key}': publish.tree names a single directory and takes no template variable(s) " \
"#{used_vars.map { |v| "{#{v}}" }.join(", ")} — it mirrors the whole subtree to one target dir.",
)
end
|