require 'thread' require 'treetop' require 'flydata-core/table_def' module Mysql 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.join( File.expand_path(File.dirname(__FILE__)), "parser/#{db_type}/#{parser_type}.treetop") Treetop.load treetop_path @@parsers[key] = "#{parser_type}_parser".camelize.constantize end end end end end