<commit_before>require 'skine'

task :expire => :environment do
  revision = ENV['REVISION'] || ENV['revision'] || 'master'

  repo   = Grit::Repo.new(App.repo)
  commit = repo.commits(revision, 1).first
  next unless commit

  cache = Skine::Cache.new
  repo.commit_diff(commit.id).each do |diff|
    cache.expire_file(diff.a_path)
    # a_path will differ from b_path in case of a move
    cache.expire_file(diff.b_path) if diff.a_path != diff.b_path
  end
  cache.put_expired_files
end

task :expire_all => :environment do
  cache = Skine::Cache.new
  repo  = Grit::Repo.new(App.repo)
  cache.expire_tree(repo.tree)
  cache.put_expired_files
end

<commit_msg>* adding Rake task descriptions<commit_after>require 'skine'

desc 'Expire cache for all files included in a commit, use revision= (defaults to HEAD)'
task :expire => :environment do
  revision = ENV['REVISION'] || ENV['revision'] || 'master'

  repo   = Grit::Repo.new(App.repo)
  commit = repo.commits(revision, 1).first
  puts "count = #{repo.commits(revision).count}"
  next unless commit

  cache = Skine::Cache.new
  repo.commit_diff(commit.id).each do |diff|
    cache.expire_file(diff.a_path)
    # a_path will differ from b_path in case of a move
    cache.expire_file(diff.b_path) if diff.a_path != diff.b_path
  end
  cache.put_expired_files
end

desc 'Expire cache for all files in the repository'
task :expire_all => :environment do
  cache = Skine::Cache.new
  repo  = Grit::Repo.new(App.repo)
  cache.expire_tree(repo.tree)
  cache.put_expired_files
end


{'fraction_non_alphanumeric': 0.11945169712793734, 'fraction_numerical': 0.0013054830287206266, 'mean_word_length': 4.196610169491525, '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': '6303261', 'n_tokens_mistral': 559, 'n_tokens_neox': 557, 'n_words': 135}