Class: RBS::Collection::Sources::Stdlib

Inherits:
Object
  • Object
show all
Includes:
Base, Singleton
Defined in:
lib/rbs/collection/sources/stdlib.rb

Overview

signatures that are bundled in rbs gem under the stdlib/ directory

Constant Summary collapse

REPO =
Repository.default

Instance Method Summary collapse

Methods included from Base

#dependencies_of

Instance Method Details

#has?(name, version) ⇒ Boolean

Returns:

  • (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:) ⇒ Object



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

#manifest_of(name, version) ⇒ Object



29
30
31
32
# File 'lib/rbs/collection/sources/stdlib.rb', line 29

def manifest_of(name, version)
  manifest_path = (lookup(name, version) or raise).join('manifest.yaml')
  YAML.safe_load(manifest_path.read) if manifest_path.exist?
end

#to_lockfileObject



34
35
36
37
38
# File 'lib/rbs/collection/sources/stdlib.rb', line 34

def to_lockfile
  {
    'type' => 'stdlib',
  }
end

#versions(name) ⇒ Object



19
20
21
# File 'lib/rbs/collection/sources/stdlib.rb', line 19

def versions(name)
  REPO.gems[name].versions.keys.map(&:to_s)
end