class Relaton::Registry
Constants
- SUPPORTED_GEMS
Attributes
processors[R]
Public Class Methods
new()
click to toggle source
# File lib/relaton/registry.rb, line 19 def initialize @processors = {} register_gems end
Public Instance Methods
by_type(type)
click to toggle source
Find processor by type
@param type [String] @return [RelatonIso::Processor, RelatonIec::Processor,
RelatonNist::Processor, RelatonIetf::Processot, RelatonItu::Processor, RelatonGb::Processor, RelatonOgc::Processor, RelatonCalconnect::Processor]
# File lib/relaton/registry.rb, line 76 def by_type(type) processors.values.detect { |v| v.prefix == type&.upcase } end
find_processor(short)
click to toggle source
# File lib/relaton/registry.rb, line 48 def find_processor(short) processors[short.to_sym] end
find_processor_by_dataset(dataset)
click to toggle source
Search a rpocessos by dataset name
@param [String] dataset
@return [Relaton::Processor, nil]
# File lib/relaton/registry.rb, line 64 def find_processor_by_dataset(dataset) processors.values.detect { |p| p.datasets&.include? dataset } end
register(processor)
click to toggle source
# File lib/relaton/registry.rb, line 38 def register(processor) raise Error unless processor < ::Relaton::Processor p = processor.new return if processors[p.short] Util.log("[relaton] processor \"#{p.short}\" registered", :debug) processors[p.short] = p end
register_gems()
click to toggle source
# File lib/relaton/registry.rb, line 24 def register_gems Util.log("[relaton] Info: detecting backends:", :info) SUPPORTED_GEMS.each do |b| begin require b require "#{b}/processor" register Kernel.const_get "#{camel_case(b)}::Processor" rescue LoadError Util.log("[relaton] Error: backend #{b} not present", :error) end end end
supported_processors()
click to toggle source
@return [Array<Symbol>]
# File lib/relaton/registry.rb, line 53 def supported_processors processors.keys end
Private Instance Methods
camel_case(gem_name)
click to toggle source
# File lib/relaton/registry.rb, line 82 def camel_case(gem_name) gem_name.split("_").map(&:capitalize).join end