Class: Yoda::Store::Project::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/yoda/store/project/cache.rb

Overview

Find registry file for the current project settings.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cache_dir_path:, gemfile_lock_path: nil) ⇒ Cache

Returns a new instance of Cache.

Parameters:

  • cache_dir_path (String)
  • gemfile_lock_path (String, nil) (defaults to: nil)


38
39
40
41
# 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

Instance Attribute Details

#cache_dir_pathString (readonly)

Returns:

  • (String)


31
32
33
# File 'lib/yoda/store/project/cache.rb', line 31

def cache_dir_path
  @cache_dir_path
end

#gemfile_lock_pathString? (readonly)

Returns:

  • (String, nil)


34
35
36
# File 'lib/yoda/store/project/cache.rb', line 34

def gemfile_lock_path
  @gemfile_lock_path
end

Class Method Details

.build_for(project) ⇒ Object

Parameters:



25
26
27
# 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) ⇒ String

Parameters:

  • project_dir (String)

Returns:

  • (String)


14
15
16
# 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) ⇒ String

Parameters:

  • project_dir (String)

Returns:

  • (String)


20
21
22
# File 'lib/yoda/store/project/cache.rb', line 20

def gemfile_lock_path(project_dir)
  File.absolute_path('Gemfile.lock', project_dir)
end

Instance Method Details

#cache_pathString

Returns:

  • (String)


55
56
57
# File 'lib/yoda/store/project/cache.rb', line 55

def cache_path
  File.expand_path(cache_name, cache_dir_path)
end

#prepare_registryRegistry

Returns:



49
50
51
52
# 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?true, false

Returns:

  • (true, false)


44
45
46
# File 'lib/yoda/store/project/cache.rb', line 44

def present?
  File.exist?(cache_path)
end