Class: Solargraph::Collection::Gem

Inherits:
Base
  • Object
show all
Includes:
Logging
Defined in:
lib/solargraph/collection/gem.rb

Overview

Cacheable gem pins.

Constant Summary collapse

@@path_source_cache =
{}

Constants included from Logging

Logging::DEFAULT_LOG_LEVEL, Logging::LOG_LEVELS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logging

log_level, logger

Methods inherited from Base

load, uncache

Constructor Details

#initialize(metagem) ⇒ Gem

Returns a new instance of Gem.

Parameters:



15
16
17
18
# File 'lib/solargraph/collection/gem.rb', line 15

def initialize metagem
  super()
  @metagem = metagem
end

Instance Attribute Details

#metagem ⇒ Object (readonly)

Returns the value of attribute metagem.



10
11
12
# File 'lib/solargraph/collection/gem.rb', line 10

def metagem
  @metagem
end

Class Method Details

.cached?(metagem) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/solargraph/collection/gem.rb', line 33

def self.cached? metagem
  metagem.cacheable? && File.exist?(new(metagem).cache_file)
end

Instance Method Details

#cache_file ⇒ Object



20
21
22
# File 'lib/solargraph/collection/gem.rb', line 20

def cache_file
  File.join CacheDir.gem_dir, "#{metagem.cache_name}.ser"
end

#load ⇒ Object



24
25
26
27
# File 'lib/solargraph/collection/gem.rb', line 24

def load
  return super if metagem.cacheable?
  @@path_source_cache[metagem.full_path] ||= pins
end

#pins ⇒ Object



29
30
31
# File 'lib/solargraph/collection/gem.rb', line 29

def pins
  @pins ||= without_yard
end