class RBS::Repository
Constants
- DEFAULT_STDLIB_ROOT
- VersionPath
Attributes
dirs[R]
gems[R]
Public Class Methods
default()
click to toggle source
# File rbs-3.2.2/lib/rbs/repository.rb, line 83 def self.default new() end
find_best_version(version, candidates)
click to toggle source
# File rbs-3.2.2/lib/rbs/repository.rb, line 87 def self.find_best_version(version, candidates) candidates = candidates.sort return candidates.last || raise unless version if v = candidates.reverse.bsearch {|v| v <= version ? true : false } v else candidates.first or raise end end
new(no_stdlib: false)
click to toggle source
# File rbs-3.2.2/lib/rbs/repository.rb, line 74 def initialize(no_stdlib: false) @dirs = [] @gems = {} unless no_stdlib add(DEFAULT_STDLIB_ROOT) end end
Public Instance Methods
add(dir)
click to toggle source
# File rbs-3.2.2/lib/rbs/repository.rb, line 98 def add(dir) dirs << dir dir.each_child(false) do |child| gem_name = child.to_s gem_rbs = (gems[gem_name] ||= GemRBS.new(name: gem_name)) gem_rbs.paths << dir + child end end
lookup(gem, version)
click to toggle source
# File rbs-3.2.2/lib/rbs/repository.rb, line 108 def lookup(gem, version) _, set = lookup_path(gem, version) set&.path end
lookup_path(gem, version)
click to toggle source
# File rbs-3.2.2/lib/rbs/repository.rb, line 113 def lookup_path(gem, version) if gem_rbs = gems[gem] unless gem_rbs.empty? set = if version and v = Gem::Version.create(version)&.release gem_rbs.find_best_version(v) else gem_rbs.latest_version end [gem_rbs, set] end end end