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?(config_entry) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/rbs/collection/sources/stdlib.rb', line 15

def has?(config_entry)
  lookup(config_entry)
end

#install(dest:, config_entry:, stdout:) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/rbs/collection/sources/stdlib.rb', line 23

def install(dest:, config_entry:, stdout:)
  # Do nothing because stdlib RBS is available by default
  name = config_entry['name']
  version = config_entry['version'] or raise
  from = lookup(config_entry)
  stdout.puts "Using #{name}:#{version} (#{from})"
end

#manifest_of(config_entry) ⇒ Object



31
32
33
34
35
# File 'lib/rbs/collection/sources/stdlib.rb', line 31

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

#to_lockfileObject



37
38
39
40
41
# File 'lib/rbs/collection/sources/stdlib.rb', line 37

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

#versions(config_entry) ⇒ Object



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

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