Class: Uniword::Plugin::Loader
- Inherits:
-
Object
- Object
- Uniword::Plugin::Loader
- 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
-
.each_validator {|validator| ... } ⇒ void
Yield every registered validator in registration order.
-
.load_all ⇒ Array<String>
Load every plugin file found in installed gems.
-
.run_transformers(document:, stage:) ⇒ void
Run every registered transformer whose
stagesincludestage, in registration order.
Class Method Details
.each_validator {|validator| ... } ⇒ void
This method returns an undefined value.
Yield every registered validator in registration order.
37 38 39 |
# File 'lib/uniword/plugin/loader.rb', line 37 def each_validator(&block) Registry.validators.each_value(&block) end |
.load_all ⇒ Array<String>
Load every plugin file found in installed gems.
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.
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 |