<commit_before>module SafetyConeMountable
  # Module for configuring safety measures
  module Configuration
    VALID_MEASURES = [
      :block, :warn,
      :notice, :alert
    ].freeze

    VALID_OPTION_KEYS = [
      :method, :controller,
      :action, :name
    ].freeze

    attr_accessor :cones, :options, :redis, :auth

    # Method add a safety measure
    def add(options = {})
      self.options = options
      valid?
      cones[make_key] = options
    end

    # Method to generate a key from the options
    def make_key
      if options.key? :method
        options[:method].to_sym
      elsif options.include?(:controller) && options.include?(:action)
        "#{options[:controller]}_#{options[:action]}".to_sym
      else
        raise(ArgumentError,
              'Options should contain :controller and :action or :method.')
      end
    end

    # Checks the validity of configuration params
    def valid?
      invalid_options = (options.keys - VALID_OPTION_KEYS)
      unless invalid_options.empty?
        raise ArgumentError, "Options #{invalid_options} are not valid."
      else
        true
      end
    end

    # Configuration method for Rails initializer
    def configure
      self.cones = {}
      self.auth = { username: nil, password: <PASSWORD>}

      yield self
    end<commit_msg>Why  : Remove depricated code What : - Removing valid? method from configuration        - Added check for name        - Removed VALID_MEASURES constant<commit_after>module SafetyConeMountable
  # Module for configuring safety measures
  module Configuration
    VALID_OPTION_KEYS = [
      :method, :controller,
      :action, :name
    ].freeze

    attr_accessor :cones, :options, :redis, :auth

    # Method add a safety measure
    def add(options = {})
      self.options = options

      raise(ArgumentError, 'Mandatory param :name missing') unless options[:name]

      cones[make_key] = options
    end

    # Method to generate a key from the options
    def make_key
      if options.key? :method
        options[:method].to_sym
      elsif options.include?(:controller) && options.include?(:action)
        "#{options[:controller]}_#{options[:action]}".to_sym
      else
        raise(ArgumentError,
              'Options should contain :controller and :action or :method.')
      end
    end

    # Configuration method for Rails initializer
    def configure
      self.cones = {}
      self.auth = { username: nil, password: <PASSWORD>}

      yield self
    end
{'fraction_non_alphanumeric': 0.0899640143942423, 'fraction_numerical': 0.0, 'mean_word_length': 2.5641025641025643, 'pattern_counts': {'":': 0, '<': 5, '<?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': '516058', 'n_tokens_mistral': 710, 'n_tokens_neox': 695, 'n_words': 209}