class RBS::Repository::GemRBS

Attributes

name[R]
paths[R]

Public Class Methods

new(name:) click to toggle source
# File rbs-2.8.2/lib/rbs/repository.rb, line 11
def initialize(name:)
  @name = name
  @paths = []
  @versions = nil
end

Public Instance Methods

empty?() click to toggle source
# File rbs-2.8.2/lib/rbs/repository.rb, line 64
def empty?
  versions.empty?
end
find_best_version(version) click to toggle source
# File rbs-2.8.2/lib/rbs/repository.rb, line 59
def find_best_version(version)
  best_version = Repository.find_best_version(version, version_names)
  versions[best_version]
end
latest_version() click to toggle source
# File rbs-2.8.2/lib/rbs/repository.rb, line 54
def latest_version
  latest = version_names.last or raise
  versions[latest] or raise
end
load!() click to toggle source
# File rbs-2.8.2/lib/rbs/repository.rb, line 22
def load!
  @versions = {}
  versions = @versions or raise

  paths.each do |gem_path|
    gem_path.each_child(false) do |child|
      next unless Gem::Version.correct?(child.to_s)

      if version = Gem::Version.create(child.to_s)
        unless version.prerelease?
          path = gem_path + child

          if prev = versions[version]
            RBS.logger.info { "Overwriting gem RBS in repository: gem=#{name}, prev_path=#{prev.path}, new_path=#{path}" }
          end

          versions[version] = VersionPath.new(gem: self, version: version, path: path)
        end
      end
    end
  end
end
oldest_version() click to toggle source
# File rbs-2.8.2/lib/rbs/repository.rb, line 49
def oldest_version
  oldest = version_names.first or raise
  versions[oldest] or raise
end
version_names() click to toggle source
# File rbs-2.8.2/lib/rbs/repository.rb, line 45
def version_names
  versions.keys.sort_by(&:version)
end
versions() click to toggle source
# File rbs-2.8.2/lib/rbs/repository.rb, line 17
def versions
  load! unless @versions
  @versions or raise
end