Class: BundleDepot::Cache
- Inherits:
-
Object
- Object
- BundleDepot::Cache
- Defined in:
- lib/bundle_depot/cache.rb
Constant Summary collapse
- DEFAULT_BUNDLE_DEPOT_PATH =
File.join(".bundle", "depot")
Instance Attribute Summary collapse
-
#local ⇒ Object
readonly
Returns the value of attribute local.
-
#remote ⇒ Object
readonly
Returns the value of attribute remote.
Class Method Summary collapse
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(local = FileSystemStore.new(Cache.cache_path), remote = FileSystemStore.new(File.join(Cache.depot_path, "remote"))) ⇒ Cache
constructor
A new instance of Cache.
- #store ⇒ Object
Constructor Details
#initialize(local = FileSystemStore.new(Cache.cache_path), remote = FileSystemStore.new(File.join(Cache.depot_path, "remote"))) ⇒ Cache
Returns a new instance of Cache.
36 37 38 39 40 41 |
# File 'lib/bundle_depot/cache.rb', line 36 def initialize(local = FileSystemStore.new(Cache.cache_path), remote = FileSystemStore.new(File.join(Cache.depot_path, "remote"))) @local = local @remote = remote end |
Instance Attribute Details
#local ⇒ Object (readonly)
Returns the value of attribute local.
34 35 36 |
# File 'lib/bundle_depot/cache.rb', line 34 def local @local end |
#remote ⇒ Object (readonly)
Returns the value of attribute remote.
34 35 36 |
# File 'lib/bundle_depot/cache.rb', line 34 def remote @remote end |
Class Method Details
.cache_path ⇒ Object
74 75 76 |
# File 'lib/bundle_depot/cache.rb', line 74 def self.cache_path ENV["BUNDLE_DEPOT_CACHE_PATH"] || File.join(Cache.depot_path, "cache") end |
.current_bundle_path ⇒ Object
78 79 80 |
# File 'lib/bundle_depot/cache.rb', line 78 def self.current_bundle_path ENV["BUNDLE_DEPOT_CURRENT_PATH"] || File.join(Cache.depot_path, "current") end |
.depot_path ⇒ Object
70 71 72 |
# File 'lib/bundle_depot/cache.rb', line 70 def self.depot_path ENV["BUNDLE_DEPOT_PATH"] || DEFAULT_BUNDLE_DEPOT_PATH end |
Instance Method Details
#fetch ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/bundle_depot/cache.rb', line 53 def fetch if local.cached?(digest) puts "=> Bundle found in local cache" else puts "=> Bundle is not in local cache" if remote.cached?(digest + ".tar.gz") download unpack else puts "=> Bundle is not in remote cache" FileUtils.mkdir_p(unpacked_bundle) end end link end |
#store ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/bundle_depot/cache.rb', line 43 def store if remote.cached?(digest + ".tar.gz") puts "=> Bundle is already in remote cache. Skipping upload." else raise BundleNotFound unless local.cached?(digest) pack upload end end |