<commit_before>module RSpecStepwise
  class ApatheticReporter < ::RSpec::Core::Reporter
    def initialize
      @examples = []
      @failed_examples = []
      @pending_examples = []
      @duration = @start = @load_time = nil
    end

    #def notify(*args)
      #noop
    #end
  end

  class WholeListExample < RSpec::Core::Example
    def initialize(example_group_class, reporter, descriptions, metadata)
      super(example_group_class, descriptions, metadata)
      #@reporter = ApatheticReporter.new
      @reporter = reporter
      build_example_block
    end

    def start(reporter)
      super(@reporter)
    end

    def finish(reporter)
      super(@reporter)
    end

    def build_example_block
      #variables of concern: reporter, instance
      reporter = @reporter
      whole_list = self
      @example_block = proc do
        begin
          self.class.filtered_examples.inject(true) do |success, example|
            if RSpec.respond_to? :wants_to_quit
              break if RSpec.wants_to_quit
            else
              break if RSpec.world.wants_to_quit
            end
            example.extend StepExample
            unless success
              example.metadata[:skip] = "Previous step failed"
              RSpec::Core::Pending.mark_pending!(example, example.skip)
            end
            succeeded = with_indelible_ivars do
              example.run(self, reporter)
            end
            unless example.exception.nil?
              whole_list.set_exception(example.exception)
            end

            if self.class.fail_fast? && !succeeded
              if RSpec.respond_to? :wants_to_quit=
                RSpec.wants_to_quit = true
              else
                RSpec.world.wants_to_quit = true
              end
            end
            success && succeeded
          end
        end
      end
    end
  end

  module StepExample
    def run_before_each
      @example_group_class.run_before_step(self)
    rescue Object => ex
      puts "\n#{__FILE__}:#{__LINE__} => #{[ex, ex.backtrace].pretty_inspect}"
    end
    alias run_before_example run_before_each

    def run_after_each
      @example_group_class.run_after_step(self)
    end
    alias run_after_example run_after_each

    def with_around_hooks
      yield
    end
  end

  def self.warnings
    @warnings ||= Hash.new do |h,warning|
      warn warning
      h[warning] = true
    end
  end

  module ClassMethods
    #This is hacky and needs a more general solution
    #Something like cloning the current conf and having RSpec::Stepwise::config ?<commit_msg>Reducing warn to puts<commit_after>module RSpecStepwise
  class ApatheticReporter < ::RSpec::Core::Reporter
    def initialize
      @examples = []
      @failed_examples = []
      @pending_examples = []
      @duration = @start = @load_time = nil
    end

    #def notify(*args)
      #noop
    #end
  end

  class WholeListExample < RSpec::Core::Example
    def initialize(example_group_class, reporter, descriptions, metadata)
      super(example_group_class, descriptions, metadata)
      #@reporter = ApatheticReporter.new
      @reporter = reporter
      build_example_block
    end

    def start(reporter)
      super(@reporter)
    end

    def finish(reporter)
      super(@reporter)
    end

    def build_example_block
      #variables of concern: reporter, instance
      reporter = @reporter
      whole_list = self
      @example_block = proc do
        begin
          self.class.filtered_examples.inject(true) do |success, example|
            if RSpec.respond_to? :wants_to_quit
              break if RSpec.wants_to_quit
            else
              break if RSpec.world.wants_to_quit
            end
            example.extend StepExample
            unless success
              example.metadata[:skip] = "Previous step failed"
              RSpec::Core::Pending.mark_pending!(example, example.skip)
            end
            succeeded = with_indelible_ivars do
              example.run(self, reporter)
            end
            unless example.exception.nil?
              whole_list.set_exception(example.exception)
            end

            if self.class.fail_fast? && !succeeded
              if RSpec.respond_to? :wants_to_quit=
                RSpec.wants_to_quit = true
              else
                RSpec.world.wants_to_quit = true
              end
            end
            success && succeeded
          end
        end
      end
    end
  end

  module StepExample
    def run_before_each
      @example_group_class.run_before_step(self)
    rescue Object => ex
      puts "\n#{__FILE__}:#{__LINE__} => #{[ex, ex.backtrace].pretty_inspect}"
    end
    alias run_before_example run_before_each

    def run_after_each
      @example_group_class.run_after_step(self)
    end
    alias run_after_example run_after_each

    def with_around_hooks
      yield
    end
  end

  def self.warnings
    @warnings ||= Hash.new do |h,warning|
      puts warning #should be warn, but RSpec complains
      h[warning] = true
    end
  end

  module ClassMethods
    #This is hacky and needs a more general solution
    #Something like cloning the current conf and having RSpec::Stepwise::config ?
{'fraction_non_alphanumeric': 0.0700746697300402, 'fraction_numerical': 0.0, 'mean_word_length': 2.080188679245283, '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': '6245473', 'n_tokens_mistral': 1522, 'n_tokens_neox': 1476, 'n_words': 361}