Class: Textus::Manifest::Entry
- Inherits:
-
Object
- Object
- Textus::Manifest::Entry
- Defined in:
- lib/textus/manifest/entry.rb
Constant Summary collapse
- PUBLISH_EACH_VARS =
%w[leaf basename key ext].freeze
- PUBLISH_EACH_VAR_RE =
/\{([a-z]+)\}/
Instance Attribute Summary collapse
-
#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.
-
#intake_config ⇒ Object
readonly
Returns the value of attribute intake_config.
-
#intake_handler ⇒ Object
readonly
Returns the value of attribute intake_handler.
-
#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.
-
#zone ⇒ Object
readonly
Returns the value of attribute zone.
Instance Method Summary collapse
-
#derived? ⇒ Boolean
Legacy alias for in_generator_zone?.
-
#in_generator_zone? ⇒ Boolean
Signal-based zone-kind predicates: derive the “kind” of a zone from its writable_by signals rather than its literal name.
- #in_proposal_zone? ⇒ Boolean
-
#initialize(manifest, raw) ⇒ Entry
constructor
A new instance of Entry.
-
#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) ⇒ Entry
Returns a new instance of Entry.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/textus/manifest/entry.rb', line 12 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"]) validate_events! raise UsageError.new("entry '#{@key}': 'source:' key renamed to 'intake:' in 0.9") if raw.key?("source") parse_intake!(raw["intake"]) reject_legacy_projection_keys! validate_format_matrix! validate_publish_each! validate_inject_intro! end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
7 8 9 |
# File 'lib/textus/manifest/entry.rb', line 7 def events @events end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
7 8 9 |
# File 'lib/textus/manifest/entry.rb', line 7 def format @format end |
#generator ⇒ Object (readonly)
Returns the value of attribute generator.
7 8 9 |
# File 'lib/textus/manifest/entry.rb', line 7 def generator @generator end |
#inject_intro ⇒ Object (readonly)
Returns the value of attribute inject_intro.
7 8 9 |
# File 'lib/textus/manifest/entry.rb', line 7 def inject_intro @inject_intro end |
#intake_config ⇒ Object (readonly)
Returns the value of attribute intake_config.
7 8 9 |
# File 'lib/textus/manifest/entry.rb', line 7 def intake_config @intake_config end |
#intake_handler ⇒ Object (readonly)
Returns the value of attribute intake_handler.
7 8 9 |
# File 'lib/textus/manifest/entry.rb', line 7 def intake_handler @intake_handler end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
7 8 9 |
# File 'lib/textus/manifest/entry.rb', line 7 def key @key end |
#nested ⇒ Object (readonly)
Returns the value of attribute nested.
7 8 9 |
# File 'lib/textus/manifest/entry.rb', line 7 def nested @nested end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
7 8 9 |
# File 'lib/textus/manifest/entry.rb', line 7 def owner @owner end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/textus/manifest/entry.rb', line 7 def path @path end |
#projection ⇒ Object (readonly)
Returns the value of attribute projection.
7 8 9 |
# File 'lib/textus/manifest/entry.rb', line 7 def projection @projection end |
#publish_each ⇒ Object (readonly)
Returns the value of attribute publish_each.
7 8 9 |
# File 'lib/textus/manifest/entry.rb', line 7 def publish_each @publish_each end |
#publish_to ⇒ Object (readonly)
Returns the value of attribute publish_to.
7 8 9 |
# File 'lib/textus/manifest/entry.rb', line 7 def publish_to @publish_to end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
7 8 9 |
# File 'lib/textus/manifest/entry.rb', line 7 def raw @raw end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
7 8 9 |
# File 'lib/textus/manifest/entry.rb', line 7 def schema @schema end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
7 8 9 |
# File 'lib/textus/manifest/entry.rb', line 7 def template @template end |
#zone ⇒ Object (readonly)
Returns the value of attribute zone.
7 8 9 |
# File 'lib/textus/manifest/entry.rb', line 7 def zone @zone end |
Instance Method Details
#derived? ⇒ Boolean
Legacy alias for in_generator_zone?. Retained because internal validation callers (and external tools) read more naturally as ‘derived?`.
73 74 75 |
# File 'lib/textus/manifest/entry.rb', line 73 def derived? in_generator_zone? end |
#in_generator_zone? ⇒ Boolean
Signal-based zone-kind predicates: derive the “kind” of a zone from its writable_by signals rather than its literal name. This keeps detection working when users rename the default zones (canon/intake/pending/derived → identity/inbox/review/output, etc.).
63 64 65 |
# File 'lib/textus/manifest/entry.rb', line 63 def in_generator_zone? zone_writers.include?("build") end |
#in_proposal_zone? ⇒ Boolean
67 68 69 |
# File 'lib/textus/manifest/entry.rb', line 67 def in_proposal_zone? zone_writers.include?("ai") 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.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/textus/manifest/entry.rb', line 43 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 = Textus::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 |