<commit_before>require 'time'

require 'builder'
require 'rspec'

require 'rspec/core/formatters/base_formatter'

# Dumps rspec results as a JUnit XML file.
# Based on XML schema: http://windyroad.org/dl/Open%20Source/JUnit.xsd
class RSpecJUnitFormatter < RSpec::Core::Formatters::BaseFormatter
  def xml
    @xml ||= Builder::XmlMarkup.new :target => output, :indent => 2
  end

  def start example_count
    @start = Time.now
    super
  end

  def dump_summary duration, example_count, failure_count, pending_count
    super

    xml.instruct!
    xml.testsuite :name => 'rspec', :tests => example_count, :failures => failure_count, :errors => 0, :time => '%.6f' % duration, :timestamp => @start.iso8601 do
      xml.properties
      examples.each do |example|
        send :"dump_summary_example_#{example.execution_result[:status]}", example
      end
    end
  end

  def xml_example example, &block
    xml.testcase :classname => example_classname(example), :name => example.full_description, :time => '%.6f' % example.execution_result[:run_time], &block
  end

  def dump_summary_example_passed example
    xml_example example
  end

  def dump_summary_example_pending example
    xml_example example do
      xml.skipped
    end
  end

  def dump_summary_example_failed example
    exception = example.execution_result[:exception]
    backtrace = format_backtrace exception.backtrace, example

    xml_example example do
      xml.failure :message => exception.to_s, :type => exception.class.name do
        xml.cdata! "#{exception.message}\n#{backtrace.join "\n"}"
      end
    end
  end

  def example_classname example
    example.file_path.sub(%r{\.[^/]*\Z}, "").gsub("/", ".").gsub(%r{\A\.+|\.+\Z}, "")
  end
end

RspecJunitFormatter = RSpecJUnitFormatter
<commit_msg>Double quotes are the besterest<commit_after>require "time"

require "builder"
require "rspec"

require "rspec/core/formatters/base_formatter"

# Dumps rspec results as a JUnit XML file.
# Based on XML schema: http://windyroad.org/dl/Open%20Source/JUnit.xsd
class RSpecJUnitFormatter < RSpec::Core::Formatters::BaseFormatter
  def xml
    @xml ||= Builder::XmlMarkup.new :target => output, :indent => 2
  end

  def start example_count
    @start = Time.now
    super
  end

  def dump_summary duration, example_count, failure_count, pending_count
    super

    xml.instruct!
    xml.testsuite :name => "rspec", :tests => example_count, :failures => failure_count, :errors => 0, :time => "%.6f" % duration, :timestamp => @start.iso8601 do
      xml.properties
      examples.each do |example|
        send :"dump_summary_example_#{example.execution_result[:status]}", example
      end
    end
  end

  def xml_example example, &block
    xml.testcase :classname => example_classname(example), :name => example.full_description, :time => "%.6f" % example.execution_result[:run_time], &block
  end

  def dump_summary_example_passed example
    xml_example example
  end

  def dump_summary_example_pending example
    xml_example example do
      xml.skipped
    end
  end

  def dump_summary_example_failed example
    exception = example.execution_result[:exception]
    backtrace = format_backtrace exception.backtrace, example

    xml_example example do
      xml.failure :message => exception.to_s, :type => exception.class.name do
        xml.cdata! "#{exception.message}\n#{backtrace.join "\n"}"
      end
    end
  end

  def example_classname example
    example.file_path.sub(%r{\.[^/]*\Z}, "").gsub("/", ".").gsub(%r{\A\.+|\.+\Z}, "")
  end
end

RspecJunitFormatter = RSpecJUnitFormatter

{'fraction_non_alphanumeric': 0.11997767857142858, 'fraction_numerical': 0.005580357142857143, 'mean_word_length': 3.773635153129161, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 26}, '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': '1049413', 'n_tokens_mistral': 1161, 'n_tokens_neox': 1118, 'n_words': 276}