Class: Textus::ManifestEntry
- Inherits:
-
Object
- Object
- Textus::ManifestEntry
- Defined in:
- lib/textus/manifest.rb
Constant Summary collapse
- PUBLISH_EACH_VARS =
%w[leaf basename key ext].freeze
- PUBLISH_EACH_VAR_RE =
/\{([a-z]+)\}/
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#action_config ⇒ Object
readonly
Returns the value of attribute action_config.
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#generator ⇒ Object
readonly
Returns the value of attribute generator.
-
#inject_intro ⇒ Object
readonly
Returns the value of attribute inject_intro.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#nested ⇒ Object
readonly
Returns the value of attribute nested.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#projection ⇒ Object
readonly
Returns the value of attribute projection.
-
#publish_each ⇒ Object
readonly
Returns the value of attribute publish_each.
-
#publish_to ⇒ Object
readonly
Returns the value of attribute publish_to.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
-
#ttl ⇒ Object
readonly
Returns the value of attribute ttl.
-
#zone ⇒ Object
readonly
Returns the value of attribute zone.
Instance Method Summary collapse
- #derived? ⇒ Boolean
-
#initialize(manifest, raw) ⇒ ManifestEntry
constructor
A new instance of ManifestEntry.
-
#publish_target_for(full_key) ⇒ Object
Resolves the per-leaf target path (relative to repo root) for a full dotted key under this entry’s prefix.
Constructor Details
#initialize(manifest, raw) ⇒ ManifestEntry
Returns a new instance of ManifestEntry.
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/textus/manifest.rb', line 205 def initialize(manifest, raw) @manifest = manifest @raw = raw @key = raw["key"] or raise UsageError.new("manifest entry missing key") @path = raw["path"] or raise UsageError.new("manifest entry '#{@key}' missing path") @zone = raw["zone"] or raise UsageError.new("manifest entry '#{@key}' missing zone") @schema = raw["schema"] @owner = raw["owner"] @nested = raw["nested"] == true @generator = raw["generator"] @projection = raw["projection"] @template = raw["template"] @publish_to = Array(raw["publish_to"]) @publish_each = raw["publish_each"] @events = raw["events"] || {} @inject_intro = raw["inject_intro"] == true @format = resolve_format!(raw["format"]) reject_legacy!(raw) parse_source!(raw["source"]) validate_format_matrix! validate_publish_each! validate_inject_intro! end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
201 202 203 |
# File 'lib/textus/manifest.rb', line 201 def action @action end |
#action_config ⇒ Object (readonly)
Returns the value of attribute action_config.
201 202 203 |
# File 'lib/textus/manifest.rb', line 201 def action_config @action_config end |
#events ⇒ Object (readonly)
Returns the value of attribute events.
201 202 203 |
# File 'lib/textus/manifest.rb', line 201 def events @events end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
201 202 203 |
# File 'lib/textus/manifest.rb', line 201 def format @format end |
#generator ⇒ Object (readonly)
Returns the value of attribute generator.
201 202 203 |
# File 'lib/textus/manifest.rb', line 201 def generator @generator end |
#inject_intro ⇒ Object (readonly)
Returns the value of attribute inject_intro.
201 202 203 |
# File 'lib/textus/manifest.rb', line 201 def inject_intro @inject_intro end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
201 202 203 |
# File 'lib/textus/manifest.rb', line 201 def key @key end |
#nested ⇒ Object (readonly)
Returns the value of attribute nested.
201 202 203 |
# File 'lib/textus/manifest.rb', line 201 def nested @nested end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
201 202 203 |
# File 'lib/textus/manifest.rb', line 201 def owner @owner end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
201 202 203 |
# File 'lib/textus/manifest.rb', line 201 def path @path end |
#projection ⇒ Object (readonly)
Returns the value of attribute projection.
201 202 203 |
# File 'lib/textus/manifest.rb', line 201 def projection @projection end |
#publish_each ⇒ Object (readonly)
Returns the value of attribute publish_each.
201 202 203 |
# File 'lib/textus/manifest.rb', line 201 def publish_each @publish_each end |
#publish_to ⇒ Object (readonly)
Returns the value of attribute publish_to.
201 202 203 |
# File 'lib/textus/manifest.rb', line 201 def publish_to @publish_to end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
201 202 203 |
# File 'lib/textus/manifest.rb', line 201 def raw @raw end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
201 202 203 |
# File 'lib/textus/manifest.rb', line 201 def schema @schema end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
201 202 203 |
# File 'lib/textus/manifest.rb', line 201 def template @template end |
#ttl ⇒ Object (readonly)
Returns the value of attribute ttl.
201 202 203 |
# File 'lib/textus/manifest.rb', line 201 def ttl @ttl end |
#zone ⇒ Object (readonly)
Returns the value of attribute zone.
201 202 203 |
# File 'lib/textus/manifest.rb', line 201 def zone @zone end |
Instance Method Details
#derived? ⇒ Boolean
249 250 251 252 253 254 |
# File 'lib/textus/manifest.rb', line 249 def derived? writers = @manifest.zone_writers(@zone) writers.include?("build") rescue UsageError => e raise UsageError.new("entry '#{@key}': #{e.}") end |
#publish_target_for(full_key) ⇒ Object
Resolves the per-leaf target path (relative to repo root) for a full dotted key under this entry’s prefix. Returns nil if this entry has no publish_each template.
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/textus/manifest.rb', line 233 def publish_target_for(full_key) return nil if @publish_each.nil? entry_segs = @key.split(".") key_segs = full_key.split(".") raise UsageError.new("key '#{full_key}' is not under entry '#{@key}'") unless key_segs[0, entry_segs.length] == entry_segs remaining = key_segs[entry_segs.length..] || [] leaf = remaining.join("/") basename = remaining.last || "" ext = Entry.for_format(@format).extensions.first.to_s.sub(/^\./, "") vars = { "leaf" => leaf, "basename" => basename, "key" => full_key, "ext" => ext } @publish_each.gsub(PUBLISH_EACH_VAR_RE) { vars.fetch(::Regexp.last_match(1)) } end |