<commit_before>module Grunt
  class Setting
    class << self
      def get(name, default = nil)
        if setting = Command.first(:name => /^#{Regexp.escape(name)}$/i, :type => "plain_text")
          unserialize(setting.body)
        else
          default
        end
      end
      
      def set(name, value)
        setting = Command.first_or_new(:name => name, :type => "plain_text")
        setting.body = serialize(value)
        setting.save
      end
      
      def increment(name, by = 1)
        by = case by
             when Numeric then by
             when String then by.to_num
             else
               raise ArgumentError, "cannot increment by the value of a #{by.class.name}"
             end
        
        setting = get(name) || 0
        setting = case setting
                  when Numeric then setting
                  when String then setting.to_num
                  else
                    raise ArgumentError, "#{name.class.name} cannot be incremented"
                  end
        
        setting += by
        set(name, setting)
        setting
      end
      alias :inc :increment
      
      def decrement(name, by = 1)
        increment(name, by * -1)
      end
      alias :dec :decrement
      <commit_msg>Stuck the class name of the wrong variable in an error message<commit_after>module Grunt
  class Setting
    class << self
      def get(name, default = nil)
        if setting = Command.first(:name => /^#{Regexp.escape(name)}$/i, :type => "plain_text")
          unserialize(setting.body)
        else
          default
        end
      end
      
      def set(name, value)
        setting = Command.first_or_new(:name => name, :type => "plain_text")
        setting.body = serialize(value)
        setting.save
      end
      
      def increment(name, by = 1)
        by = case by
             when Numeric then by
             when String then by.to_num
             else
               raise ArgumentError, "cannot increment by the value of a #{by.class.name}"
             end
        
        setting = get(name) || 0
        setting = case setting
                  when Numeric then setting
                  when String then setting.to_num
                  else
                    raise ArgumentError, "#{setting.class.name} cannot be incremented"
                  end
        
        setting += by
        set(name, setting)
        setting
      end
      alias :inc :increment
      
      def decrement(name, by = 1)
        increment(name, by * -1)
      end
      alias :dec :decrement
      
{'fraction_non_alphanumeric': 0.07990690457719161, 'fraction_numerical': 0.0031031807602792862, 'mean_word_length': 1.4147940074906367, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '2615889', 'n_tokens_mistral': 687, 'n_tokens_neox': 672, 'n_words': 219}