<commit_before>require 'yaml'
require 'tmpdir'

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'thrust_config'))

@thrust = ThrustConfig.new(Dir.getwd, File.join(Dir.getwd, 'thrust.yml'))

desc 'Trim whitespace'
task :trim do
  @thrust.system_or_exit %Q[git status --short | awk '{if ($1 != "D" && $1 != "R") print $2}' | grep -e '.*\.[cmh]$' | xargs sed -i '' -e 's/	/    /g;s/ *$//g;']
end

desc "Remove any focus from specs"
task :nof do
  @thrust.system_or_exit %Q[ rake focused_specs | xargs -I{} sed -i '' -e 's/fit\(@/it\(@/g;' -e 's/fdescribe\(@/describe\(@/g;' -e 's/fcontext\(@/context\(@/g;' "{}" ]
end

desc "Print out names of files containing focused specs"
task :focused_specs do
  @thrust.system_or_exit %Q[ grep -l -r -e "\\(fit\\|fdescribe\\|fcontext\\)" #{ @thrust.config['spec_targets'].values.map {|h| h['target']}.join(' ') } | grep -v 'Frameworks' ; exit 0 ]
end

desc 'Clean all targets'
task :clean do
  @thrust.xcodeclean('AdHoc', 'iphoneos')
  @thrust.xcodeclean('Debug', 'iphoneos')
  @thrust.xcodeclean('Release', 'iphoneos')
end

@thrust.config['spec_targets'].each do |task_name, info|
  desc "Run #{info['name']}"
  task task_name do
    build_configuration = info['configuration']
    target = info['target']
    sdk = info['sdk']

    @thrust.xcodeclean(build_configuration, 'iphonesimulator')
    @thrust.xcodebuild(build_configuration, 'iphonesimulator', target)
    @thrust.run_cedar(build_configuration, target, sdk, info['device'])
  end
end
<commit_msg>Match the words 'fit' etc more strictly in 'focused_specs' task<commit_after>require 'yaml'
require 'tmpdir'

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'thrust_config'))

@thrust = ThrustConfig.new(Dir.getwd, File.join(Dir.getwd, 'thrust.yml'))

desc 'Trim whitespace'
task :trim do
  @thrust.system_or_exit %Q[git status --short | awk '{if ($1 != "D" && $1 != "R") print $2}' | grep -e '.*\.[cmh]$' | xargs sed -i '' -e 's/	/    /g;s/ *$//g;']
end

desc "Remove any focus from specs"
task :nof do
  substitutions = focused_methods.map do |method|
    unfocused_method = method.sub(/^f/, '')
    "-e 's/#{method}/#{unfocused_method}/g;'"
  end

  @thrust.system_or_exit %Q[ rake focused_specs | xargs -I filename sed -i '' #{substitutions.join(' ')} "filename" ]
end

desc "Print out names of files containing focused specs"
task :focused_specs do
  pattern = focused_methods.join("\\|")
  directories = @thrust.config['spec_targets'].values.map {|h| h['target']}.join(' ')
  @thrust.system_or_exit %Q[ grep -l -r -e "\\(#{pattern}\\)" #{directories} | grep -v 'Frameworks' ; exit 0 ]
end

desc 'Clean all targets'
task :clean do
  @thrust.xcodeclean('AdHoc', 'iphoneos')
  @thrust.xcodeclean('Debug', 'iphoneos')
  @thrust.xcodeclean('Release', 'iphoneos')
end

@thrust.config['spec_targets'].each do |task_name, info|
  desc "Run #{info['name']}"
  task task_name do
    build_configuration = info['configuration']
    target = info['target']
    sdk = info['sdk']

    @thrust.xcodeclean(build_configuration, 'iphonesimulator')
    @thrust.xcodebuild(build_configuration, 'iphonesimulator', target)
    @thrust.run_cedar(build_configuration, target, sdk, info['device'])
  end
end

def focused_methods
  ["fit", "fcontext", "fdescribe"].map { |method| "#{method}(@" }
end

{'fraction_non_alphanumeric': 0.1888788153520701, 'fraction_numerical': 0.0024176488365064974, 'mean_word_length': 4.4801324503311255, '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': '2184190', 'n_tokens_mistral': 1259, 'n_tokens_neox': 1220, 'n_words': 293}