<commit_before># encoding: UTF-8
# frozen_string_literal: true

module NRSER::RSpex::ExampleGroup
  
  # Describe a method of the parent subject.
  # 
  # @return [void]
  # 
  def describe_method method_name, *description, **metadata, &body
    # Due to legacy, we only auto-bind if the name is a symbol
    # 
    # TODO  Get rid of this
    # 
    subject_block = if method_name.is_a? Symbol
      -> { super().method method_name }
    end
    
    name_prefix = if  self.respond_to?( :metadata ) &&
                      self.metadata.key?( :constructor_args )
      '#'
    else
      '.'
    end
    
    method = if self.try( :metadata )
      getter = if self.metadata.key?( :constructor_args )
        :instance_method
      else
        :method
      end
      
      target = self.metadata[:class] || self.metadata[:module]
      
      if target
        begin
          target.public_send getter, method_name
        rescue
          nil
        end
      end
    end
    
    name_string = NRSER::RSpex::Format.md_code_quote \
      "#{ name_prefix }#{ method_name }"
    
    # Create the RSpec example group context
    describe_x \
      name_string,
      NRSER::Meta::Source::Location.new( method ),
      *description,
      type: :method,
      metadata: {
        **metadata,
        method_name: method_name,
      },
      subject_block: subject_block,
      &body
  end # #describe_method
  
end # module NRSER::RSpex::ExampleGroup
<commit_msg>All-caps alias for describe_method<commit_after># encoding: UTF-8
# frozen_string_literal: true

module NRSER::RSpex::ExampleGroup
  
  # Describe a method of the parent subject.
  # 
  # @return [void]
  # 
  def describe_method method_name, *description, **metadata, &body
    # Due to legacy, we only auto-bind if the name is a symbol
    # 
    # TODO  Get rid of this
    # 
    subject_block = if method_name.is_a? Symbol
      -> { super().method method_name }
    end
    
    name_prefix = if  self.respond_to?( :metadata ) &&
                      self.metadata.key?( :constructor_args )
      '#'
    else
      '.'
    end
    
    method = if self.try( :metadata )
      getter = if self.metadata.key?( :constructor_args )
        :instance_method
      else
        :method
      end
      
      target = self.metadata[:class] || self.metadata[:module]
      
      if target
        begin
          target.public_send getter, method_name
        rescue
          nil
        end
      end
    end
    
    name_string = NRSER::RSpex::Format.md_code_quote \
      "#{ name_prefix }#{ method_name }"
    
    # Create the RSpec example group context
    describe_x \
      name_string,
      NRSER::Meta::Source::Location.new( method ),
      *description,
      type: :method,
      metadata: {
        **metadata,
        method_name: method_name,
      },
      subject_block: subject_block,
      &body
  end # #describe_method

  alias_method :METHOD, :describe_method
  
end # module NRSER::RSpex::ExampleGroup

{'fraction_non_alphanumeric': 0.0960320106702234, 'fraction_numerical': 0.0006668889629876625, 'mean_word_length': 2.045685279187817, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1363079', 'n_tokens_mistral': 928, 'n_tokens_neox': 919, 'n_words': 224}