Class Yapra::LegacyPlugin::CompatibleModeRegistry
In: lib/yapra/legacy_plugin/compatible_mode_registry.rb
Parent: Object

Methods

get   logger   new  

Attributes

legacy_plugins  [RW] 

Public Class methods

paths :Directory paths which contain legacy plugins.
pipeline :Runtime pipline.

[Source]

    # File lib/yapra/legacy_plugin/compatible_mode_registry.rb, line 10
10:     def initialize paths, pipeline
11:       self.legacy_plugins = {}
12:       
13:       paths.each do |folder|
14:         folder = Pathname.new(folder)
15:         Pathname.glob(File.join(folder, "**/*.rb")).sort.each do |file|
16:           module_name = file.relative_path_from(folder).to_s.gsub("/","::")[0..-4]
17:           begin
18:             legacy_plugins[ module_name ] = Yapra::LegacyPlugin::Base.new(pipeline, file)
19:             logger.debug "#{module_name} is loaded from #{file}"
20:           rescue LoadError => ex
21:             logger.warn "#{module_name} can't load, because: #{ex.message}"
22:           end
23:         end
24:       end
25:     end

Public Instance methods

load plugin from module name.

example:

    registry = Yapra::LegacyPlugin::CompatibleModeRegistry.new(paths, pipeline)
    feed_load_plugin = registry.get('Feed::load')

[Source]

    # File lib/yapra/legacy_plugin/compatible_mode_registry.rb, line 38
38:     def get module_name
39:       plugin = legacy_plugins[module_name]
40:       raise "#{module_name} is not registered." unless plugin
41:       plugin
42:     end

[Source]

    # File lib/yapra/legacy_plugin/compatible_mode_registry.rb, line 27
27:     def logger
28:       Yapra::Runtime.logger
29:     end

[Validate]