<commit_before>require 'bundler/setup'
require 'fileutils'
require 'thor'
require 'vim-flavor/version'
require 'yaml'

module Vim
  module Flavor
    module StringExtension
      def to_flavors_path()
        "#{self}/flavors"
      end
    end

    class ::String
      include StringExtension
    end

    class VersionConstraint
      attr_reader :base_version, :operator

      def initialize(s)
        @base_version, @operator = parse(s)
      end

      def to_s()
        "#{@operator} #{@base_version}"
      end

      def ==(other)
        self.base_version == other.base_version &&
          self.operator == other.operator
      end

      def parse(s)
        m = /^\s*(>=|~>)\s+(\S+)$/.match(s)
        if m then
          [Gem::Version.create(m[2]), m[1]]
        else
          raise "Invalid version constraint: #{s.inspect}"
        end
      end

      def compatible?(other_version_or_s)
        v = Gem::Version.create(other_version_or_s)
        if @operator == '~>' then
          self.base_version.bump() > v and v >= self.base_version
        elsif @operator == '>=' then
          v >= self.base_version
        else
          raise NotImplementedError
        end
      end

      def find_the_best_version(versions)
        versions.
          select {|v| compatible?(v)}.
          sort().
          reverse().
          first
      end
    end

    class << self
      @@dot_path = "#{Dir.getwd()}/.vim-flavor"

      def dot_path
        @@dot_path
      end

      def dot_path= path
        @@dot_path = path
      end
    end
<commit_msg>Use ~/.vim-flavor to share fetched data easily<commit_after>require 'bundler/setup'
require 'fileutils'
require 'thor'
require 'vim-flavor/version'
require 'yaml'

module Vim
  module Flavor
    module StringExtension
      def to_flavors_path()
        "#{self}/flavors"
      end
    end

    class ::String
      include StringExtension
    end

    class VersionConstraint
      attr_reader :base_version, :operator

      def initialize(s)
        @base_version, @operator = parse(s)
      end

      def to_s()
        "#{@operator} #{@base_version}"
      end

      def ==(other)
        self.base_version == other.base_version &&
          self.operator == other.operator
      end

      def parse(s)
        m = /^\s*(>=|~>)\s+(\S+)$/.match(s)
        if m then
          [Gem::Version.create(m[2]), m[1]]
        else
          raise "Invalid version constraint: #{s.inspect}"
        end
      end

      def compatible?(other_version_or_s)
        v = Gem::Version.create(other_version_or_s)
        if @operator == '~>' then
          self.base_version.bump() > v and v >= self.base_version
        elsif @operator == '>=' then
          v >= self.base_version
        else
          raise NotImplementedError
        end
      end

      def find_the_best_version(versions)
        versions.
          select {|v| compatible?(v)}.
          sort().
          reverse().
          first
      end
    end

    class << self
      @@dot_path = File.expand_path('~/.vim-flavor')

      def dot_path
        @@dot_path
      end

      def dot_path= path
        @@dot_path = path
      end
    end

{'fraction_non_alphanumeric': 0.11369346733668342, 'fraction_numerical': 0.001256281407035176, 'mean_word_length': 1.823581560283688, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, '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': '1021763', 'n_tokens_mistral': 1003, 'n_tokens_neox': 975, 'n_words': 234}