<commit_before>class Predef < Module
  VERSION = "0.0.1"

  private_class_method :new

  def self.predef klass, method_name, &definition
    if defined? klass.__PREDEF__
      instance = klass.__PREDEF__
    else
      instance = new(klass)

      singleton_class = class << klass; self ; end
      singleton_class.class_eval do
        define_method(:__PREDEF__) { instance }
      end
    end

    instance.module_eval do
      define_method(method_name, &definition)
    end
    method_name
  end<commit_msg>raise an error given undefined method<commit_after>class Predef < Module
  VERSION = "0.0.1"

  private_class_method :new

  def self.predef klass, method_name, &definition
    unless klass.public_method_defined? method_name
      raise ::Predef::Error, "#{klass}##{method_name} is not defined!"
    end

    if defined? klass.__PREDEF__
      instance = klass.__PREDEF__
    else
      instance = new(klass)

      singleton_class = class << klass; self ; end
      singleton_class.class_eval do
        define_method(:__PREDEF__) { instance }
      end
    end

    instance.module_eval do
      define_method(method_name, &definition)
    end
    method_name
  end
{'fraction_non_alphanumeric': 0.07724957555178268, 'fraction_numerical': 0.0050933786078098476, 'mean_word_length': 2.9563758389261743, 'pattern_counts': {'":': 0, '<': 9, '<?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': '5765623', 'n_tokens_mistral': 365, 'n_tokens_neox': 371, 'n_words': 90}