Class: Yapra::LegacyPlugin::AdvanceModeRegistry
- Inherits:
-
Object
- Object
- Yapra::LegacyPlugin::AdvanceModeRegistry
- Defined in:
- lib/yapra/legacy_plugin/advance_mode_registry.rb
Overview
AdvanceModeRegistry load legacy plugin at one by one.
Instance Attribute Summary collapse
-
#legacy_plugins ⇒ Object
Returns the value of attribute legacy_plugins.
-
#pipeline ⇒ Object
Returns the value of attribute pipeline.
-
#plugin_paths ⇒ Object
Returns the value of attribute plugin_paths.
Instance Method Summary collapse
-
#get(module_name) ⇒ Object
load plugin from module name.
-
#initialize(paths, pipeline) ⇒ AdvanceModeRegistry
constructor
- paths
-
Directory paths which contain legacy plugins.
- #logger ⇒ Object
Constructor Details
#initialize(paths, pipeline) ⇒ AdvanceModeRegistry
- paths
-
Directory paths which contain legacy plugins.
- pipeline
-
Runtime pipline.
15 16 17 18 19 |
# File 'lib/yapra/legacy_plugin/advance_mode_registry.rb', line 15 def initialize paths, pipeline self.legacy_plugins = {} self.plugin_paths = paths.reverse self.pipeline = pipeline end |
Instance Attribute Details
#legacy_plugins ⇒ Object
Returns the value of attribute legacy_plugins.
9 10 11 |
# File 'lib/yapra/legacy_plugin/advance_mode_registry.rb', line 9 def legacy_plugins @legacy_plugins end |
#pipeline ⇒ Object
Returns the value of attribute pipeline.
11 12 13 |
# File 'lib/yapra/legacy_plugin/advance_mode_registry.rb', line 11 def pipeline @pipeline end |
#plugin_paths ⇒ Object
Returns the value of attribute plugin_paths.
10 11 12 |
# File 'lib/yapra/legacy_plugin/advance_mode_registry.rb', line 10 def plugin_paths @plugin_paths end |
Instance Method Details
#get(module_name) ⇒ Object
load plugin from module name.
example:
registry = Yapra::LegacyPlugin::AdvanceModeRegistry.new(paths, pipeline)
feed_load_plugin = registry.get('Feed::load')
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/yapra/legacy_plugin/advance_mode_registry.rb', line 32 def get module_name plugin = legacy_plugins[module_name] unless plugin plugin_paths.each do |folder| file = File.join(folder, (module_name.gsub('::', '/') + '.rb')) if File.file?(file) plugin = Yapra::LegacyPlugin::Base.new(pipeline, file) legacy_plugins[ module_name ] = plugin logger.debug "#{module_name} is loaded from #{file}" break end end end raise "#{module_name} is not registered." unless plugin plugin end |