class Middleman::CachingProxy::Cache
Public Class Methods
new(path:, key:)
click to toggle source
# File lib/middleman/caching_proxy/cache.rb, line 8 def initialize(path:, key:) @manifest = nil end
Public Instance Methods
add(item:, source:)
click to toggle source
# File lib/middleman/caching_proxy/cache.rb, line 19 def add(item:, source:) manifest.add item cached_path = full_path(item: item) copy_in source, cached_path end
full_path(item:)
click to toggle source
# File lib/middleman/caching_proxy/cache.rb, line 25 def full_path(item:) File.join(path, "items", item.path) end
has?(item)
click to toggle source
# File lib/middleman/caching_proxy/cache.rb, line 13 def has?(item) cached_path = full_path(item: item) return false if !File.exist?(cached_path) manifest.has?(item) end
save()
click to toggle source
# File lib/middleman/caching_proxy/cache.rb, line 29 def save manifest.save end
Private Instance Methods
copy_in(source, cached_path)
click to toggle source
# File lib/middleman/caching_proxy/cache.rb, line 41 def copy_in(source, cached_path) cache_subdirectory = File.dirname(cached_path) FileUtils.mkdir_p cache_subdirectory FileUtils.cp source, cached_path end
manifest()
click to toggle source
# File lib/middleman/caching_proxy/cache.rb, line 35 def manifest @manifest ||= CacheManifest.new( path: path, key: key ) end