Class: Solargraph::RbsMap::StdlibMap
- Inherits:
-
Solargraph::RbsMap
- Object
- Solargraph::RbsMap
- Solargraph::RbsMap::StdlibMap
- Includes:
- Logging
- Defined in:
- lib/solargraph/rbs_map/stdlib_map.rb
Overview
Ruby stdlib pins
Constant Summary
Constants included from Logging
Logging::DEFAULT_LOG_LEVEL, Logging::LOG_LEVELS
Constants inherited from Solargraph::RbsMap
CACHE_KEY_GEM_EXPORT, CACHE_KEY_LOCAL, CACHE_KEY_STDLIB, CACHE_KEY_UNRESOLVED
Instance Attribute Summary
Attributes inherited from Solargraph::RbsMap
#library, #rbs_collection_config_path, #rbs_collection_paths
Class Method Summary collapse
- .load(library) ⇒ StdlibMap
- .source ⇒ RBS::Collection::Sources::Stdlib
- .stdlib_dependencies(name, version = nil) ⇒ Array<Hash{String => String}>?
Instance Method Summary collapse
-
#initialize(library, rebuild: false, out: $stderr) ⇒ StdlibMap
constructor
A new instance of StdlibMap.
- #resolve_dependencies? ⇒ Boolean
Methods included from Logging
Methods inherited from Solargraph::RbsMap
#cache_key, from_gemspec, #loader, #path_pin, #path_pins, #pins, rbs_source_desc, #repository, #resolved?
Constructor Details
#initialize(library, rebuild: false, out: $stderr) ⇒ StdlibMap
Returns a new instance of StdlibMap.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/solargraph/rbs_map/stdlib_map.rb', line 19 def initialize library, rebuild: false, out: $stderr cached_pins = PinCache.deserialize_stdlib_require library if cached_pins && !rebuild @pins = cached_pins @resolved = true @loaded = true logger.debug { "Deserialized #{cached_pins.length} cached pins for stdlib require #{library.inspect}" } elsif self.class.source.has? library, nil super(library, out: out) unless resolved? @pins = [] logger.debug { "StdlibMap could not resolve #{library.inspect}" } return end generated_pins = pins logger.debug { "Found #{generated_pins.length} pins for stdlib library #{library}" } PinCache.serialize_stdlib_require library, generated_pins end end |
Class Method Details
.load(library) ⇒ StdlibMap
66 67 68 |
# File 'lib/solargraph/rbs_map/stdlib_map.rb', line 66 def self.load library @stdlib_maps_hash[library] ||= StdlibMap.new(library) end |
.source ⇒ RBS::Collection::Sources::Stdlib
40 41 42 |
# File 'lib/solargraph/rbs_map/stdlib_map.rb', line 40 def self.source @source ||= RBS::Collection::Sources::Stdlib.instance end |
.stdlib_dependencies(name, version = nil) ⇒ Array<Hash{String => String}>?
47 48 49 50 51 52 53 54 55 |
# File 'lib/solargraph/rbs_map/stdlib_map.rb', line 47 def self.stdlib_dependencies name, version = nil if source.has?(name, version) # @sg-ignore we are relying on undocumented behavior where # passing version=nil gives the latest version it has source.dependencies_of(name, version) else [] end end |
Instance Method Details
#resolve_dependencies? ⇒ Boolean
57 58 59 60 61 62 |
# File 'lib/solargraph/rbs_map/stdlib_map.rb', line 57 def resolve_dependencies? # there are 'virtual' dependencies for stdlib gems in RBS that # aren't represented in the actual gemspecs that we'd # otherwise use true end |