Module: Solargraph::CacheDir

Defined in:
lib/solargraph/cache_dir.rb

Class Method Summary collapse

Class Method Details

.base_dir ⇒ String

The base directory for cached YARD documentation and serialized pins.

Returns:

  • (String)


13
14
15
16
17
# File 'lib/solargraph/cache_dir.rb', line 13

def base_dir
  ENV['SOLARGRAPH_CACHE'] ||
    (ENV['XDG_CACHE_HOME'] ? File.join(ENV['XDG_CACHE_HOME'], 'solargraph') : nil) ||
    File.join(Dir.home, '.cache', 'solargraph')
end

.clear ⇒ Object



54
55
56
# File 'lib/solargraph/cache_dir.rb', line 54

def clear
  FileUtils.rm_rf base_dir
end

.gem_dir ⇒ String

The current gem directory.

Returns:

  • (String)


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

def gem_dir
  File.join(work_dir, 'gems')
end

.rbs_dir ⇒ String

The current RBS collection directory.

Returns:

  • (String)


43
44
45
# File 'lib/solargraph/cache_dir.rb', line 43

def rbs_dir
  File.join(work_dir, 'rbs')
end

.stdlib_dir ⇒ String

The current stdlib directory.

Returns:

  • (String)


36
37
38
# File 'lib/solargraph/cache_dir.rb', line 36

def stdlib_dir
  File.join(work_dir, 'stdlib')
end

.work_dir ⇒ String

The working directory for the current Ruby, RBS, and Solargraph versions.

Returns:

  • (String)


22
23
24
# File 'lib/solargraph/cache_dir.rb', line 22

def work_dir
  File.join(base_dir, "ruby-#{RUBY_VERSION}", "rbs-#{RBS::VERSION}", "solargraph-#{Solargraph::VERSION}")
end

.yard_dir ⇒ String

The directory for the current YARD version.

Returns:

  • (String)


50
51
52
# File 'lib/solargraph/cache_dir.rb', line 50

def yard_dir
  File.join(base_dir, "yard-#{YARD::VERSION}", "yard-activesupport-concern-#{YARD::ActiveSupport::Concern::VERSION}")
end