Class: RBS::Collection::Sources::Stdlib
- Inherits:
-
Object
- Object
- RBS::Collection::Sources::Stdlib
- Includes:
- Base, Singleton
- Defined in:
- lib/rbs/collection/sources/stdlib.rb,
sig/collection/sources.rbs
Overview
signatures that are bundled in rbs gem under the stdlib/ directory
Constant Summary collapse
- REPO =
Repository.default
Class Method Summary collapse
-
.instance ⇒ instance
polyfill of singleton module.
Instance Method Summary collapse
- #has?(name, version) ⇒ Boolean
- #install(dest:, name:, version:, stdout:) ⇒ void
- #lookup(name, version) ⇒ Pathname?
- #manifest_of(name, version) ⇒ manifest_entry?
- #to_lockfile ⇒ source_entry
- #versions(name) ⇒ Array[String]
Methods included from Base
Class Method Details
.instance ⇒ instance
polyfill of singleton module
170 |
# File 'sig/collection/sources.rbs', line 170
def self.instance: () -> instance
|
Instance Method Details
#has?(name, version) ⇒ Boolean
15 16 17 |
# File 'lib/rbs/collection/sources/stdlib.rb', line 15 def has?(name, version) lookup(name, version) end |
#install(dest:, name:, version:, stdout:) ⇒ void
This method returns an undefined value.
23 24 25 26 27 |
# File 'lib/rbs/collection/sources/stdlib.rb', line 23 def install(dest:, name:, version:, stdout:) # Do nothing because stdlib RBS is available by default from = lookup(name, version) stdout.puts "Using #{name}:#{version} (#{from})" end |
#lookup(name, version) ⇒ Pathname?
44 45 46 |
# File 'lib/rbs/collection/sources/stdlib.rb', line 44 private def lookup(name, version) REPO.lookup(name, version) end |
#manifest_of(name, version) ⇒ manifest_entry?
29 30 31 32 33 34 35 36 |
# File 'lib/rbs/collection/sources/stdlib.rb', line 29 def manifest_of(name, version) unless path = lookup(name, version) RBS.logger.warn "`#{name}` is specified in rbs_collection.lock.yaml. But it is not found in #{REPO.dirs.join(",")}" return end manifest_path = path.join('manifest.yaml') YAML.safe_load(manifest_path.read) if manifest_path.exist? end |
#to_lockfile ⇒ source_entry
38 39 40 41 42 |
# File 'lib/rbs/collection/sources/stdlib.rb', line 38 def to_lockfile { 'type' => 'stdlib', } end |
#versions(name) ⇒ Array[String]
19 20 21 |
# File 'lib/rbs/collection/sources/stdlib.rb', line 19 def versions(name) REPO.gems[name].versions.keys.map(&:to_s) end |