write some file change and deletion tests for better data coverage
This commit is contained in:
parent
b8b48afcbb
commit
86cd626084
8 changed files with 53 additions and 67 deletions
|
@ -170,7 +170,7 @@ module Middleman
|
|||
# @private
|
||||
# @return [Middleman::Util::Cache] The cache
|
||||
def self.cache
|
||||
@_cache ||= ::Middleman::Util::Cache.new
|
||||
@_cache ||= ::Tilt::Cache.new
|
||||
end
|
||||
delegate :cache, :to => :"self.class"
|
||||
|
||||
|
|
|
@ -146,62 +146,5 @@ module Middleman
|
|||
end
|
||||
end.flatten.compact
|
||||
end
|
||||
|
||||
# Simple shared cache implementation
|
||||
class Cache
|
||||
# Initialize
|
||||
def initialize
|
||||
self.clear
|
||||
end
|
||||
|
||||
# Either get the cached key or save the contents of the block
|
||||
#
|
||||
# @param key Anything Hash can use as a key
|
||||
def fetch(*key)
|
||||
@cache[key] ||= yield
|
||||
end
|
||||
|
||||
# Whether the key is in the cache
|
||||
#
|
||||
# @param key Anything Hash can use as a key
|
||||
# @return [Boolean]
|
||||
def has_key?(key)
|
||||
@cache.has_key?(key)
|
||||
end
|
||||
|
||||
# Get a specific key
|
||||
#
|
||||
# @param key Anything Hash can use as a key
|
||||
def get(key)
|
||||
@cache[key]
|
||||
end
|
||||
|
||||
# Array of keys
|
||||
# @return [Array]
|
||||
def keys
|
||||
@cache.keys
|
||||
end
|
||||
|
||||
# Clear the entire cache
|
||||
# @return [void]
|
||||
def clear
|
||||
@cache = {}
|
||||
end
|
||||
|
||||
# Set a specific key
|
||||
#
|
||||
# @param key Anything Hash can use as a key
|
||||
# @param value Cached value
|
||||
# @return [void]
|
||||
def set(key, value)
|
||||
@cache[key] = value
|
||||
end
|
||||
|
||||
# Remove a specific key
|
||||
# @param key Anything Hash can use as a key
|
||||
def remove(*key)
|
||||
@cache.delete(key)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue