Class: Textus::Manifest::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/manifest/entry.rb,
lib/textus/manifest/entry/parser.rb,
lib/textus/manifest/entry/validators.rb,
lib/textus/manifest/entry/validators/events.rb,
lib/textus/manifest/entry/validators/inject_intro.rb,
lib/textus/manifest/entry/validators/publish_each.rb,
lib/textus/manifest/entry/validators/format_matrix.rb,
lib/textus/manifest/entry/validators/index_filename.rb

Defined Under Namespace

Modules: Parser, Validators

Constant Summary collapse

PUBLISH_EACH_VARS =

Re-exported for backward compatibility with callers that referenced these constants on Entry. Canonical source is the PublishEach validator.

Validators::PublishEach::KNOWN_VARS
PUBLISH_EACH_VAR_RE =
Validators::PublishEach::VAR_RE

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(manifest:, raw:, key:, path:, zone:, schema:, owner:, nested:, template:, publish_to:, publish_each:, events:, inject_intro:, index_filename:, format:, compute:, projection:, generator:, intake_handler:, intake_config:) ⇒ Entry

rubocop:disable Metrics/ParameterLists



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/textus/manifest/entry.rb', line 16

def initialize(manifest:, raw:, key:, path:, zone:, schema:, owner:, nested:,
               template:, publish_to:, publish_each:, events:, inject_intro:,
               index_filename:, format:, compute:, projection:, generator:,
               intake_handler:, intake_config:)
  @manifest = manifest
  @raw = raw
  @key = key
  @path = path
  @zone = zone
  @schema = schema
  @owner = owner
  @nested = nested
  @template = template
  @publish_to = publish_to
  @publish_each = publish_each
  @events = events
  @inject_intro = inject_intro
  @index_filename = index_filename
  @format = format
  @compute = compute
  @projection = projection
  @generator = generator
  @intake_handler = intake_handler
  @intake_config = intake_config
end

Instance Attribute Details

#computeObject (readonly)

Returns the value of attribute compute.



9
10
11
# File 'lib/textus/manifest/entry.rb', line 9

def compute
  @compute
end

#eventsObject (readonly)

Returns the value of attribute events.



9
10
11
# File 'lib/textus/manifest/entry.rb', line 9

def events
  @events
end

#formatObject (readonly)

Returns the value of attribute format.



9
10
11
# File 'lib/textus/manifest/entry.rb', line 9

def format
  @format
end

#generatorObject (readonly)

Returns the value of attribute generator.



9
10
11
# File 'lib/textus/manifest/entry.rb', line 9

def generator
  @generator
end

#index_filenameObject (readonly)

Returns the value of attribute index_filename.



9
10
11
# File 'lib/textus/manifest/entry.rb', line 9

def index_filename
  @index_filename
end

#inject_introObject (readonly)

Returns the value of attribute inject_intro.



9
10
11
# File 'lib/textus/manifest/entry.rb', line 9

def inject_intro
  @inject_intro
end

#intake_configObject (readonly)

Returns the value of attribute intake_config.



9
10
11
# File 'lib/textus/manifest/entry.rb', line 9

def intake_config
  @intake_config
end

#intake_handlerObject (readonly)

Returns the value of attribute intake_handler.



9
10
11
# File 'lib/textus/manifest/entry.rb', line 9

def intake_handler
  @intake_handler
end

#keyObject (readonly)

Returns the value of attribute key.



9
10
11
# File 'lib/textus/manifest/entry.rb', line 9

def key
  @key
end

#nestedObject (readonly)

Returns the value of attribute nested.



9
10
11
# File 'lib/textus/manifest/entry.rb', line 9

def nested
  @nested
end

#ownerObject (readonly)

Returns the value of attribute owner.



9
10
11
# File 'lib/textus/manifest/entry.rb', line 9

def owner
  @owner
end

#pathObject (readonly)

Returns the value of attribute path.



9
10
11
# File 'lib/textus/manifest/entry.rb', line 9

def path
  @path
end

#projectionObject (readonly)

Returns the value of attribute projection.



9
10
11
# File 'lib/textus/manifest/entry.rb', line 9

def projection
  @projection
end

#publish_eachObject (readonly)

Returns the value of attribute publish_each.



9
10
11
# File 'lib/textus/manifest/entry.rb', line 9

def publish_each
  @publish_each
end

#publish_toObject (readonly)

Returns the value of attribute publish_to.



9
10
11
# File 'lib/textus/manifest/entry.rb', line 9

def publish_to
  @publish_to
end

#rawObject (readonly)

Returns the value of attribute raw.



9
10
11
# File 'lib/textus/manifest/entry.rb', line 9

def raw
  @raw
end

#schemaObject (readonly)

Returns the value of attribute schema.



9
10
11
# File 'lib/textus/manifest/entry.rb', line 9

def schema
  @schema
end

#templateObject (readonly)

Returns the value of attribute template.



9
10
11
# File 'lib/textus/manifest/entry.rb', line 9

def template
  @template
end

#zoneObject (readonly)

Returns the value of attribute zone.



9
10
11
# File 'lib/textus/manifest/entry.rb', line 9

def zone
  @zone
end

Instance Method Details

#in_generator_zone?Boolean

Signal-based zone-kind predicates: derive the “kind” of a zone from its write_policy signals rather than its literal name, so detection keeps working when users rename the default zones.

Returns:

  • (Boolean)


65
66
67
# File 'lib/textus/manifest/entry.rb', line 65

def in_generator_zone?
  zone_writers.include?("builder")
end

#in_proposal_zone?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/textus/manifest/entry.rb', line 69

def in_proposal_zone?
  zone_writers.include?("agent")
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.

Raises:



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/textus/manifest/entry.rb', line 46

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