class Solargraph::DocMap
def resolve_path_to_gemspec path
-
(Gem::Specification, nil)
-
Parameters:
-
path
(String
) --
def resolve_path_to_gemspec path return nil if path.empty? gemspec = Gem::Specification.find_by_path(path) if gemspec.nil? gem_name_guess = path.split('/').first begin # this can happen when the gem is included via a local path in # a Gemfile; Gem doesn't try to index the paths in that case. # # See if we can make a good guess: potential_gemspec = Gem::Specification.find_by_name(gem_name_guess) file = "lib/#{path}.rb" gemspec = potential_gemspec if potential_gemspec.files.any? { |gemspec_file| file == gemspec_file } rescue Gem::MissingSpecError Solargraph.logger.debug "Require path #{path} could not be resolved to a gem via find_by_path or guess of #{gem_name_guess}" nil end end gemspec_or_preference gemspec end