Class: Middleman::CachingProxy::Cache
- Inherits:
-
Object
- Object
- Middleman::CachingProxy::Cache
- Includes:
- Autostruct::Wrap
- Defined in:
- lib/middleman/caching_proxy/cache.rb
Instance Method Summary collapse
- #add(item:, source:) ⇒ Object
- #full_path(item:) ⇒ Object
- #has?(item) ⇒ Boolean
-
#initialize(path:, key:) ⇒ Cache
constructor
A new instance of Cache.
- #save ⇒ Object
Constructor Details
#initialize(path:, key:) ⇒ Cache
Returns a new instance of Cache.
8 9 10 |
# File 'lib/middleman/caching_proxy/cache.rb', line 8 def initialize(path:, key:) @manifest = nil end |
Instance Method Details
#add(item:, source:) ⇒ Object
19 20 21 22 23 |
# 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:) ⇒ Object
25 26 27 |
# File 'lib/middleman/caching_proxy/cache.rb', line 25 def full_path(item:) File.join(path, "items", item.path) end |
#has?(item) ⇒ Boolean
13 14 15 16 17 |
# 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 ⇒ Object
29 30 31 |
# File 'lib/middleman/caching_proxy/cache.rb', line 29 def save manifest.save end |