<commit_before>require 'cucumber/platform'
require 'gherkin/formatter/ansi_escapes'

begin
  # Support Rake > 0.8.7
  require 'rake/dsl_definition'
  include Rake::DSL
rescue LoadError
end

module Cucumber
  module Rake
    # Defines a Rake task for running features.
    #
    # The simplest use of it goes something like:
    #
    #   Cucumber::Rake::Task.new
    #
    # This will define a task named <tt>cucumber</tt> described as 'Run Cucumber features'.
    # It will use steps from 'features/**/*.rb' and features in 'features/**/*.feature'.
    #
    # To further configure the task, you can pass a block:
    #
    #   Cucumber::Rake::Task.new do |t|
    #     t.cucumber_opts = %w{--format progress}
    #   end
    #
    # This task can also be configured to be run with RCov:
    #
    #   Cucumber::Rake::Task.new do |t|
    #     t.rcov = true
    #   end
    #
    # See the attributes for additional configuration possibilities.
    class Task
      include Gherkin::Formatter::AnsiEscapes

      class InProcessCucumberRunner #:nodoc:
        attr_reader :args

        def initialize(libs, cucumber_opts, feature_files)
          raise "libs must be an Array when running in-process" unless Array === libs
          libs.reverse.each{|lib| $LOAD_PATH.unshift(lib)}
          @args = (
            cucumber_opts +
            feature_files
          ).flatten.compact
        end

        def run
          require 'cucumber/cli/main'
          failure = Cucumber::Cli::Main.execute(args)
          raise "Cucumber failed" if failure
        end
      end

      class ForkedCucumberRunner #:nodoc:

        def initialize(libs, cucumber_bin, cucumber_opts, bundler, feature_files)
          @libs          = libs
          @cucumber_bin  = cucumber_bin
          @cucumber_opts = cucumber_opts
          @bundler       = bundler
          @feature_files = feature_files
        end

        def load_path(libs)
          ['"%s"' % @libs.join(File::PATH_SEPARATOR)]
        end

        def quoted_binary(cucumber_bin)
          ['"%s"' % cucumber_bin]
        end

        def use_bundler
          @bundler.nil? ? File.exist?("./Gemfile") && gem_available?("bundler") : @bundler
        end

        def gem_available?(gemname)
          gem_available_new_rubygems?(gemname) || gem_available_old_rubygems?(gemname)
        end

        def gem_available_old_rubygems?(gemname)
          Gem.available?(gemname)
        end

        def gem_available_new_rubygems?(gemname)
          Gem::Specification.respond_to?(:find_all_by_name) && Gem::Specification.find_all_by_name(gemname).any?
        end

        def cmd
          if use_bundler
            [ RUBY, '-S', 'bundle', 'exec', 'cucumber', @cucumber_opts,
            @feature_files ].flatten
          else
            [ RUBY, '-I', load_path(@libs), quoted_binary(@cucumber_bin),
            @cucumber_opts, @feature_files ].flatten
          end
        end

        def run
          sh(cmd.join(" "))
        end
      end

      class RCovCucumberRunner < ForkedCucumberRunner #:nodoc:

        def initialize(libs, cucumber_bin, cucumber_opts, bundler, feature_files, rcov_opts)
          super(       libs, cucumber_bin, cucumber_opts, bundler, feature_files )
          @rcov_opts = rcov_opts
        end

        def cmd
          if use_bundler
            [RUBY, '-S', 'bundle', 'exec', 'rcov', @rcov_opts,
             quoted_binary(@cucumber_bin), '--', @cucumber_opts, @feature_files].flatten
          else
            [RUBY, '-I', load_path(@libs), '-S', 'rcov', @rcov_opts,
             quoted_binary(@cucumber_bin), '--', @cucumber_opts, @feature_files].flatten
          end
        end
        
      end

      LIB = File.expand_path(File.dirname(__FILE__) + '/../..') #:nodoc:

      # Directories to add to the Ruby $LOAD_PATH
      attr_accessor :libs

      # Name of the cucumber binary to use for running features. Defaults to Cucumber::BINARY
      attr_accessor :binary<commit_msg>Use our own Ruby binary constant instead of Rake's<commit_after>require 'cucumber/platform'
require 'gherkin/formatter/ansi_escapes'

begin
  # Support Rake > 0.8.7
  require 'rake/dsl_definition'
  include Rake::DSL
rescue LoadError
end

module Cucumber
  module Rake
    # Defines a Rake task for running features.
    #
    # The simplest use of it goes something like:
    #
    #   Cucumber::Rake::Task.new
    #
    # This will define a task named <tt>cucumber</tt> described as 'Run Cucumber features'.
    # It will use steps from 'features/**/*.rb' and features in 'features/**/*.feature'.
    #
    # To further configure the task, you can pass a block:
    #
    #   Cucumber::Rake::Task.new do |t|
    #     t.cucumber_opts = %w{--format progress}
    #   end
    #
    # This task can also be configured to be run with RCov:
    #
    #   Cucumber::Rake::Task.new do |t|
    #     t.rcov = true
    #   end
    #
    # See the attributes for additional configuration possibilities.
    class Task
      include Gherkin::Formatter::AnsiEscapes

      class InProcessCucumberRunner #:nodoc:
        attr_reader :args

        def initialize(libs, cucumber_opts, feature_files)
          raise "libs must be an Array when running in-process" unless Array === libs
          libs.reverse.each{|lib| $LOAD_PATH.unshift(lib)}
          @args = (
            cucumber_opts +
            feature_files
          ).flatten.compact
        end

        def run
          require 'cucumber/cli/main'
          failure = Cucumber::Cli::Main.execute(args)
          raise "Cucumber failed" if failure
        end
      end

      class ForkedCucumberRunner #:nodoc:

        def initialize(libs, cucumber_bin, cucumber_opts, bundler, feature_files)
          @libs          = libs
          @cucumber_bin  = cucumber_bin
          @cucumber_opts = cucumber_opts
          @bundler       = bundler
          @feature_files = feature_files
        end

        def load_path(libs)
          ['"%s"' % @libs.join(File::PATH_SEPARATOR)]
        end

        def quoted_binary(cucumber_bin)
          ['"%s"' % cucumber_bin]
        end

        def use_bundler
          @bundler.nil? ? File.exist?("./Gemfile") && gem_available?("bundler") : @bundler
        end

        def gem_available?(gemname)
          gem_available_new_rubygems?(gemname) || gem_available_old_rubygems?(gemname)
        end

        def gem_available_old_rubygems?(gemname)
          Gem.available?(gemname)
        end

        def gem_available_new_rubygems?(gemname)
          Gem::Specification.respond_to?(:find_all_by_name) && Gem::Specification.find_all_by_name(gemname).any?
        end

        def cmd
          if use_bundler
            [ Cucumber::RUBY_BINARY, '-S', 'bundle', 'exec', 'cucumber', @cucumber_opts,
            @feature_files ].flatten
          else
            [ Cucumber::RUBY_BINARY, '-I', load_path(@libs), quoted_binary(@cucumber_bin),
            @cucumber_opts, @feature_files ].flatten
          end
        end

        def run
          sh(cmd.join(" "))
        end
      end

      class RCovCucumberRunner < ForkedCucumberRunner #:nodoc:

        def initialize(libs, cucumber_bin, cucumber_opts, bundler, feature_files, rcov_opts)
          super(       libs, cucumber_bin, cucumber_opts, bundler, feature_files )
          @rcov_opts = rcov_opts
        end

        def cmd
          if use_bundler
            [Cucumber::RUBY_BINARY, '-S', 'bundle', 'exec', 'rcov', @rcov_opts,
             quoted_binary(@cucumber_bin), '--', @cucumber_opts, @feature_files].flatten
          else
            [Cucumber::RUBY_BINARY, '-I', load_path(@libs), '-S', 'rcov', @rcov_opts,
             quoted_binary(@cucumber_bin), '--', @cucumber_opts, @feature_files].flatten
          end
        end
        
      end

      LIB = File.expand_path(File.dirname(__FILE__) + '/../..') #:nodoc:

      # Directories to add to the Ruby $LOAD_PATH
      attr_accessor :libs

      # Name of the cucumber binary to use for running features. Defaults to Cucumber::BINARY
      attr_accessor :binary
{'fraction_non_alphanumeric': 0.10211659858893428, 'fraction_numerical': 0.0007426661715558856, 'mean_word_length': 2.184864012613323, 'pattern_counts': {'":': 0, '<': 9, '<?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': '7525397', 'n_tokens_mistral': 2630, 'n_tokens_neox': 2538, 'n_words': 595}