<commit_before>module Moltrio
  module Config
    class Storage
      def [](key)
        raise NotImplementedError
      end

      def []=(key, value)
        raise NotImplementedError
      end

      def has_key?(key)
        raise NotImplementedError
      end

      def fetch(key, *args)
        return self[key] if has_key?(key)
        return args.first if args.size == 1

        raise KeyError, key
      end
    end
  end<commit_msg>Allow passing a block to Moltrio::Config.fetch to compute a default<commit_after>module Moltrio
  module Config
    class Storage
      def [](key)
        raise NotImplementedError
      end

      def []=(key, value)
        raise NotImplementedError
      end

      def has_key?(key)
        raise NotImplementedError
      end

      def fetch(key, default = Moltrio::Undefined)
        if has_key?(key)
          self[key]
        elsif default != Moltrio::Undefined
          default
        elsif block_given?
          yield
        else
          raise KeyError, key
        end
      end
    end
  end
{'fraction_non_alphanumeric': 0.06244087038789026, 'fraction_numerical': 0.000946073793755913, 'mean_word_length': 1.806366047745358, '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': '4244851', 'n_tokens_mistral': 306, 'n_tokens_neox': 300, 'n_words': 92}