<commit_before># This is based on Florian Weber's TDDMate
require 'rubygems'

rspec_rails_plugin = File.join(ENV['TM_PROJECT_DIRECTORY'],'vendor','plugins','rspec','lib')
if File.directory?(rspec_rails_plugin)
  $LOAD_PATH.unshift(rspec_rails_plugin)
elsif ENV['TM_RSPEC_HOME']
  rspec_lib = File.join(ENV['TM_RSPEC_HOME'], 'lib')
  $LOAD_PATH.unshift(rspec_lib)
  raise "TM_RSPEC_HOME points to a bad location: #{ENV['TM_RSPEC_HOME']}" unless File.directory?(rspec_lib)
end

require 'spec'
require File.dirname(__FILE__) + '/text_mate_formatter'

class SpecMate
  def run_files(stdout, options={})
    files = ENV['TM_SELECTED_FILES'].split(" ").map{|p| p[1..-2]}
    options.merge!({:files => files})
    run(stdout, options)
  end
  
  def run_file(stdout, options={})
    options.merge!({:files => [single_file]})
    run(stdout, options)<commit_msg>a little cleaner spec_mate (doesn't append to load path unless it finds the right directory)<commit_after># This is based on Florian Weber's TDDMate
require 'rubygems'

rspec_rails_plugin = File.join(ENV['TM_PROJECT_DIRECTORY'],'vendor','plugins','rspec','lib')
if File.directory?(rspec_rails_plugin)
  $LOAD_PATH.unshift(rspec_rails_plugin)
elsif ENV['TM_RSPEC_HOME']
  rspec_lib = File.join(ENV['TM_RSPEC_HOME'], 'lib')
  raise "TM_RSPEC_HOME points to a bad location: #{ENV['TM_RSPEC_HOME']}" unless File.directory?(rspec_lib)
  $LOAD_PATH.unshift(rspec_lib)
end

require 'spec'
require File.dirname(__FILE__) + '/text_mate_formatter'

class SpecMate
  def run_files(stdout, options={})
    files = ENV['TM_SELECTED_FILES'].split(" ").map{|p| p[1..-2]}
    options.merge!({:files => files})
    run(stdout, options)
  end
  
  def run_file(stdout, options={})
    options.merge!({:files => [single_file]})
    run(stdout, options)
{'fraction_non_alphanumeric': 0.1527700055959709, 'fraction_numerical': 0.002238388360380526, 'mean_word_length': 6.123505976095617, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6873641', 'n_tokens_mistral': 669, 'n_tokens_neox': 641, 'n_words': 129}