Class: Solargraph::RbsCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/solargraph/rbs_collection.rb

Overview

The RBS collection declared by a project's rbs_collection.lock.yaml.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lockfile) ⇒ RbsCollection

Returns a new instance of RbsCollection.



9
10
11
# File 'lib/solargraph/rbs_collection.rb', line 9

def initialize lockfile
  @lockfile = File.expand_path(lockfile) if lockfile
end

Instance Attribute Details

#lockfile ⇒ Object (readonly)

Returns the value of attribute lockfile.



7
8
9
# File 'lib/solargraph/rbs_collection.rb', line 7

def lockfile
  @lockfile
end

Instance Method Details

#gem_keys ⇒ Object



21
22
23
# File 'lib/solargraph/rbs_collection.rb', line 21

def gem_keys
  gem_path_map.keys
end

#load(metagem) ⇒ Array<Pin::Base>

Parameters:

Returns:



15
16
17
18
19
# File 'lib/solargraph/rbs_collection.rb', line 15

def load metagem
  key = best_key(metagem)
  return [] unless key
  mem_cache[key] ||= RbsMap::Path.pins(gem_path_map[key])
end

#stdlib_names ⇒ Array<String>

The names of the stdlib signature sets declared by the collection.

rbs collection install resolves these to the signatures which ship with the rbs gem instead of copying them into the collection directory, so they can never be located by a gem name/version lookup.

Returns:

  • (Array<String>)


32
33
34
35
# File 'lib/solargraph/rbs_collection.rb', line 32

def stdlib_names
  @stdlib_names ||= raw_data[:gems].select { |gem| gem.dig(:source, :type).to_s == 'stdlib' }
                                   .map { |gem| gem[:name].to_s }.uniq
end