<commit_before># encoding: utf-8

# Module that adds descendant tracking to a class
module DescendantsTracker

  # @private
  def self.extended(descendant)
    setup(descendant)
  end
  private_class_method :extended

  # @return [Array]
  #
  # @private
  def self.setup(descendant)
    descendant.instance_variable_set('@descendants', [])
  end

  # Return the descendants of this class
  #
  # @example
  #   descendants = ParentClass.descendants
  #
  # @return [Array<Class>]
  #
  # @api public
  def descendants
    @descendants
  end

  # Add the descendant to this class and the superclass
  #
  # @param [Class] descendant
  #
  # @return [self]
  #
  # @api private
  def add_descendant(descendant)
    ancestor = superclass
    if ancestor.respond_to?(:add_descendant)
      ancestor.add_descendant(descendant)
    end
    descendants.unshift(descendant)
    self
  end

private

  # Hook called when class is inherited
  #
  # @param [Class] descendant
  #
  # @return [self]
  #
  # @api private
  def inherited(descendant)<commit_msg>Refactor descendants method to be an attr_reader<commit_after># encoding: utf-8

# Module that adds descendant tracking to a class
module DescendantsTracker

  # Return the descendants of this class
  #
  # @example
  #   descendants = ParentClass.descendants
  #
  # @return [Array<Class<DescendantsTracker>>]
  #
  # @api public
  attr_reader :descendants

  # @private
  def self.extended(descendant)
    setup(descendant)
  end
  private_class_method :extended

  # @return [Array]
  #
  # @private
  def self.setup(descendant)
    descendant.instance_variable_set('@descendants', [])
  end

  # Add the descendant to this class and the superclass
  #
  # @param [Class] descendant
  #
  # @return [self]
  #
  # @api private
  def add_descendant(descendant)
    ancestor = superclass
    if ancestor.respond_to?(:add_descendant)
      ancestor.add_descendant(descendant)
    end
    descendants.unshift(descendant)
    self
  end

private

  # Hook called when class is inherited
  #
  # @param [Class] descendant
  #
  # @return [self]
  #
  # @api private
  def inherited(descendant)
{'fraction_non_alphanumeric': 0.09069658719027583, 'fraction_numerical': 0.0009350163627863488, 'mean_word_length': 3.4123711340206184, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '2981379', 'n_tokens_mistral': 721, 'n_tokens_neox': 695, 'n_words': 177}