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.
-
#fetch ⇒ Object
readonly
Returns the value of attribute fetch.
-
#fetch_config ⇒ Object
readonly
Returns the value of attribute fetch_config.
-
#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) ⇒ 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.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/textus/manifest/entry.rb', line 11 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! parse_source!(raw["source"]) 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 |
#fetch ⇒ Object (readonly)
Returns the value of attribute fetch.
7 8 9 |
# File 'lib/textus/manifest/entry.rb', line 7 def fetch @fetch end |
#fetch_config ⇒ Object (readonly)
Returns the value of attribute fetch_config.
7 8 9 |
# File 'lib/textus/manifest/entry.rb', line 7 def fetch_config @fetch_config 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 |
#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 |
#ttl ⇒ Object (readonly)
Returns the value of attribute ttl.
7 8 9 |
# File 'lib/textus/manifest/entry.rb', line 7 def ttl @ttl 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
56 57 58 59 60 61 |
# File 'lib/textus/manifest/entry.rb', line 56 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.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/textus/manifest/entry.rb', line 40 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 |