class Yoda::Store::Project::Cache
Find registry file for the current project settings.
Attributes
cache_dir_path[R]
@return [String]
gemfile_lock_path[R]
@return [String, nil]
Public Class Methods
build_for(project)
click to toggle source
@param project [Project]
# File lib/yoda/store/project/cache.rb, line 25 def build_for(project) new(cache_dir_path: cache_dir(project.root_path), gemfile_lock_path: gemfile_lock_path(project.root_path)) end
cache_dir(project_dir)
click to toggle source
@param project_dir [String] @return [String]
# File lib/yoda/store/project/cache.rb, line 14 def cache_dir(project_dir) File.expand_path('.yoda/cache', project_dir) end
gemfile_lock_path(project_dir)
click to toggle source
@param project_dir [String] @return [String]
# File lib/yoda/store/project/cache.rb, line 20 def gemfile_lock_path(project_dir) File.absolute_path('Gemfile.lock', project_dir) end
new(cache_dir_path:, gemfile_lock_path: nil)
click to toggle source
@param cache_dir_path
[String] @param gemfile_lock_path
[String, nil]
# File lib/yoda/store/project/cache.rb, line 38 def initialize(cache_dir_path:, gemfile_lock_path: nil) @cache_dir_path = cache_dir_path @gemfile_lock_path = gemfile_lock_path end
Public Instance Methods
cache_path()
click to toggle source
@return [String]
# File lib/yoda/store/project/cache.rb, line 55 def cache_path File.expand_path(cache_name, cache_dir_path) end
prepare_registry()
click to toggle source
@return [Registry]
# File lib/yoda/store/project/cache.rb, line 49 def prepare_registry make_cache_dir Registry.new(Adapters.default_adapter_class.for(cache_path)) end
present?()
click to toggle source
@return [true, false]
# File lib/yoda/store/project/cache.rb, line 44 def present? File.exist?(cache_path) end
Private Instance Methods
cache_name()
click to toggle source
@return [String]
# File lib/yoda/store/project/cache.rb, line 62 def cache_name @cache_path ||= begin digest = Digest::SHA256.new digest.file(gemfile_lock_path) if gemfile_lock_path && File.exist?(gemfile_lock_path) digest.update(Registry::REGISTRY_VERSION.to_s) digest.update(Adapters.default_adapter_class.type.to_s) digest.hexdigest end end
make_cache_dir()
click to toggle source
# File lib/yoda/store/project/cache.rb, line 72 def make_cache_dir File.exist?(cache_dir_path) || FileUtils.mkdir_p(cache_dir_path) end