<commit_before>module ActionView::Helpers::CaptureHelper

  def content_for_with_annotation(name, content = nil, &block)
    content = capture(&block) if block_given?
    file = caller.first.gsub(/\s`.*/, '')
    content_for_annotation = "content_for(#{name.inspect}) from: #{file}"
    content = %Q{
      <!-- START #{content_for_annotation} -->
        #{content}
      <!-- END #{content_for_annotation} -->
     }      
    content_for_without_annotation(name, content)
  end

  if (ENV['RAILS_ENV'] == 'development' || TEST_ANNOTATE_CONTENT_FOR)
    alias_method_chain :content_for, :annotation
  else
    alias_method :content_for_without_annotation, :content_for
  end

end



<commit_msg>Detecting the caller from the view or helper.<commit_after>module ActionView::Helpers::CaptureHelper

  def content_for_with_annotation(name, content = nil, &block)
    content = capture(&block) if block_given?
    file = caller.detect do |file| 
      file =~ /\/app\/views\// || file =~ /\/app\/helpers\//
    end
    if file
      content_for_annotation = "content_for(#{name.inspect}) from: #{file.gsub(/:in\s+`.*/, '')}"
      content = %Q{
        <!-- START #{content_for_annotation} -->
          #{content}
        <!-- END #{content_for_annotation} -->
       }      
    end
    content_for_without_annotation(name, content)
  end

  if (ENV['RAILS_ENV'] == 'development' || TEST_ANNOTATE_CONTENT_FOR)
    alias_method_chain :content_for, :annotation
  else
    alias_method :content_for_without_annotation, :content_for
  end

end




{'fraction_non_alphanumeric': 0.13804277381723914, 'fraction_numerical': 0.0, 'mean_word_length': 3.3492957746478873, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6171843', 'n_tokens_mistral': 501, 'n_tokens_neox': 489, 'n_words': 97}