Sha256: 6dbdc6b56224eaad01074fcf4aabcca1f7fbc79c211c06745edebd1f56a8bc3e

Contents?: true

Size: 964 Bytes

Versions: 1

Compression:

Stored size: 964 Bytes

Contents

require 'yapra/legacy_plugin'
require 'yapra/inflector'

module Yapra::LegacyPlugin
  
  class AdvanceModeRegistry
    attr_accessor :legacy_plugins
    attr_accessor :plugin_paths
    attr_accessor :pipeline
    
    def initialize paths, pipeline
      self.legacy_plugins = {}
      self.plugin_paths = paths.reverse
      self.pipeline = pipeline
    end
    
    def logger
      Yapra::Runtime.logger
    end
    
    def get module_name
      plugin = legacy_plugins[module_name]
      unless plugin
        plugin_paths.each do |folder|
          file = folder + (module_name.gsub('::', '/') + '.rb')
          if 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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yapra-0.1.0 lib/yapra/legacy_plugin/advance_mode_registry.rb