<commit_before># -*- coding: utf-8 -*-
require 'rspec'

class Object
  
  # Determines if a configuration file (helper.rb) is true or false. The user 
  # might enter “true”, 1 or true.
  def truthy?
    self && !['false', 'no', 'n', '0', 0].include?(self)
  end
end


module OperaWatir::Waiter
  extend self
  
  def self.default_attr_accessor(attr, default)
    define_method attr.to_sym do
      ENV["OPERA_#{attr.to_s.upcase}"] || instance_variable_get("@#{attr}") || default
    end
    attr_writer attr.to_sym
  end
  
  default_attr_accessor :path,          nil
  default_attr_accessor :args,          ''
  default_attr_accessor :files,         "file://#{File.expand_path('../interactive', Dir.pwd)}"
  default_attr_accessor :inspectr,      false
  default_attr_accessor :terminal_size, [80,24]
  
  def browser
    @browser ||= OperaWatir::Browser.new(path, *args.split(' '))
  end
  
  def helper_file
    File.expand_path(File.join(Dir.pwd, 'helper.rb'))
  end
  
  def configure_rspec
    RSpec.configure do |config|
      config.include SpecHelpers

      config.after(:suite) do
        OperaWatir::Waiter.browser.quit
      end
    end
  end
  
  def inspectr_path
    File.join File.expand_path('../../../utils', __FILE__),
              (RUBY_PLATFORM =~ /mswin|msys|mingw32/ ? 'inspectr.exe' : 'inspectr')
  end
  
  def spawn_inspectr
    abort 'operawatir: inspectr is not supported on your operating system' unless Config::CONFIG['os_host'] =~ /linux/
    abort 'operawatir: Unable to locate inspectr executable' unless File.exist?(inspectr_path)
    
    Thread.new do
      puts "Attaching inspectr to PID ##{browser.pid}"
      exec inspectr, browser.pid.to_s
    end
  end

  def run!
    require helper_file if File.exist?(helper_file)
    spawn_inspectr if inspectr.truthy?
    configure_rspec
  end

  
  # Helpers included for each Spec
  
  module SpecHelpers
    def browser
      OperaWatir::Waiter.browser
    end
    
    # TODO Not sure of this
    def files(new_path=nil)
      if new_path
        OperaWatir::Waiter.files = new_path
      else
        OperaWatir::Waiter.files
      end
    end
  end

end
<commit_msg>RUBY_PLATFORM does not work on JRuby platform<commit_after># -*- coding: utf-8 -*-
require 'rspec'

class Object
  
  # Determines if a configuration file (helper.rb) is true or false. The user 
  # might enter “true”, 1 or true.
  def truthy?
    self && !['false', 'no', 'n', '0', 0].include?(self)
  end
end


module OperaWatir::Waiter
  extend self
  
  def self.default_attr_accessor(attr, default)
    define_method attr.to_sym do
      ENV["OPERA_#{attr.to_s.upcase}"] || instance_variable_get("@#{attr}") || default
    end
    attr_writer attr.to_sym
  end
  
  default_attr_accessor :path,          nil
  default_attr_accessor :args,          ''
  default_attr_accessor :files,         "file://#{File.expand_path('../interactive', Dir.pwd)}"
  default_attr_accessor :inspectr,      false
  default_attr_accessor :terminal_size, [80,24]
  
  def browser
    @browser ||= OperaWatir::Browser.new(path, *args.split(' '))
  end
  
  def helper_file
    File.expand_path(File.join(Dir.pwd, 'helper.rb'))
  end
  
  def configure_rspec
    RSpec.configure do |config|
      config.include SpecHelpers

      config.after(:suite) do
        OperaWatir::Waiter.browser.quit
      end
    end
  end
  
  def inspectr_path
    File.join File.expand_path('../../../utils', __FILE__),
              (Config::CONFIG['os_host'] =~ /mswin|msys|mingw32/ ? 'inspectr.exe' : 'inspectr')
  end
  
  def spawn_inspectr
    abort 'operawatir: inspectr is not supported on your operating system' unless Config::CONFIG['os_host'] =~ /linux/
    abort 'operawatir: Unable to locate inspectr executable' unless File.exist?(inspectr_path)
    
    Thread.new do
      puts "Attaching inspectr to PID ##{browser.pid}"
      exec inspectr, browser.pid.to_s
    end
  end

  def run!
    require helper_file if File.exist?(helper_file)
    spawn_inspectr if inspectr.truthy?
    configure_rspec
  end

  
  # Helpers included for each Spec
  
  module SpecHelpers
    def browser
      OperaWatir::Waiter.browser
    end
    
    # TODO Not sure of this
    def files(new_path=nil)
      if new_path
        OperaWatir::Waiter.files = new_path
      else
        OperaWatir::Waiter.files
      end
    end
  end

end

{'fraction_non_alphanumeric': 0.10799632352941177, 'fraction_numerical': 0.004595588235294118, 'mean_word_length': 2.815074496056091, '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': '1969745', 'n_tokens_mistral': 1515, 'n_tokens_neox': 1500, 'n_words': 360}