<commit_before>#!/usr/bin/env ruby

require "pathname"
require "fileutils"

rbenv_versions          = Pathname("#{ENV["HOME"]}/.rbenv/versions")
homebrew_ruby_versions  = Pathname.glob("/usr/local/Cellar/ruby")
homebrew_ruby_versions += Pathname.glob("/usr/local/Cellar/ruby@*")

homebrew_ruby_versions.flat_map(&:children)
                      .each {|v| FileUtils.ln_sf v, rbenv_versions }

rbenv_versions.children
              .select(&:symlink?)
              .reject(&:exist?)
              .each {|v| FileUtils.rm_f v }<commit_msg>rbenv-sync-homebrew-rubies: handle Homebrew formulae revisions.<commit_after>#!/usr/bin/env ruby

require "pathname"
require "fileutils"

@rbenv_versions         = Pathname("#{ENV["HOME"]}/.rbenv/versions")
homebrew_ruby_versions  = Pathname.glob("/usr/local/Cellar/ruby")
homebrew_ruby_versions += Pathname.glob("/usr/local/Cellar/ruby@*")

def link_rbenv_version_without_revision(version)
  basename_without_revision = version.basename
                                     .to_s
                                     .gsub(/_\d+$/, "")
  FileUtils.ln_sf version, @rbenv_versions / basename_without_revision
end

def gem_like_version(version)
  Gem::Version.new(version.basename
                          .to_s
                          .tr("_", "."))
end

homebrew_ruby_versions.flat_map(&:children)
                      .sort_by(&method(:gem_like_version))
                      .each(&method(:link_rbenv_version_without_revision))

@rbenv_versions.children
               .select(&:symlink?)
               .reject(&:exist?)
               .each { |path| FileUtils.rm_f path }
{'fraction_non_alphanumeric': 0.13218035824583077, 'fraction_numerical': 0.0, 'mean_word_length': 2.5217391304347827, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4096217', 'n_tokens_mistral': 537, 'n_tokens_neox': 513, 'n_words': 68}