<commit_before>desc "Updates the gemspec"
task :gemspec do
  # TODO
end<commit_msg>Implemented task for in-place gemspec updates.<commit_after>desc "Updates the gemspec file"
task :gemspec do
  if gemspec_file = Dir.glob('*.gemspec').first
    load gemspec_file
    gemspec = File.read(gemspec_file)

    puts "Updating gemspec version..."
    version = File.read('VERSION').chomp
    gemspec.gsub!(/(gem\.version\s*=\s*')[^']+(')/, "\\1#{version}\\2")

    puts "Updating gemspec date..."
    date = File.mtime('VERSION').strftime('%Y-%m-%d')
    gemspec.gsub!(/(gem\.date\s*=\s*')[^']+(')/, "\\1#{date}\\2")

    puts "Updating gemspec file list..."
    files = FileList['[A-Z]*', '[A-Z]*.*', 'bin/*', 'doc/**/*', 'lib/**/*.rb', 'test/**/*', 'spec/**/*']
    gemspec.gsub!(/(gem\.files\s*=\s*%w\()[^\)]*(\))/, "\\1#{files.to_a.sort.join(' ')}\\2")

    puts "Updating gemspec test file list..."
    files = FileList['test/**/*', 'spec/**/*']
    gemspec.gsub!(/(gem\.test_files\s*=\s*%w\()[^\)]*(\))/, "\\1#{files.to_a.sort.join(' ')}\\2")

    open(gemspec_file, "wb") { |f| f.puts gemspec }
  end
end
{'fraction_non_alphanumeric': 0.28351449275362317, 'fraction_numerical': 0.007246376811594203, 'mean_word_length': 3.299610894941634, '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': '6054954', 'n_tokens_mistral': 440, 'n_tokens_neox': 430, 'n_words': 79}