From ddb15b2e3581291eaca016af0ed8cd594b38e672 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Sat, 26 Nov 2011 16:23:38 -0800 Subject: [PATCH] add some more rdocs --- lib/middleman/cache.rb | 26 +++++++++++++++++++-- lib/middleman/core_extensions/extensions.rb | 3 +++ lib/middleman/version.rb | 3 +++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/lib/middleman/cache.rb b/lib/middleman/cache.rb index b2d057cf..6aa992e9 100644 --- a/lib/middleman/cache.rb +++ b/lib/middleman/cache.rb @@ -1,29 +1,51 @@ module Middleman + # Simple shared cache implementation class Cache + + # Initialize def initialize - @cache = {} + self.clear 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) @cache[key] ||= yield end + # Whether the key is in the cache + # + # @param Anything Hash can use as a key + # @return [Boolean] def has_key?(key) @cache.has_key?(key) end + # Get a specific key + # + # @param Anything Hash can use as a key + # @return Cached value def get(key) @cache[key] end - + + # Clear the entire cache def clear @cache = {} end + # Set a specific key + # + # @param Anything Hash can use as a key + # @param Cached value def set(key, value) @cache[key] = value end + # Remove a specific key + # @param Anything Hash can use as a key def remove(*key) @cache.delete(key) if @cache.has_key?(key) end diff --git a/lib/middleman/core_extensions/extensions.rb b/lib/middleman/core_extensions/extensions.rb index 92c33e41..f44e07a8 100644 --- a/lib/middleman/core_extensions/extensions.rb +++ b/lib/middleman/core_extensions/extensions.rb @@ -28,6 +28,9 @@ # methods to use in your views. Some modify the output on-the-fly. And some # apply computationally-intensive changes to your final build files. +# Using for version parsing +require "rubygems" + module Middleman::CoreExtensions::Extensions class << self diff --git a/lib/middleman/version.rb b/lib/middleman/version.rb index fc371818..0512b55d 100644 --- a/lib/middleman/version.rb +++ b/lib/middleman/version.rb @@ -1,3 +1,6 @@ +# Using for version parsing +require "rubygems" + module Middleman VERSION = "3.0.0.alpha.3" GEM_VERSION = ::Gem::Version.create(VERSION)