require 'thread' require 'treetop' require 'flydata-core/table_def' module Flydata module Parser class ParserProvider @@mutex = Mutex.new @@parsers = {} def self.parser(db_type, parser_type) key = [db_type.to_s, parser_type.to_s].join("::").to_s @@mutex.synchronize do if @@parsers[key] return @@parsers[key] else # lazy load treetop_path = File.expand_path( "../source_#{db_type}/parser/#{parser_type}.treetop", File.dirname(__FILE__)) Treetop.load treetop_path @@parsers[key] = "#{parser_type}_parser".camelize.constantize end end end end end end