Class: Textus::Manifest::Entry::Base
- Inherits:
-
Textus::Manifest::Entry
- Object
- Textus::Manifest::Entry
- Textus::Manifest::Entry::Base
- Defined in:
- lib/textus/manifest/entry/base.rb
Defined Under Namespace
Classes: PublishContext
Constant Summary
Constants inherited from Textus::Manifest::Entry
PUBLISH_EACH_VARS, PUBLISH_EACH_VAR_RE, REGISTRY
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#manifest ⇒ Object
readonly
Returns the value of attribute manifest.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#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.
-
#zone ⇒ Object
readonly
Returns the value of attribute zone.
Instance Method Summary collapse
- #derived? ⇒ Boolean
- #events ⇒ Object
- #in_generator_zone? ⇒ Boolean
- #in_proposal_zone? ⇒ Boolean
- #index_filename ⇒ Object
-
#initialize(manifest:, raw:, key:, path:, zone:, schema:, owner:, format:, publish_to: []) ⇒ Base
constructor
rubocop:disable Metrics/ParameterLists, Lint/MissingSuper.
-
#inject_boot ⇒ Object
rubocop:disable Naming/PredicateMethod.
- #intake? ⇒ Boolean
- #leaf? ⇒ Boolean
- #nested? ⇒ Boolean
- #publish_each ⇒ Object
-
#publish_via(pctx, prefix: nil) ⇒ Object
Subclasses override to customize publish behavior.
-
#template ⇒ Object
Nil stubs for cross-cutting optional attrs.
-
#zone_writers ⇒ Object
rubocop:enable Metrics/ParameterLists, Lint/MissingSuper.
Constructor Details
#initialize(manifest:, raw:, key:, path:, zone:, schema:, owner:, format:, publish_to: []) ⇒ Base
rubocop:disable Metrics/ParameterLists, Lint/MissingSuper
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/textus/manifest/entry/base.rb', line 8 def initialize(manifest:, raw:, key:, path:, zone:, schema:, owner:, format:, publish_to: []) @manifest = manifest @raw = raw @key = key @path = path @zone = zone @schema = schema @owner = owner @format = format @publish_to = Array(publish_to) end |
Instance Attribute Details
#format ⇒ Object (readonly)
Returns the value of attribute format.
5 6 7 |
# File 'lib/textus/manifest/entry/base.rb', line 5 def format @format end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
5 6 7 |
# File 'lib/textus/manifest/entry/base.rb', line 5 def key @key end |
#manifest ⇒ Object (readonly)
Returns the value of attribute manifest.
5 6 7 |
# File 'lib/textus/manifest/entry/base.rb', line 5 def manifest @manifest end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
5 6 7 |
# File 'lib/textus/manifest/entry/base.rb', line 5 def owner @owner end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/textus/manifest/entry/base.rb', line 5 def path @path end |
#publish_to ⇒ Object (readonly)
Returns the value of attribute publish_to.
5 6 7 |
# File 'lib/textus/manifest/entry/base.rb', line 5 def publish_to @publish_to end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
5 6 7 |
# File 'lib/textus/manifest/entry/base.rb', line 5 def raw @raw end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
5 6 7 |
# File 'lib/textus/manifest/entry/base.rb', line 5 def schema @schema end |
#zone ⇒ Object (readonly)
Returns the value of attribute zone.
5 6 7 |
# File 'lib/textus/manifest/entry/base.rb', line 5 def zone @zone end |
Instance Method Details
#derived? ⇒ Boolean
31 |
# File 'lib/textus/manifest/entry/base.rb', line 31 def derived? = false |
#events ⇒ Object
40 |
# File 'lib/textus/manifest/entry/base.rb', line 40 def events = {} |
#in_generator_zone? ⇒ Boolean
27 |
# File 'lib/textus/manifest/entry/base.rb', line 27 def in_generator_zone? = @manifest.zone_kinds(@zone).include?(:generator) |
#in_proposal_zone? ⇒ Boolean
28 |
# File 'lib/textus/manifest/entry/base.rb', line 28 def in_proposal_zone? = @manifest.zone_kinds(@zone).include?(:proposer) |
#index_filename ⇒ Object
42 |
# File 'lib/textus/manifest/entry/base.rb', line 42 def index_filename = nil |
#inject_boot ⇒ Object
rubocop:disable Naming/PredicateMethod
39 |
# File 'lib/textus/manifest/entry/base.rb', line 39 def inject_boot = false # rubocop:disable Naming/PredicateMethod |
#intake? ⇒ Boolean
32 |
# File 'lib/textus/manifest/entry/base.rb', line 32 def intake? = false |
#leaf? ⇒ Boolean
33 |
# File 'lib/textus/manifest/entry/base.rb', line 33 def leaf? = false |
#nested? ⇒ Boolean
30 |
# File 'lib/textus/manifest/entry/base.rb', line 30 def nested? = false |
#publish_each ⇒ Object
41 |
# File 'lib/textus/manifest/entry/base.rb', line 41 def publish_each = nil |
#publish_via(pctx, prefix: nil) ⇒ Object
Subclasses override to customize publish behavior. Default: copy the stored file to each publish_to target. Returns: { kind: :built|:leaves, value: … } to be accumulated by Publish#call, or nil to skip.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/textus/manifest/entry/base.rb', line 54 def publish_via(pctx, prefix: nil) # rubocop:disable Lint/UnusedMethodArgument return nil if Array(publish_to).empty? source_path = pctx.manifest.resolver.resolve(@key).path envelope = pctx.reader.call(@key) publish_to.each do |rel| target_abs = File.join(pctx.repo_root, rel) Textus::Infra::Publisher.publish(source: source_path, target: target_abs, store_root: pctx.root) pctx.emit.call(:file_published, key: @key, envelope: envelope, source: source_path, target: target_abs) end { kind: :built, value: { "key" => @key, "path" => source_path, "published_to" => publish_to } } end |
#template ⇒ Object
Nil stubs for cross-cutting optional attrs. Subclasses override the ones they own. Validators and serializers can call these directly without ‘respond_to?` guards.
38 |
# File 'lib/textus/manifest/entry/base.rb', line 38 def template = nil |
#zone_writers ⇒ Object
rubocop:enable Metrics/ParameterLists, Lint/MissingSuper
21 22 23 24 25 |
# File 'lib/textus/manifest/entry/base.rb', line 21 def zone_writers @manifest.zone_writers(@zone) rescue UsageError => e raise UsageError.new("entry '#{@key}': #{e.}") end |