Class: Textus::Manifest::Entry::Base

Inherits:
Textus::Manifest::Entry show all
Defined in:
lib/textus/manifest/entry/base.rb

Direct Known Subclasses

Derived, Intake, Leaf, Nested

Defined Under Namespace

Classes: PublishContext

Constant Summary

Constants inherited from Textus::Manifest::Entry

REGISTRY

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(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
# File 'lib/textus/manifest/entry/base.rb', line 8

def initialize(raw:, key:, path:, zone:, schema:, owner:, format:, publish_to: [])
  @raw = raw
  @key = key
  @path = path
  @zone = zone
  @schema = schema
  @owner = owner
  @format = format
  @publish_to = Array(publish_to)
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



5
6
7
# File 'lib/textus/manifest/entry/base.rb', line 5

def format
  @format
end

#keyObject (readonly)

Returns the value of attribute key.



5
6
7
# File 'lib/textus/manifest/entry/base.rb', line 5

def key
  @key
end

#ownerObject (readonly)

Returns the value of attribute owner.



5
6
7
# File 'lib/textus/manifest/entry/base.rb', line 5

def owner
  @owner
end

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/textus/manifest/entry/base.rb', line 5

def path
  @path
end

#publish_toObject (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

#rawObject (readonly)

Returns the value of attribute raw.



5
6
7
# File 'lib/textus/manifest/entry/base.rb', line 5

def raw
  @raw
end

#schemaObject (readonly)

Returns the value of attribute schema.



5
6
7
# File 'lib/textus/manifest/entry/base.rb', line 5

def schema
  @schema
end

#zoneObject (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

Returns:

  • (Boolean)


30
# File 'lib/textus/manifest/entry/base.rb', line 30

def derived? = false

#eventsObject



45
# File 'lib/textus/manifest/entry/base.rb', line 45

def events         = {}

#ignoreObject



48
# File 'lib/textus/manifest/entry/base.rb', line 48

def ignore         = []

#ignored?(_rel_path) ⇒ Boolean

Per-entry ignore (ADR 0042). Base entries enumerate no tree, so nothing is ever ignored; Nested overrides with real patterns.

Returns:

  • (Boolean)


52
# File 'lib/textus/manifest/entry/base.rb', line 52

def ignored?(_rel_path) = false

#in_generator_zone?(policy) ⇒ Boolean

Returns:

  • (Boolean)


26
# File 'lib/textus/manifest/entry/base.rb', line 26

def in_generator_zone?(policy) = policy.derived_zone?(@zone)

#in_proposal_zone?(policy) ⇒ Boolean

Returns:

  • (Boolean)


27
# File 'lib/textus/manifest/entry/base.rb', line 27

def in_proposal_zone?(policy)  = policy.queue_zone?(@zone)

#index_filenameObject



47
# File 'lib/textus/manifest/entry/base.rb', line 47

def index_filename = nil

#inject_bootObject

rubocop:disable Naming/PredicateMethod



44
# File 'lib/textus/manifest/entry/base.rb', line 44

def inject_boot    = false # rubocop:disable Naming/PredicateMethod

#intake?Boolean

Returns:

  • (Boolean)


31
# File 'lib/textus/manifest/entry/base.rb', line 31

def intake?  = false

#leaf?Boolean

Returns:

  • (Boolean)


32
# File 'lib/textus/manifest/entry/base.rb', line 32

def leaf?    = false

#nested?Boolean

Returns:

  • (Boolean)


29
# File 'lib/textus/manifest/entry/base.rb', line 29

def nested?  = false

#publish_eachObject



46
# File 'lib/textus/manifest/entry/base.rb', line 46

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.



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/textus/manifest/entry/base.rb', line 85

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::Ports::Publisher.publish(source: source_path, target: target_abs, store_root: pctx.root)
    pctx.emit(: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

#templateObject

Nil stubs for cross-cutting optional attrs. Subclasses override the ones they own. Validators and serializers can call these directly without ‘respond_to?` guards.



43
# File 'lib/textus/manifest/entry/base.rb', line 43

def template       = nil

#tracked?Boolean

Whether git should track this entry’s file. Default true; an entry marked ‘tracked: false` in the manifest stays protocol-readable but is listed in the generated `.gitignore` (ADR 0043). Cross-cutting, so it reads from raw here rather than threading through every constructor.

Returns:

  • (Boolean)


38
# File 'lib/textus/manifest/entry/base.rb', line 38

def tracked? = @raw["tracked"] != false

#zone_writers(policy) ⇒ Object

rubocop:enable Metrics/ParameterLists, Lint/MissingSuper



20
21
22
23
24
# File 'lib/textus/manifest/entry/base.rb', line 20

def zone_writers(policy)
  policy.zone_writers(@zone)
rescue UsageError => e
  raise UsageError.new("entry '#{@key}': #{e.message}")
end