<commit_before>module MAbbre # rubocop:disable Style/Documentation
  ##
  # This is a temporary module that is run when loading MAbbre in order to add patches on some Ruby
  # versions/implementations. After the environment is patched it will be automatically removed.
  module Compatibility
    ##
    # Relative path to the directory where patch files for the Object class live.
    PATH_TO_OBJECT_PATCHES = "mabbre/patch/object_mixin".freeze

    ##
    # A hash of patch names for the Object class. Each patch name has a +true+ or +false+ value assigned that represents
    # if they need to be applied or not.
    OBJECT_PATCHES = {
      :respond_to_missing => !Object.private_instance_methods.map(&:to_sym).include?(:respond_to_missing?)
    }.freeze

    class << self
      private

      ##
      # call-seq:
      #   init_self() => nil
      #
      # This method is automatically called by this module in order to apply all patches.
      #
      # Returns a +nil+ value.
      def init_self
        check_object
        nil
      end

      ##
      # call-seq:
      #   check_object() => Object or nil
      #
      # Checks all available patches for the Object class and applies the ones that are needed.
      #
      # Returns Object if patches were applied or +nil+ otherwise.
      def check_object
        OBJECT_PATCHES.each {|patch, needed| require "#{PATH_TO_OBJECT_PATCHES}/#{patch}" if needed }
        Object.instance_eval { include Patch::ObjectMixin } if OBJECT_PATCHES.values.any?
      end
    end

    init_self
  end

  remove_const :Compatibility
end<commit_msg>Yet another attempt at reducing Compatibility complexity outside of method definitions.<commit_after>module MAbbre # rubocop:disable Style/Documentation
  ##
  # This is a temporary module that is run when loading MAbbre in order to add patches on some Ruby
  # versions/implementations. After the environment is patched it will be automatically removed.
  module Compatibility
    class << self
      private

      ##
      # call-seq:
      #   init_self() => nil
      #
      # This method is automatically called by this module in order to apply all patches.
      #
      # Returns a +nil+ value.
      def init_self
        check_object
        nil
      end

      ##
      # call-seq:
      #   check_object() => Object or nil
      #
      # Checks all available patches for the Object class and applies the ones that are needed.
      #
      # Returns Object if patches were applied or +nil+ otherwise.
      def check_object
        OBJECT_PATCHES.each {|patch, needed| require "#{PATH_TO_OBJECT_PATCHES}/#{patch}" if needed }
        Object.instance_eval { include Patch::ObjectMixin } if OBJECT_PATCHES.values.any?
      end

      ##
      # call-seq:
      #   needs_respond_to_missing?() => true or false
      #
      # Returns +true+ if Object needs to be patched with MAbbre::Patch::ObjectMixin and +false+ otherwise.
      def needs_respond_to_missing?
        !Object.private_instance_methods.map(&:to_sym).include?(:respond_to_missing?)
      end
    end

    ##
    # Relative path to the directory where patch files for the Object class live.
    PATH_TO_OBJECT_PATCHES = "mabbre/patch/object_mixin".freeze

    ##
    # A hash of patch names for the Object class. Each patch name has a +true+ or +false+ value assigned that represents
    # if they need to be applied or not.
    OBJECT_PATCHES = {
      :respond_to_missing => needs_respond_to_missing?
    }.freeze

    init_self
  end

  remove_const :Compatibility
end
{'fraction_non_alphanumeric': 0.07189173949816746, 'fraction_numerical': 0.0, 'mean_word_length': 2.653964984552008, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, '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': '4863420', 'n_tokens_mistral': 1035, 'n_tokens_neox': 992, 'n_words': 357}