<commit_before># Copyright (c) 2006-2012 <NAME> <<EMAIL>>
# See the file LICENSE.txt included with the distribution for
# software license details.

require 'ci/reporter/core'

module CI
  module Reporter
    module RSpecFormatters
      begin
        require 'rspec/core/formatters/base_formatter'
        require 'rspec/core/formatters/progress_formatter'
        require 'rspec/core/formatters/documentation_formatter'
        BaseFormatter = ::RSpec::Core::Formatters::BaseFormatter
        ProgressFormatter = ::RSpec::Core::Formatters::ProgressFormatter
        DocFormatter = ::RSpec::Core::Formatters::DocumentationFormatter
      rescue LoadError => first_error
        begin
          require 'spec/runner/formatter/progress_bar_formatter'
          require 'spec/runner/formatter/specdoc_formatter'
          BaseFormatter = ::Spec::Runner::Formatter::BaseFormatter
          ProgressFormatter = ::Spec::Runner::Formatter::ProgressBarFormatter
          DocFormatter = ::Spec::Runner::Formatter::SpecdocFormatter
        rescue LoadError
          raise first_error
        end
      end
    end

    # Wrapper around a <code>RSpec</code> error or failure to be used by the test suite to interpret results.
    class RSpecFailure
      attr_reader :exception
      def initialize(failure)
        @failure = failure
        @exception = failure.exception
      end

      def failure?
        @failure.expectation_not_met?
      end

      def error?
        !failure?
      end

      def name() exception.class.name end
      def message() exception.message end
      def location() (exception.backtrace || ["No backtrace available"]).join("\n") end
    end

    class RSpec2Failure < RSpecFailure
      def initialize(example, formatter)
        @formatter = formatter
        @example = example
        @exception = @example.execution_result[:exception] || @example.execution_result[:exception_encountered]
      end

      def name
        @exception.class.name
      end

      def message
        @exception.message
      end

      def failure?
        exception.is_a?(::RSpec::Expectations::ExpectationNotMetError)
      end

      def location
        output = []
        output.push "#{exception.class.name << ":"}" unless exception.class.name =~ /RSpec/<commit_msg>Attempt to restore RSpec 2.2.1 compatibility in the proper place<commit_after># Copyright (c) 2006-2012 <NAME> <<EMAIL>>
# See the file LICENSE.txt included with the distribution for
# software license details.

require 'ci/reporter/core'

module CI
  module Reporter
    module RSpecFormatters
      begin
        require 'rspec/core/formatters/base_formatter'
        require 'rspec/core/formatters/progress_formatter'
        require 'rspec/core/formatters/documentation_formatter'
        BaseFormatter = ::RSpec::Core::Formatters::BaseFormatter
        ProgressFormatter = ::RSpec::Core::Formatters::ProgressFormatter
        DocFormatter = ::RSpec::Core::Formatters::DocumentationFormatter
      rescue LoadError => first_error
        begin
          require 'spec/runner/formatter/progress_bar_formatter'
          require 'spec/runner/formatter/specdoc_formatter'
          BaseFormatter = ::Spec::Runner::Formatter::BaseFormatter
          ProgressFormatter = ::Spec::Runner::Formatter::ProgressBarFormatter
          DocFormatter = ::Spec::Runner::Formatter::SpecdocFormatter
        rescue LoadError
          raise first_error
        end
      end
    end

    # Wrapper around a <code>RSpec</code> error or failure to be used by the test suite to interpret results.
    class RSpecFailure
      attr_reader :exception
      def initialize(failure)
        @failure = failure
        @exception = failure.exception
      end

      def failure?
        @failure.expectation_not_met?
      end

      def error?
        !failure?
      end

      def name() exception.class.name end
      def message() exception.message end
      def location() (exception.backtrace || ["No backtrace available"]).join("\n") end
    end

    class RSpec2Failure < RSpecFailure
      def initialize(example, formatter)
        @formatter = formatter
        @example = example
        if @example.respond_to?(:execution_result)
          @exception = @example.execution_result[:exception] || @example.execution_result[:exception_encountered]
        else
          @exception = @example.metadata[:execution_result][:exception]
        end
      end

      def name
        @exception.class.name
      end

      def message
        @exception.message
      end

      def failure?
        exception.is_a?(::RSpec::Expectations::ExpectationNotMetError)
      end

      def location
        output = []
        output.push "#{exception.class.name << ":"}" unless exception.class.name =~ /RSpec/
{'fraction_non_alphanumeric': 0.09085199916265438, 'fraction_numerical': 0.004396064475612309, 'mean_word_length': 2.753338570306363, 'pattern_counts': {'":': 2, '<': 19, '<?xml version=': 0, '>': 15, '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': '2609614', 'n_tokens_mistral': 1273, 'n_tokens_neox': 1216, 'n_words': 306}