Module: Solargraph::PinCache
- Extended by:
- Logging
- Defined in:
- lib/solargraph/pin_cache.rb
Constant Summary
Constants included
from Logging
Logging::DEFAULT_LOG_LEVEL, Logging::LOG_LEVELS
Class Method Summary
collapse
-
.base_dir ⇒ String
The base directory where cached YARD documentation and serialized pins are serialized.
-
.clear ⇒ void
-
.combined_path(gemspec, hash) ⇒ String
-
.combined_path_prefix(gemspec) ⇒ String
-
.core_path ⇒ String
-
.deserialize_combined_gem(gemspec, hash) ⇒ Array<Pin::Base>
-
.deserialize_core ⇒ Array<Pin::Base>
-
.deserialize_rbs_collection_gem(gemspec, hash) ⇒ Array<Pin::Base>
-
.deserialize_stdlib_require(require) ⇒ Array<Pin::Base>
-
.deserialize_yard_gem(gemspec) ⇒ Array<Pin::Base>
-
.has_rbs_collection?(gemspec, hash) ⇒ Boolean
-
.has_yard?(gemspec) ⇒ Boolean
-
.rbs_collection_path(gemspec, hash) ⇒ String
-
.rbs_collection_path_prefix(gemspec) ⇒ String
-
.serialize_combined_gem(gemspec, hash, pins) ⇒ void
-
.serialize_core(pins) ⇒ void
-
.serialize_rbs_collection_gem(gemspec, hash, pins) ⇒ void
-
.serialize_stdlib_require(require, pins) ⇒ void
-
.serialize_yard_gem(gemspec, pins) ⇒ void
-
.stdlib_path ⇒ String
-
.stdlib_require_path(require) ⇒ String
-
.uncache_core ⇒ void
-
.uncache_gem(gemspec, out: nil) ⇒ void
-
.uncache_stdlib ⇒ void
-
.work_dir ⇒ String
The working directory for the current Ruby, RBS, and Solargraph versions.
-
.yard_gem_path(gemspec) ⇒ String
-
.yardoc_path(gemspec) ⇒ String
Methods included from Logging
logger
Class Method Details
.base_dir ⇒ String
The base directory where cached YARD documentation and serialized pins are serialized
13
14
15
16
17
18
19
|
# File 'lib/solargraph/pin_cache.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 ⇒ void
This method returns an undefined value.
188
189
190
|
# File 'lib/solargraph/pin_cache.rb', line 188
def clear
FileUtils.rm_rf base_dir, secure: true
end
|
.combined_path(gemspec, hash) ⇒ String
135
136
137
|
# File 'lib/solargraph/pin_cache.rb', line 135
def combined_path(gemspec, hash)
File.join(work_dir, 'combined', "#{gemspec.name}-#{gemspec.version}-#{hash || 0}.ser")
end
|
.combined_path_prefix(gemspec) ⇒ String
141
142
143
|
# File 'lib/solargraph/pin_cache.rb', line 141
def combined_path_prefix(gemspec)
File.join(work_dir, 'combined', "#{gemspec.name}-#{gemspec.version}-")
end
|
.core_path ⇒ String
64
65
66
|
# File 'lib/solargraph/pin_cache.rb', line 64
def core_path
File.join(work_dir, 'core.ser')
end
|
.deserialize_combined_gem(gemspec, hash) ⇒ Array<Pin::Base>
156
157
158
|
# File 'lib/solargraph/pin_cache.rb', line 156
def deserialize_combined_gem gemspec, hash
load(combined_path(gemspec, hash))
end
|
.deserialize_core ⇒ Array<Pin::Base>
69
70
71
|
# File 'lib/solargraph/pin_cache.rb', line 69
def deserialize_core
load(core_path)
end
|
.deserialize_rbs_collection_gem(gemspec, hash) ⇒ Array<Pin::Base>
120
121
122
|
# File 'lib/solargraph/pin_cache.rb', line 120
def deserialize_rbs_collection_gem(gemspec, hash)
load(rbs_collection_path(gemspec, hash))
end
|
.deserialize_stdlib_require(require) ⇒ Array<Pin::Base>
52
53
54
|
# File 'lib/solargraph/pin_cache.rb', line 52
def deserialize_stdlib_require require
load(stdlib_require_path(require))
end
|
.deserialize_yard_gem(gemspec) ⇒ Array<Pin::Base>
87
88
89
|
# File 'lib/solargraph/pin_cache.rb', line 87
def deserialize_yard_gem(gemspec)
load(yard_gem_path(gemspec))
end
|
.has_rbs_collection?(gemspec, hash) ⇒ Boolean
163
164
165
|
# File 'lib/solargraph/pin_cache.rb', line 163
def has_rbs_collection?(gemspec, hash)
exist?(rbs_collection_path(gemspec, hash))
end
|
.has_yard?(gemspec) ⇒ Boolean
100
101
102
|
# File 'lib/solargraph/pin_cache.rb', line 100
def has_yard?(gemspec)
exist?(yard_gem_path(gemspec))
end
|
.rbs_collection_path(gemspec, hash) ⇒ String
107
108
109
|
# File 'lib/solargraph/pin_cache.rb', line 107
def rbs_collection_path(gemspec, hash)
File.join(work_dir, 'rbs', "#{gemspec.name}-#{gemspec.version}-#{hash || 0}.ser")
end
|
.rbs_collection_path_prefix(gemspec) ⇒ String
113
114
115
|
# File 'lib/solargraph/pin_cache.rb', line 113
def rbs_collection_path_prefix(gemspec)
File.join(work_dir, 'rbs', "#{gemspec.name}-#{gemspec.version}-")
end
|
.serialize_combined_gem(gemspec, hash, pins) ⇒ void
This method returns an undefined value.
149
150
151
|
# File 'lib/solargraph/pin_cache.rb', line 149
def serialize_combined_gem(gemspec, hash, pins)
save(combined_path(gemspec, hash), pins)
end
|
.serialize_core(pins) ⇒ void
This method returns an undefined value.
75
76
77
|
# File 'lib/solargraph/pin_cache.rb', line 75
def serialize_core pins
save(core_path, pins)
end
|
.serialize_rbs_collection_gem(gemspec, hash, pins) ⇒ void
This method returns an undefined value.
128
129
130
|
# File 'lib/solargraph/pin_cache.rb', line 128
def serialize_rbs_collection_gem(gemspec, hash, pins)
save(rbs_collection_path(gemspec, hash), pins)
end
|
.serialize_stdlib_require(require, pins) ⇒ void
This method returns an undefined value.
59
60
61
|
# File 'lib/solargraph/pin_cache.rb', line 59
def serialize_stdlib_require require, pins
save(stdlib_require_path(require), pins)
end
|
.serialize_yard_gem(gemspec, pins) ⇒ void
This method returns an undefined value.
94
95
96
|
# File 'lib/solargraph/pin_cache.rb', line 94
def serialize_yard_gem(gemspec, pins)
save(yard_gem_path(gemspec), pins)
end
|
.stdlib_path ⇒ String
40
41
42
|
# File 'lib/solargraph/pin_cache.rb', line 40
def stdlib_path
File.join(work_dir, 'stdlib')
end
|
.stdlib_require_path(require) ⇒ String
46
47
48
|
# File 'lib/solargraph/pin_cache.rb', line 46
def stdlib_require_path require
File.join(stdlib_path, "#{require}.ser")
end
|
.uncache_core ⇒ void
This method returns an undefined value.
168
169
170
|
# File 'lib/solargraph/pin_cache.rb', line 168
def uncache_core
uncache(core_path)
end
|
.uncache_gem(gemspec, out: nil) ⇒ void
This method returns an undefined value.
180
181
182
183
184
185
|
# File 'lib/solargraph/pin_cache.rb', line 180
def uncache_gem(gemspec, out: nil)
uncache(yardoc_path(gemspec), out: out)
uncache_by_prefix(rbs_collection_path_prefix(gemspec), out: out)
uncache(yard_gem_path(gemspec), out: out)
uncache_by_prefix(combined_path_prefix(gemspec), out: out)
end
|
.uncache_stdlib ⇒ void
This method returns an undefined value.
173
174
175
|
# File 'lib/solargraph/pin_cache.rb', line 173
def uncache_stdlib
uncache(stdlib_path)
end
|
.work_dir ⇒ String
The working directory for the current Ruby, RBS, and Solargraph versions.
24
25
26
27
28
|
# File 'lib/solargraph/pin_cache.rb', line 24
def work_dir
File.join(base_dir, "ruby-#{RUBY_VERSION}", "rbs-#{RBS::VERSION}", "solargraph-#{Solargraph::VERSION}")
end
|
.yard_gem_path(gemspec) ⇒ String
81
82
83
|
# File 'lib/solargraph/pin_cache.rb', line 81
def yard_gem_path gemspec
File.join(work_dir, 'yard', "#{gemspec.name}-#{gemspec.version}.ser")
end
|
.yardoc_path(gemspec) ⇒ String
32
33
34
35
36
37
|
# File 'lib/solargraph/pin_cache.rb', line 32
def yardoc_path gemspec
File.join(base_dir,
"yard-#{YARD::VERSION}",
"yard-activesupport-concern-#{YARD::ActiveSupport::Concern::VERSION}",
"#{gemspec.name}-#{gemspec.version}.yardoc")
end
|