<commit_before>module QUnited
  class Runner

    # The drivers in order of which to use first when not otherwise specified
    DRIVERS_PRIORITY = [:PhantomJs, :Rhino].freeze

    attr_accessor :js_source_files, :js_test_files, :options

    def initialize(js_source_files, js_test_files, options={})
      @js_source_files, @js_test_files, @options = js_source_files, js_test_files, options
    end

    def run
      driver_class = resolve_driver_class
      driver = driver_class.new(js_source_files, js_test_files)

      puts "\n# Running JavaScript tests with #{driver.name}:\n\n"

      results = driver.run
      puts results
      results.to_i
    end

    def resolve_driver_class
      if options[:driver]
        begin
          driver_class = get_driver(options[:driver])
        rescue NameError
          raise UsageError, "#{options[:driver].to_s} does not exist"
        end

        if !driver_class
          raise UsageError, "#{driver_class} driver not found"
        elsif !driver_class.available?
          raise UsageError, "#{driver_class} driver specified, but not available"
        end
        driver_class
      end

      driver_class ||= best_available_driver
      raise(UsageError, 'No driver available') unless driver_class
      driver_class
    end

    def get_driver(klass)
      if ::QUnited::Driver.constants.reject { |d| d == :Base }.include?(klass)
        ::QUnited::Driver.const_get(klass)
      end
    end
<commit_msg>Additional fix for 1.8<commit_after>module QUnited
  class Runner

    # The drivers in order of which to use first when not otherwise specified
    DRIVERS_PRIORITY = [:PhantomJs, :Rhino].freeze

    attr_accessor :js_source_files, :js_test_files, :options

    def initialize(js_source_files, js_test_files, options={})
      @js_source_files, @js_test_files, @options = js_source_files, js_test_files, options
    end

    def run
      driver_class = resolve_driver_class
      driver = driver_class.new(js_source_files, js_test_files)

      puts "\n# Running JavaScript tests with #{driver.name}:\n\n"

      results = driver.run
      puts results
      results.to_i
    end

    def resolve_driver_class
      if options[:driver]
        begin
          driver_class = get_driver(options[:driver])
        rescue NameError
          raise UsageError, "#{options[:driver].to_s} does not exist"
        end

        if !driver_class
          raise UsageError, "#{driver_class} driver not found"
        elsif !driver_class.available?
          raise UsageError, "#{driver_class} driver specified, but not available"
        end
        driver_class
      end

      driver_class ||= best_available_driver
      raise(UsageError, 'No driver available') unless driver_class
      driver_class
    end

    def get_driver(klass)
      if ::QUnited::Driver.constants.reject { |d| d == :Base }.include?(klass.to_s)
        ::QUnited::Driver.const_get(klass.to_s)
      end
    end

{'fraction_non_alphanumeric': 0.0831353919239905, 'fraction_numerical': 0.0006786562606040041, 'mean_word_length': 2.833550065019506, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6679599', 'n_tokens_mistral': 904, 'n_tokens_neox': 879, 'n_words': 229}