Class: Yoda::Store::Project::Cache
- Inherits:
-
Object
- Object
- Yoda::Store::Project::Cache
- Defined in:
- lib/yoda/store/project/cache.rb
Overview
Find registry file for the current project settings.
Instance Attribute Summary collapse
- #cache_dir_path ⇒ String readonly
- #gemfile_lock_path ⇒ String? readonly
Class Method Summary collapse
- .build_for(project) ⇒ Object
- .cache_dir(project_dir) ⇒ String
- .gemfile_lock_path(project_dir) ⇒ String
Instance Method Summary collapse
- #cache_path ⇒ String
-
#initialize(cache_dir_path:, gemfile_lock_path: nil) ⇒ Cache
constructor
A new instance of Cache.
- #present? ⇒ true, false
- #register_adapter(registry) ⇒ Object
Constructor Details
#initialize(cache_dir_path:, gemfile_lock_path: nil) ⇒ Cache
Returns a new instance of Cache.
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_path ⇒ String (readonly)
31 32 33 |
# File 'lib/yoda/store/project/cache.rb', line 31 def cache_dir_path @cache_dir_path end |
#gemfile_lock_path ⇒ String? (readonly)
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
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
14 15 16 |
# File 'lib/yoda/store/project/cache.rb', line 14 def cache_dir(project_dir) File.('.yoda/cache', project_dir) end |
.gemfile_lock_path(project_dir) ⇒ 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_path ⇒ String
56 57 58 |
# File 'lib/yoda/store/project/cache.rb', line 56 def cache_path File.(cache_name, cache_dir_path) end |
#present? ⇒ true, false
44 45 46 |
# File 'lib/yoda/store/project/cache.rb', line 44 def present? File.exist?(cache_path) end |
#register_adapter(registry) ⇒ Object
49 50 51 52 53 |
# File 'lib/yoda/store/project/cache.rb', line 49 def register_adapter(registry) return if registry.adapter make_cache_dir registry.adapter = Adapters.default_adapter_class.for(cache_path) end |