<commit_before>require 'capybara/poltergeist'
require "poltergeist/suppressor/version"
require "poltergeist/suppressor/redirect_stderr"

module Capybara::Poltergeist
  class Suppressor
    DEFAULT_PATTERNS = [
      /QFont::setPixelSize: Pixel size <= 0/,
      /CoreText performance note:/,
      /WARNING: Method userSpaceScaleFactor/
    ]

    def initialize(args = {})
      @patterns = args[:patterns] || DEFAULT_PATTERNS
    end

    def write(message)
      if ignore_message?(message)
        0
      else
        puts(message)
        1
      end
    end

    private
    def ignore_message?(message)
      @patterns.any? {|regexp| message =~ regexp }
    end
  end
end<commit_msg>Add register_driver<commit_after>require 'capybara/poltergeist'
require "poltergeist/suppressor/version"
require "poltergeist/suppressor/redirect_stderr"

module Capybara::Poltergeist
  class Suppressor
    DEFAULT_PATTERNS = [
      /QFont::setPixelSize: Pixel size <= 0/,
      /CoreText performance note:/,
      /WARNING: Method userSpaceScaleFactor/
    ]

    def initialize(args = {})
      @patterns = args[:patterns] || DEFAULT_PATTERNS
    end

    def write(message)
      if ignore_message?(message)
        0
      else
        puts(message)
        1
      end
    end

    private
    def ignore_message?(message)
      @patterns.any? {|regexp| message =~ regexp }
    end
  end
end

Capybara.register_driver :poltergeist do |app|
  Capybara::Poltergeist::Driver.new(app,
    phantomjs_logger: Capybara::Poltergeist::Suppressor.new
  )
end
{'fraction_non_alphanumeric': 0.09579288025889968, 'fraction_numerical': 0.003883495145631068, 'mean_word_length': 2.9539641943734014, 'pattern_counts': {'":': 0, '<': 5, '<?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': '790919', 'n_tokens_mistral': 514, 'n_tokens_neox': 499, 'n_words': 102}