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

Inherits:
Entry
  • Object
show all
Defined in:
lib/textus/protocol/manifest/entry/base.rb

Direct Known Subclasses

Leaf, Nested

Defined Under Namespace

Classes: PublishContext

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw:, key:, path:, lane:, format:, schema: nil, naming: nil, publish_targets: []) ⇒ Base

rubocop:disable Lint/MissingSuper



9
10
11
12
13
14
15
16
17
18
# File 'lib/textus/protocol/manifest/entry/base.rb', line 9

def initialize(raw:, key:, path:, lane:, format:, schema: nil, naming: nil, publish_targets: [])
  @raw = raw
  @key = key
  @path = path
  @lane = lane
  @schema = schema
  @naming = naming
  @format = format
  @publish_targets = Array(publish_targets)
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



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

def format
  @format
end

#keyObject (readonly)

Returns the value of attribute key.



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

def key
  @key
end

#laneObject (readonly)

Returns the value of attribute lane.



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

def lane
  @lane
end

#namingObject (readonly)

Returns the value of attribute naming.



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

def naming
  @naming
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

#publish_targetsObject (readonly)

Returns the value of attribute publish_targets.



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

def publish_targets
  @publish_targets
end

#rawObject (readonly)

Returns the value of attribute raw.



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

def raw
  @raw
end

#schemaObject (readonly)

Returns the value of attribute schema.



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

def schema
  @schema
end

Instance Method Details

#derived?Boolean

Returns:

  • (Boolean)


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

def derived? = false

#eventsObject



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

def events = {}

#external?Boolean

Production traits. Default false on all non-produced entries. Lets publish modes call these without a respond_to? guard.

Returns:

  • (Boolean)


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

def external? = false

#in_proposal_lane?(policy) ⇒ Boolean

Returns:

  • (Boolean)


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

def in_proposal_lane?(policy) = policy.queue_lane?(@lane)

#lane_writers(policy) ⇒ Object

rubocop:enable Lint/MissingSuper



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

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

#leaf?Boolean

Returns:

  • (Boolean)


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

def leaf?    = false

#nested?Boolean

Returns:

  • (Boolean)


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

def nested?  = false

#publish_modeObject

ADR 0049: an entry resolves, once, to one Publish::* mode that owns its publish algorithm. A plain entry publishes via ToPaths (publish_to) or None; Nested resolves among the key/path-driven modes. Derived overrides publish_via to materialize first.



80
81
82
# File 'lib/textus/protocol/manifest/entry/base.rb', line 80

def publish_mode
  @publish_mode ||= Publish.resolve(self)
end

#publish_toObject

Single source of truth is @publish_targets (ADR 0094). These derive the ADR-0049/0052 views the publish modes consume.



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

def publish_to   = @publish_targets.select(&:to_target?).map(&:to)

#publish_treeObject



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

def publish_tree = @publish_targets.find(&:tree_target?)&.tree

#publish_via(pctx, prefix: nil) ⇒ Object



84
85
86
# File 'lib/textus/protocol/manifest/entry/base.rb', line 84

def publish_via(pctx, prefix: nil)
  publish_mode.publish(pctx, prefix: prefix)
end

#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)


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

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

#with_publish_targets(pts) ⇒ Object



88
89
90
# File 'lib/textus/protocol/manifest/entry/base.rb', line 88

def with_publish_targets(pts)
  dup.tap { |e| e.instance_variable_set(:@publish_targets, pts) }
end