<commit_before>require 'allowing/extensions/string'
require 'allowing/validations'

module Allowing
  UnknownValidationError = Class.new(StandardError)

  class ValidationBuilder
    using Extensions::String

    VALIDATION_CLASS_FORMAT = '%{type}Validation'

    def initialize(type, rule)
      @type      = type
      @rule      = rule
    end

    def build
      validation_class.new(@rule)
    end

    private

    def validation_class
      Validations.const_get(constant_name)
    rescue NameError
      raise UnknownValidationError,
            "Don't know how to create validation '#{@type}'"
    end

    def constant_name
      VALIDATION_CLASS_FORMAT % { type: @type.to_s.classify }
    end
  end
end<commit_msg>Remove some extra spaces<commit_after>require 'allowing/extensions/string'
require 'allowing/validations'

module Allowing
  UnknownValidationError = Class.new(StandardError)

  class ValidationBuilder
    using Extensions::String

    VALIDATION_CLASS_FORMAT = '%{type}Validation'

    def initialize(type, rule)
      @type = type
      @rule = rule
    end

    def build
      validation_class.new(@rule)
    end

    private

    def validation_class
      Validations.const_get(constant_name)
    rescue NameError
      raise UnknownValidationError,
            "Don't know how to create validation '#{@type}'"
    end

    def constant_name
      VALIDATION_CLASS_FORMAT % { type: @type.to_s.classify }
    end
  end
end
{'fraction_non_alphanumeric': 0.0729525120440468, 'fraction_numerical': 0.0, 'mean_word_length': 3.016574585635359, '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': '953878', 'n_tokens_mistral': 434, 'n_tokens_neox': 409, 'n_words': 102}