Class: Rigor::Plugin::Registry

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(plugins: [], load_errors: []) ⇒ Registry

Returns a new instance of Registry.

Parameters:

  • plugins (Array<Rigor::Plugin::Base>) (defaults to: [])

    instantiated plugin instances in deterministic order.

  • load_errors (Array<Rigor::Plugin::LoadError>) (defaults to: [])

    failures surfaced during loading. Each error is also turned into a diagnostic by the runner.



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_errorsObject (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

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

Returns:

  • (Boolean)


43
44
45
# File 'lib/rigor/plugin/registry.rb', line 43

def any_load_errors?
  !load_errors.empty?
end

#empty?Boolean

Returns:

  • (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

#idsObject



35
36
37
# File 'lib/rigor/plugin/registry.rb', line 35

def ids
  plugins.map { |plugin| plugin.manifest.id }
end