<commit_before># encoding: utf-8
require "mongoid/config/environment"
require "mongoid/config/options"
require "mongoid/config/validators"

module Mongoid

  # This module defines all the configuration options for Mongoid, including the
  # database connections.
  module Config
    extend self
    extend Options

    delegate :logger=, to: ::Mongoid
    delegate :logger, to: ::Mongoid

    LOCK = Mutex.new

    option :include_root_in_json, default: false
    option :include_type_for_serialization, default: false
    option :preload_models, default: false
    option :raise_not_found_error, default: true
    option :scope_overwrite_exception, default: false
    option :duplicate_fields_exception, default: false
    option :use_activesupport_time_zone, default: true
    option :use_utc, default: false

    # Has Mongoid been configured? This is checking that at least a valid
    # session config exists.
    #
    # @example Is Mongoid configured?
    #   config.configured?
    #
    # @return [ true, false ] If Mongoid is configured.
    #
    # @since 3.0.9
    def configured?
      sessions.has_key?(:default)
    end

    # Connect to the provided database name on the default session.
    #
    # @note Use only in development or test environments for convenience.
    #
    # @example Set the database to connect to.
    #   config.connect_to("mongoid_test")
    #
    # @param [ String ] name The database name.
    #
    # @since 3.0.0
    def connect_to(name, options = { read: :primary })
      self.sessions = {
        default: {
          database: name,
          hosts: [ "localhost:27017" ],
          options: options
        }
      }
    end

    # Return field names that could cause destructive things to happen if
    # defined in a Mongoid::Document.
    #
    # @example Get the destructive fields.
    #   config.destructive_fields
    #
    # @return [ Array<String> ] An array of bad field names.
    def destructive_fields
      Composable.prohibited_methods
    end

    # Load the settings from a compliant mongoid.yml file. This can be used for
    # easy setup with frameworks other than Rails.
    #
    # @example Configure Mongoid.
    #   Mongoid.load!("/path/to/mongoid.yml")
    #
    # @param [ String ] path The path to the file.
    # @param [ String, Symbol ] environment The environment to load.
    #
    # @since 2.0.1
    def load!(path, environment = nil)
      settings = Environment.load_yaml(path, environment)
      if settings.present?
        Sessions.disconnect
        Sessions.clear
        load_configuration(settings)
      end
      settings
    end

    # Get all the models in the application - this is everything that includes
    # Mongoid::Document.
    #
    # @example Get all the models.
    #   config.models
    #
    # @return [ Array<Class> ] All the models in the application.
    #
    # @since 3.1.0
    def models
      @models ||= []
    end

    # Register a model in the application with Mongoid.
    #
    # @example Register a model.<commit_msg>debugging config load<commit_after># encoding: utf-8
require "mongoid/config/environment"
require "mongoid/config/options"
require "mongoid/config/validators"

module Mongoid

  # This module defines all the configuration options for Mongoid, including the
  # database connections.
  module Config
    extend self
    extend Options

    delegate :logger=, to: ::Mongoid
    delegate :logger, to: ::Mongoid

    LOCK = Mutex.new

    option :include_root_in_json, default: false
    option :include_type_for_serialization, default: false
    option :preload_models, default: false
    option :raise_not_found_error, default: true
    option :scope_overwrite_exception, default: false
    option :duplicate_fields_exception, default: false
    option :use_activesupport_time_zone, default: true
    option :use_utc, default: false

    # Has Mongoid been configured? This is checking that at least a valid
    # session config exists.
    #
    # @example Is Mongoid configured?
    #   config.configured?
    #
    # @return [ true, false ] If Mongoid is configured.
    #
    # @since 3.0.9
    def configured?
      sessions.has_key?(:default)
    end

    # Connect to the provided database name on the default session.
    #
    # @note Use only in development or test environments for convenience.
    #
    # @example Set the database to connect to.
    #   config.connect_to("mongoid_test")
    #
    # @param [ String ] name The database name.
    #
    # @since 3.0.0
    def connect_to(name, options = { read: :primary })
      self.sessions = {
        default: {
          database: name,
          hosts: [ "localhost:27017" ],
          options: options
        }
      }
    end

    # Return field names that could cause destructive things to happen if
    # defined in a Mongoid::Document.
    #
    # @example Get the destructive fields.
    #   config.destructive_fields
    #
    # @return [ Array<String> ] An array of bad field names.
    def destructive_fields
      Composable.prohibited_methods
    end

    # Load the settings from a compliant mongoid.yml file. This can be used for
    # easy setup with frameworks other than Rails.
    #
    # @example Configure Mongoid.
    #   Mongoid.load!("/path/to/mongoid.yml")
    #
    # @param [ String ] path The path to the file.
    # @param [ String, Symbol ] environment The environment to load.
    #
    # @since 2.0.1
    def load!(path, environment = nil)
	  puts "Mongoid::Config.load! - loading mongoid config at " + path + " with environment " + environment.to_s
      settings = Environment.load_yaml(path, environment)
      if settings.present?
        Sessions.disconnect
        Sessions.clear
        load_configuration(settings)
      end
      settings
    end

    # Get all the models in the application - this is everything that includes
    # Mongoid::Document.
    #
    # @example Get all the models.
    #   config.models
    #
    # @return [ Array<Class> ] All the models in the application.
    #
    # @since 3.1.0
    def models
      @models ||= []
    end

    # Register a model in the application with Mongoid.
    #
    # @example Register a model.
{'fraction_non_alphanumeric': 0.08279535183989671, 'fraction_numerical': 0.005810200129115558, 'mean_word_length': 2.565592635212888, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4784607', 'n_tokens_mistral': 1810, 'n_tokens_neox': 1759, 'n_words': 591}