<commit_before>require 'yaml'

module BceExplorer
  # Coin configuration class
  class Configuration
    attr_reader :info

    FRONTEND_KEYS = %w(Name Tag Algorithm
                       BitcoinTalk GitHub Website Twitter PaperWallet)

    def initialize(coin_config_file)
      coin_config = YAML.load_file coin_config_file
      @info = coin_config.select { |k, _| FRONTEND_KEYS.include? k }
      @rpc =  coin_config.select { |k, _| k[0, 5] == '_rpc_' }
      load_db_config
      load_cache_config
    end

    def client
      BceClient::Client.new client_options
    end

    def db
      DB.new db_options
    end

    def cache
      Cache.new cache_options, db_options[:dbname]
    end

    private

    def client_options
      {
        host: @rpc['_rpc_host'],
        port: @rpc['_rpc_port'],
        username: @rpc['_rpc_user'],
        password: @rpc['_rpc_pass']
      }
    end

    def db_options
      {
        host: @_db_conf['host'] || 'localhost',
        port: @_db_conf['port'] || 27_017,
        dbname: "#{@_db_conf['db_prefix']}_#{@info['Name'].downcase}" || 'bce'
      }
    end

    def cache_options
      {
        host: @_cache_conf['host'] || 'localhost',
        port: @_cache_conf['port'] || 6_379
      }
    end

    def load_db_config
      @_db_conf = YAML.load_file Env.mongo_conf_file
    end

    def load_cache_config
      @_cache_conf = YAML.load_file Env.redis_conf_file
    end
  end
end<commit_msg>removed cache code from Configuration#<commit_after>require 'yaml'

module BceExplorer
  # Coin configuration class
  class Configuration
    attr_reader :info

    FRONTEND_KEYS = %w(Name Tag Algorithm
                       BitcoinTalk GitHub Website Twitter PaperWallet)

    def initialize(coin_config_file)
      coin_config = YAML.load_file coin_config_file
      @info = coin_config.select { |k, _| FRONTEND_KEYS.include? k }
      @rpc =  coin_config.select { |k, _| k[0, 5] == '_rpc_' }
      load_db_config
    end

    def client
      BceClient::Client.new client_options
    end

    def db
      DB.new db_options
    end

    private

    def client_options
      {
        host: @rpc['_rpc_host'],
        port: @rpc['_rpc_port'],
        username: @rpc['_rpc_user'],
        password: @rpc['_rpc_pass']
      }
    end

    def db_options
      {
        host: @_db_conf['host'] || 'localhost',
        port: @_db_conf['port'] || 27_017,
        dbname: "#{@_db_conf['db_prefix']}_#{@info['Name'].downcase}" || 'bce'
      }
    end

    def load_db_config
      @_db_conf = YAML.load_file Env.mongo_conf_file
    end
  end
end
{'fraction_non_alphanumeric': 0.10678488820354665, 'fraction_numerical': 0.006939090208172706, 'mean_word_length': 2.387728459530026, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6677622', 'n_tokens_mistral': 911, 'n_tokens_neox': 868, 'n_words': 185}