<commit_before>module VersionManager
  class VersionStorage
    class WrongLatestVersionError < StandardError
      attr_reader :version
      def initialize(version)
        @version = version
      end
    end

    def initialize(vcs, storage_options)
      @filename = storage_options[:filename]
      @filepath = storage_options[:filepath]
      @vcs = vcs
    end

    def store(version)
      File.open(full_path, 'w') do |file|
        file << version
      end
      full_path
    end

    def latest_version
      versions = vcs.remote_branch_names.map do |name|
        name = name.split('/').last
        ReleaseVersion.new(name) if name.include?('release-') && ReleaseVersion.valid?(name)
      end
      version = select_appropriate_version(versions)
      file_content = vcs.show_file(version.branch, relative_path) if version
      version = ReleaseVersion.new(file_content) if file_content && ReleaseVersion.valid?(file_content)
      version
    end

    private

    attr_reader :filename, :filepath, :vcs

    def relative_path
      Pathname.new(full_path).relative_path_from(Pathname.new(ROOT_DIR)).to_s
    end

    def full_path
      File.expand_path(File.join(filepath, filename))
    end<commit_msg>Added current_version method to VersionStorage<commit_after>module VersionManager
  class VersionStorage
    class WrongLatestVersionError < StandardError
      attr_reader :version
      def initialize(version)
        @version = version
      end
    end

    def initialize(vcs, storage_options)
      @filename = storage_options[:filename]
      @filepath = storage_options[:filepath]
      @vcs = vcs
    end

    def store(version)
      File.open(full_path, 'w') do |file|
        file << version
      end
      full_path
    end

    def latest_version
      versions = vcs.remote_branch_names.map(&method(:version_from_branch_name))
      version = select_appropriate_version(versions) # It's a partial release version (only major and minor parts)
      version_from_file(version)
    end

    def current_version
      version = version_from_branch_name(vcs.current_branch)
      raise ArgumentError, 'Can not detect a current version' unless version
      version
    end

    private

    attr_reader :filename, :filepath, :vcs

    def version_from_file(version)
      return unless version
      file_content = vcs.show_file(version.branch, relative_path) if version
      ReleaseVersion.new(file_content) if file_content && ReleaseVersion.valid?(file_content)
    end

    def version_from_branch_name(branch_name)
      return unless branch_name
      branch_name = branch_name.split('/').last
      ReleaseVersion.new(branch_name) if branch_name.include?('release-') && ReleaseVersion.valid?(branch_name)
    end

    def relative_path
      Pathname.new(full_path).relative_path_from(Pathname.new(ROOT_DIR)).to_s
    end

    def full_path
      File.expand_path(File.join(filepath, filename))
    end
{'fraction_non_alphanumeric': 0.07877758913412564, 'fraction_numerical': 0.0, 'mean_word_length': 3.184659090909091, 'pattern_counts': {'":': 0, '<': 9, '<?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': '4317599', 'n_tokens_mistral': 860, 'n_tokens_neox': 841, 'n_words': 191}