Class: Uniword::Plugin::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/uniword/plugin/loader.rb

Overview

Discovers plugins from installed gems. Each plugin ships a ruby file under uniword/plugin/<name>.rb that registers itself with Plugin::Registry on load.

Constant Summary collapse

GLOB =
"uniword/plugin/*.rb"

Class Method Summary collapse

Class Method Details

.each_validator {|validator| ... } ⇒ void

This method returns an undefined value.

Yield every registered validator in registration order.

Yield Parameters:



37
38
39
# File 'lib/uniword/plugin/loader.rb', line 37

def each_validator(&block)
  Registry.validators.each_value(&block)
end

.load_allArray<String>

Load every plugin file found in installed gems.

Returns:

  • (Array<String>)

    paths loaded



15
16
17
# File 'lib/uniword/plugin/loader.rb', line 15

def load_all
  Gem.find_files(GLOB).each { |path| require path }
end

.run_transformers(document:, stage:) ⇒ void

This method returns an undefined value.

Run every registered transformer whose stages include stage, in registration order.

Parameters:



25
26
27
28
29
30
31
# File 'lib/uniword/plugin/loader.rb', line 25

def run_transformers(document:, stage:)
  Registry.transformers.each_value do |transformer|
    next unless transformer.applies_to?(stage)

    transformer.transform(document)
  end
end