Class: Rigor::Plugin::Registry
- Inherits:
-
Object
- Object
- Rigor::Plugin::Registry
- Defined in:
- lib/rigor/plugin/registry.rb
Overview
Read-side query API over the plugins loaded for a single ‘Analysis::Runner.run`. Constructed by Loader.load and exposed downstream so the contribution merger (slice 3) and diagnostic provenance (slice 5) can iterate over loaded plugin instances in deterministic order.
The registry is read-only after construction; ordering is the order in which Loader resolved configuration entries, which is project-config order with plugin-id alphabetical as the tie-breaker.
Constant Summary collapse
- EMPTY =
new.freeze
Instance Attribute Summary collapse
-
#load_errors ⇒ Object
readonly
Returns the value of attribute load_errors.
-
#plugins ⇒ Object
readonly
Returns the value of attribute plugins.
Instance Method Summary collapse
- #any_load_errors? ⇒ Boolean
- #empty? ⇒ Boolean
- #find(id) ⇒ Object
- #ids ⇒ Object
-
#initialize(plugins: [], load_errors: []) ⇒ Registry
constructor
A new instance of Registry.
-
#type_node_resolvers ⇒ Object
ADR-13 slice 2 — flat ordered list of every loaded plugin’s manifest-declared TypeNodeResolver instances, in plugin registration order.
Constructor Details
#initialize(plugins: [], load_errors: []) ⇒ Registry
Returns a new instance of Registry.
24 25 26 27 28 |
# File 'lib/rigor/plugin/registry.rb', line 24 def initialize(plugins: [], load_errors: []) @plugins = plugins.dup.freeze @load_errors = load_errors.dup.freeze freeze end |
Instance Attribute Details
#load_errors ⇒ Object (readonly)
Returns the value of attribute load_errors.
17 18 19 |
# File 'lib/rigor/plugin/registry.rb', line 17 def load_errors @load_errors end |
#plugins ⇒ Object (readonly)
Returns the value of attribute plugins.
17 18 19 |
# File 'lib/rigor/plugin/registry.rb', line 17 def plugins @plugins end |
Instance Method Details
#any_load_errors? ⇒ Boolean
43 44 45 |
# File 'lib/rigor/plugin/registry.rb', line 43 def any_load_errors? !load_errors.empty? end |
#empty? ⇒ Boolean
39 40 41 |
# File 'lib/rigor/plugin/registry.rb', line 39 def empty? plugins.empty? end |
#find(id) ⇒ Object
30 31 32 33 |
# File 'lib/rigor/plugin/registry.rb', line 30 def find(id) id_s = id.to_s plugins.find { |plugin| plugin.manifest.id == id_s } end |
#ids ⇒ Object
35 36 37 |
# File 'lib/rigor/plugin/registry.rb', line 35 def ids plugins.map { |plugin| plugin.manifest.id } end |
#type_node_resolvers ⇒ Object
ADR-13 slice 2 — flat ordered list of every loaded plugin’s manifest-declared TypeNodeResolver instances, in plugin registration order. Slice 3 wires this into the parser’s resolver chain; until then the method is a read-side aggregator only. The first non-nil ‘#resolve(node, scope)` return wins per ADR-13 WD3 / WD5 — registration order is the user’s lever.
54 55 56 |
# File 'lib/rigor/plugin/registry.rb', line 54 def type_node_resolvers plugins.flat_map { |plugin| plugin.manifest.type_node_resolvers } end |