Class: RBS::Repository
Relationships & Source Files | |
Namespace Children | |
Classes:
| |
Inherits: | Object |
Defined in: | lib/rbs/repository.rb |
Constant Summary
-
DEFAULT_STDLIB_ROOT =
# File 'lib/rbs/repository.rb', line 5Pathname(_ = __dir__) + "../../stdlib"
-
VersionPath =
# File 'lib/rbs/repository.rb', line 69_ = Struct.new(:gem, :version, :path, keyword_init: true)
Class Method Summary
Instance Attribute Summary
Instance Method Summary
Constructor Details
.new(no_stdlib: false) ⇒ Repository
# File 'lib/rbs/repository.rb', line 74
def initialize(no_stdlib: false) @dirs = [] @gems = {} unless no_stdlib add(DEFAULT_STDLIB_ROOT) end end
Class Method Details
.default
[ GitHub ]# File 'lib/rbs/repository.rb', line 83
def self.default new() end
.find_best_version(version, candidates)
[ GitHub ]# File '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
Instance Attribute Details
#dirs (readonly)
[ GitHub ]# File 'lib/rbs/repository.rb', line 71
attr_reader :dirs
#gems (readonly)
[ GitHub ]# File 'lib/rbs/repository.rb', line 72
attr_reader :gems
Instance Method Details
#add(dir)
[ GitHub ]#lookup(gem, version)
[ GitHub ]# File 'lib/rbs/repository.rb', line 108
def lookup(gem, version) _, set = lookup_path(gem, version) set&.path end
#lookup_path(gem, version)
[ GitHub ]# File '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