add some more rdocs
This commit is contained in:
parent
fed3dd5a85
commit
ddb15b2e35
3 changed files with 30 additions and 2 deletions
|
@ -1,29 +1,51 @@
|
||||||
module Middleman
|
module Middleman
|
||||||
|
# Simple shared cache implementation
|
||||||
class Cache
|
class Cache
|
||||||
|
|
||||||
|
# Initialize
|
||||||
def initialize
|
def initialize
|
||||||
@cache = {}
|
self.clear
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Either get the cached key or save the contents of the block
|
||||||
|
#
|
||||||
|
# @param Anything Hash can use as a key
|
||||||
|
# @return Cached value
|
||||||
def fetch(*key)
|
def fetch(*key)
|
||||||
@cache[key] ||= yield
|
@cache[key] ||= yield
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Whether the key is in the cache
|
||||||
|
#
|
||||||
|
# @param Anything Hash can use as a key
|
||||||
|
# @return [Boolean]
|
||||||
def has_key?(key)
|
def has_key?(key)
|
||||||
@cache.has_key?(key)
|
@cache.has_key?(key)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Get a specific key
|
||||||
|
#
|
||||||
|
# @param Anything Hash can use as a key
|
||||||
|
# @return Cached value
|
||||||
def get(key)
|
def get(key)
|
||||||
@cache[key]
|
@cache[key]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Clear the entire cache
|
||||||
def clear
|
def clear
|
||||||
@cache = {}
|
@cache = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Set a specific key
|
||||||
|
#
|
||||||
|
# @param Anything Hash can use as a key
|
||||||
|
# @param Cached value
|
||||||
def set(key, value)
|
def set(key, value)
|
||||||
@cache[key] = value
|
@cache[key] = value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Remove a specific key
|
||||||
|
# @param Anything Hash can use as a key
|
||||||
def remove(*key)
|
def remove(*key)
|
||||||
@cache.delete(key) if @cache.has_key?(key)
|
@cache.delete(key) if @cache.has_key?(key)
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,6 +28,9 @@
|
||||||
# methods to use in your views. Some modify the output on-the-fly. And some
|
# methods to use in your views. Some modify the output on-the-fly. And some
|
||||||
# apply computationally-intensive changes to your final build files.
|
# apply computationally-intensive changes to your final build files.
|
||||||
|
|
||||||
|
# Using for version parsing
|
||||||
|
require "rubygems"
|
||||||
|
|
||||||
module Middleman::CoreExtensions::Extensions
|
module Middleman::CoreExtensions::Extensions
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
# Using for version parsing
|
||||||
|
require "rubygems"
|
||||||
|
|
||||||
module Middleman
|
module Middleman
|
||||||
VERSION = "3.0.0.alpha.3"
|
VERSION = "3.0.0.alpha.3"
|
||||||
GEM_VERSION = ::Gem::Version.create(VERSION)
|
GEM_VERSION = ::Gem::Version.create(VERSION)
|
||||||
|
|
Loading…
Reference in a new issue