<commit_before>require "king_konf/variable"
require "king_konf/config_file_loader"

module KingKonf
  class Config
    @variables = {}

    class << self
      def env_prefix(prefix = nil)
        @env_prefix = prefix if prefix
        @env_prefix
      end

      def ignore_unknown_variables(should_ignore)
        @ignore_unknown_variables = should_ignore
      end

      def ignore_unknown_variables?
        # Always ignore about unknown ENV vars if there's no prefix defined.
        @ignore_unknown_variables || !env_prefix
      end

      def variable(name)
        @variables.fetch(name.to_s)
      end

      def variable?(name)
        @variables.key?(name.to_s)
      end

      def variables
        @variables.values
      end

      TYPES.each do |type|
        define_method(type) do |name, default: nil, required: false, allowed_values: nil, validate_with: ->(_) { true }, **options|
          description, @desc = @desc, nil
          variable = Variable.new(
            name: name,
            type: type,
            default: default,
            required: required,
            description: description,
            allowed_values: allowed_values,
            validate_with: validate_with,
            options: options,
          )

          @variables ||= {}
          @variables[name.to_s] = variable

          define_method(name) do
            get(name)
          end

          if variable.boolean?
            alias_method("#{name}?", name)
          end
<commit_msg>Fixes ruby warning about uninitialized @desc var<commit_after>require "king_konf/variable"
require "king_konf/config_file_loader"

module KingKonf
  class Config
    @variables = {}

    class << self
      def env_prefix(prefix = nil)
        @env_prefix = prefix if prefix
        @env_prefix
      end

      def ignore_unknown_variables(should_ignore)
        @ignore_unknown_variables = should_ignore
      end

      def ignore_unknown_variables?
        # Always ignore about unknown ENV vars if there's no prefix defined.
        @ignore_unknown_variables || !env_prefix
      end

      def variable(name)
        @variables.fetch(name.to_s)
      end

      def variable?(name)
        @variables.key?(name.to_s)
      end

      def variables
        @variables.values
      end

      TYPES.each do |type|
        define_method(type) do |name, default: nil, required: false, allowed_values: nil, validate_with: ->(_) { true }, **options|
          description, @desc = @desc, nil if defined?(@desc)
          variable = Variable.new(
            name: name,
            type: type,
            default: default,
            required: required,
            description: description,
            allowed_values: allowed_values,
            validate_with: validate_with,
            options: options,
          )

          @variables ||= {}
          @variables[name.to_s] = variable

          define_method(name) do
            get(name)
          end

          if variable.boolean?
            alias_method("#{name}?", name)
          end

{'fraction_non_alphanumeric': 0.08420707732634339, 'fraction_numerical': 0.0, 'mean_word_length': 1.9497584541062802, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '479040', 'n_tokens_mistral': 843, 'n_tokens_neox': 822, 'n_words': 212}