Sha256: 7a4932b4349d03ddae20c6dba458ba96414bfac10015a02746bc0c436ea0b712

Contents?: true

Size: 642 Bytes

Versions: 12

Compression:

Stored size: 642 Bytes

Contents

# frozen_string_literal: true

module Recog
  class DBManager
    require 'nokogiri'
    require 'recog/db'

    attr_accessor :path, :databases

    DefaultDatabasePath = File.expand_path(File.join(File.expand_path(__dir__), ['..', '..', 'recog', 'xml']))

    def initialize(path = DefaultDatabasePath)
      self.path = path
      reload
    end

    def load_databases
      if File.directory?(path)
        Dir["#{path}/*.xml"].each do |dbxml|
          databases << DB.new(dbxml)
        end
      else
        databases << DB.new(path)
      end
    end

    def reload
      self.databases = []
      load_databases
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
recog-3.1.13 lib/recog/db_manager.rb
recog-3.1.12 lib/recog/db_manager.rb
recog-3.1.11 lib/recog/db_manager.rb
recog-3.1.10 lib/recog/db_manager.rb
recog-3.1.9 lib/recog/db_manager.rb
recog-3.1.8 lib/recog/db_manager.rb
recog-3.1.7 lib/recog/db_manager.rb
recog-3.1.6 lib/recog/db_manager.rb
recog-3.1.5 lib/recog/db_manager.rb
recog-3.1.4 lib/recog/db_manager.rb
recog-3.1.3 lib/recog/db_manager.rb
recog-3.1.2 lib/recog/db_manager.rb