class Solargraph::YardMap

Public Instance Methods

spec_for_require(path) click to toggle source

TODO: remove after github.com/castwide/solargraph/pull/509 is merged

# File lib/solargraph/arc/patches.rb, line 32
def spec_for_require path
  name = path.split('/').first
  spec = Gem::Specification.find_by_name(name, @gemset[name])

  # Avoid loading the spec again if it's going to be skipped anyway
  #
  return spec if @source_gems.include?(spec.name)
  # Avoid loading the spec again if it's already the correct version
  if @gemset[spec.name] && @gemset[spec.name] != spec.version
    begin
      return Gem::Specification.find_by_name(spec.name, "= #{@gemset[spec.name]}")
    rescue Gem::LoadError
      Solargraph.logger.warn "Unable to load #{spec.name} #{@gemset[spec.name]} specified by workspace, using #{spec.version} instead"
    end
  end
  spec
end