<commit_before>module Spinach
  # Spinach's runner gets the parsed data from the feature and performs the
  # actual calls to the feature classes.
  #
  class Runner
    # Initializes the runner with a parsed feature
    # @param [Hash] data
    #   the parsed feature data
    #
    def initialize(data, options = {})
      @feature_name = data['name']
      @scenarios = data['elements']

      @step_definitions_path = options.delete(:step_definitions_path ) ||
        Spinach.config.step_definitions_path

      @support_path = options.delete(:support_path ) ||
        Spinach.config.support_path

      @reporter = Spinach::config.default_reporter
    end

    # The default reporter associated to this run
    attr_reader :reporter

    # The default path where the steps are located
    attr_reader :step_definitions_path

    # The default path where the support files are located
    attr_reader :support_path

    # Returns the feature class for the provided feature data
    # @return [Spinach::Feature] feature
    #   this runner's feature
    #
    def feature
      @feature ||= Spinach.find_feature(@feature_name)
    end

    # @return [Hash]
    #   the parsed scenarios for this runner's feature
    #
    def scenarios
      @scenarios
    end

    # Runs this runner and outputs the results in a colorful manner.
    #
    def run
      require_steps

      step_count = 0
      reports = []

      reporter.feature(@feature_name)

      scenarios.each do |scenario|
        Scenario.new(self, scenario).run
      end
      reporter.end

    end

    def require_steps
      Dir.glob(
        File.expand_path File.join(step_definitions_path, '**', '*.rb')
      ).each do |file|
        require file
      end
    end
    private :require_steps

    def require_support
      Dir.glob(
        File.expand_path File.join(support_path, '**', '*.rb')
      ).each do |file|
        require file
      end
    end
    private :require_steps

    class Scenario
      attr_reader :name, :steps

      def initialize(runner, data)
        @name = data['name']
        @steps = data['steps']
        @runner = runner
      end

      def reporter; @runner.reporter; end;

      def feature
        @feature ||= @runner.feature.new
      end

      def run
        reporter.scenario(name)
        feature.send(:before)
        steps.each do |step|
          step_name = "#{step['keyword'].strip} #{step['name']}"
          unless @failed
            @failed = true
            begin
              feature.execute_step(step_name)
              reporter.step(step_name, :success)
              @failed = false
            rescue MiniTest::Assertion=>e
              reporter.step(step_name, :failure)
            rescue Spinach::StepNotDefinedException=>e
              reporter.step(step_name, :undefined_step)
            rescue StandardError=>e
              reporter.step(step_name, :error)
            end<commit_msg>More cosmetic changes. FU @oriolgual xDD<commit_after>module Spinach
  # Spinach's runner gets the parsed data from the feature and performs the
  # actual calls to the feature classes.
  #
  class Runner
    # Initializes the runner with a parsed feature
    # @param [Hash] data
    #   the parsed feature data
    #
    def initialize(data, options = {})
      @feature_name = data['name']
      @scenarios = data['elements']

      @step_definitions_path = options.delete(:step_definitions_path ) ||
        Spinach.config.step_definitions_path

      @support_path = options.delete(:support_path ) ||
        Spinach.config.support_path

      @reporter = Spinach::config.default_reporter
    end

    # The default reporter associated to this run
    attr_reader :reporter

    # The default path where the steps are located
    attr_reader :step_definitions_path

    # The default path where the support files are located
    attr_reader :support_path

    # Returns the feature class for the provided feature data
    # @return [Spinach::Feature] feature
    #   this runner's feature
    #
    def feature
      @feature ||= Spinach.find_feature(@feature_name)
    end

    # @return [Hash]
    #   the parsed scenarios for this runner's feature
    #
    def scenarios
      @scenarios
    end

    # Runs this runner and outputs the results in a colorful manner.
    #
    def run
      require_steps

      step_count = 0
      reports = []

      reporter.feature(@feature_name)

      scenarios.each do |scenario|
        Scenario.new(self, scenario).run
      end
      reporter.end

    end

    def require_steps
      Dir.glob(
        File.expand_path File.join(step_definitions_path, '**', '*.rb')
      ).each do |file|
        require file
      end
    end
    private :require_steps

    def require_support
      Dir.glob(
        File.expand_path File.join(support_path, '**', '*.rb')
      ).each do |file|
        require file
      end
    end
    private :require_steps

    class Scenario
      attr_reader :name, :steps

      def initialize(runner, data)
        @name = data['name']
        @steps = data['steps']
        @runner = runner
      end

      def reporter; @runner.reporter; end;

      def feature
        @feature ||= @runner.feature.new
      end

      def run
        reporter.scenario(name)
        feature.send(:before)
        steps.each do |step|
          step_name = "#{step['keyword'].strip} #{step['name']}"
          unless @failed
            @failed = true
            begin
              feature.execute_step(step_name)
              reporter.step(step_name, :success)
              @failed = false
            rescue MiniTest::Assertion=>e
              reporter.step(step_name, :failure)
            rescue Spinach::StepNotDefinedException => e
              reporter.step(step_name, :undefined_step)
            rescue StandardError => e
              reporter.step(step_name, :error)
            end
{'fraction_non_alphanumeric': 0.08501270110076206, 'fraction_numerical': 0.00033869602032176124, 'mean_word_length': 2.1667560321715817, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '5792560', 'n_tokens_mistral': 1682, 'n_tokens_neox': 1640, 'n_words': 462}