Class: BundleDepot::Cache
- Inherits:
-
Object
- Object
- BundleDepot::Cache
- Defined in:
- lib/bundle_depot/cache.rb
Constant Summary collapse
- DEFAULT_BUNDLE_DEPOT_CURRENT =
File.join(".bundle", "depot", "current")
- DEFAULT_BUNDLE_DEPOT_CACHE =
File.join(".bundle", "depot", "cache")
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
- #fetch_local ⇒ Object
- #fetch_remote ⇒ Object
-
#initialize(local = FileSystemStore.new(Cache.cache_path), remote = FileSystemStore.new(File.join(".bundle", "depot", "remote")).with_packing) ⇒ Cache
constructor
A new instance of Cache.
- #remote_configured? ⇒ Boolean
- #store ⇒ Object
- #store_remote ⇒ Object
Constructor Details
#initialize(local = FileSystemStore.new(Cache.cache_path), remote = FileSystemStore.new(File.join(".bundle", "depot", "remote")).with_packing) ⇒ Cache
Returns a new instance of Cache.
135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/bundle_depot/cache.rb', line 135 def initialize(local = FileSystemStore.new(Cache.cache_path), remote = FileSystemStore.new(File.join(".bundle", "depot", "remote")).with_packing) if remote_configured? && !ENV["TEST"] remote = SCPStore.new(ENV["BUNDLE_DEPOT_SCP_HOST"], ENV["BUNDLE_DEPOT_SCP_USER"], ENV["BUNDLE_DEPOT_SCP_PASS"], "cache").with_packing end @local = local @remote = remote end |
Instance Attribute Details
#local ⇒ Object (readonly)
Returns the value of attribute local.
133 134 135 |
# File 'lib/bundle_depot/cache.rb', line 133 def local @local end |
#remote ⇒ Object (readonly)
Returns the value of attribute remote.
133 134 135 |
# File 'lib/bundle_depot/cache.rb', line 133 def remote @remote end |
Class Method Details
.cache_path ⇒ Object
190 191 192 |
# File 'lib/bundle_depot/cache.rb', line 190 def self.cache_path ENV["BUNDLE_DEPOT_CACHE"] || DEFAULT_BUNDLE_DEPOT_CACHE end |
.current_bundle_path ⇒ Object
194 195 196 |
# File 'lib/bundle_depot/cache.rb', line 194 def self.current_bundle_path ENV["DEFAULT_BUNDLE_DEPOT_CURRENT"] || DEFAULT_BUNDLE_DEPOT_CURRENT end |
Instance Method Details
#fetch ⇒ Object
153 154 155 156 157 |
# File 'lib/bundle_depot/cache.rb', line 153 def fetch setup fetch_remote unless fetch_local manage_symlink end |
#fetch_local ⇒ Object
159 160 161 162 163 164 165 166 |
# File 'lib/bundle_depot/cache.rb', line 159 def fetch_local if local.cached?(digest) puts "=> Bundle found in local cache" true else puts "=> Bundle is not in local cache" end end |
#fetch_remote ⇒ Object
168 169 170 171 172 173 174 175 176 177 |
# File 'lib/bundle_depot/cache.rb', line 168 def fetch_remote return unless remote_configured? if remote.cached?(digest) puts "=> Bundle found in remote cache. Downloading!" remote.fetch(digest, local.path) else puts "=> Bundle is not in remote cache" end end |
#remote_configured? ⇒ Boolean
198 199 200 |
# File 'lib/bundle_depot/cache.rb', line 198 def remote_configured? ENV["BUNDLE_DEPOT_SCP_HOST"] end |
#store ⇒ Object
148 149 150 151 |
# File 'lib/bundle_depot/cache.rb', line 148 def store setup store_remote end |
#store_remote ⇒ Object
179 180 181 182 183 184 185 186 187 188 |
# File 'lib/bundle_depot/cache.rb', line 179 def store_remote raise RemoteConfigurationMissing unless remote_configured? if remote.cached?(digest) puts "=> Bundle is already in remote cache. Skipping upload." else puts "=> Uploading bundle to remote cache" remote.store(File.join(local.path, digest)) end end |