Class: Solargraph::YardMap

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

Instance Method Summary collapse

Instance Method Details

#spec_for_require(path) ⇒ Object

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



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# 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