Class: RBS::Collection::Sources::Rubygems

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

Overview

sig/ directory

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base

#dependencies_of

Class Method Details

.instanceinstance

polyfill of singleton module

Returns:



196
# File 'sig/collection/sources.rbs', line 196

def self.instance: () -> instance

Instance Method Details

#gem_sig_path(name, version) ⇒ [Gem::Specification, Pathname]?

Parameters:

  • name (String)
  • version (String, nil)

Returns:



42
43
44
# File 'lib/rbs/collection/sources/rubygems.rb', line 42

private def gem_sig_path(name, version)
  RBS::EnvironmentLoader.gem_sig_path(name, version)
end

#has?(name, version) ⇒ Boolean

Parameters:

  • name (String)
  • version (String, nil)

Returns:

  • (Boolean)


13
14
15
# File 'lib/rbs/collection/sources/rubygems.rb', line 13

def has?(name, version)
  gem_sig_path(name, version)
end

#install(dest:, name:, version:, stdout:) ⇒ void

This method returns an undefined value.

Parameters:

  • dest: (Pathname)
  • name: (String)
  • version: (String)
  • stdout: (CLI::_IO)


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

def install(dest:, name:, version:, stdout:)
  # Do nothing because stdlib RBS is available by default
  _, from = gem_sig_path(name, version)
  stdout.puts "Using #{name}:#{version} (#{from})"
end

#manifest_of(name, version) ⇒ manifest_entry?

Parameters:

  • name (String)
  • version (String)

Returns:

  • (manifest_entry, nil)


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

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

#to_lockfilesource_entry

Returns:

  • (source_entry)


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

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

#versions(name) ⇒ Array[String]

Parameters:

  • name (String)

Returns:

  • (Array[String])


17
18
19
20
21
# File 'lib/rbs/collection/sources/rubygems.rb', line 17

def versions(name)
  spec, _ = gem_sig_path(name, nil)
  spec or raise
  [spec.version.to_s]
end