Sha256: f376c28f84c7a47cef5aefc9aa278e8d70cda08e8a8af4813482072f70394bc6
Contents?: true
Size: 939 Bytes
Versions: 1
Compression:
Stored size: 939 Bytes
Contents
require "autostruct/wrap" require "fileutils" require "middleman/caching_proxy/cache_manifest" module Middleman::CachingProxy class Cache def initialize(path:, key:) @manifest = nil end include Autostruct::Wrap def has?(item) cached_path = full_path(item: item) return false if !File.exist?(cached_path) manifest.has?(item) end def add(item:, source:) manifest.add item cached_path = full_path(item: item) copy_in source, cached_path end def full_path(item:) File.join(path, "items", item.path) end def save manifest.save end private def manifest @manifest ||= CacheManifest.new( path: path, key: key ) end def copy_in(source, cached_path) cache_subdirectory = File.dirname(cached_path) FileUtils.mkdir_p cache_subdirectory FileUtils.cp source, cached_path end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
middleman-caching-proxy-0.1.4 | lib/middleman/caching_proxy/cache.rb |