<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -2,58 +2,58 @@ require &quot;pstore&quot;
 require &quot;monitor&quot;
 
 # == TimedCache
-# 
+#
 # TimedCache implements a cache in which you can place objects
 # and specify a timeout value.
-# 
+#
 # If you attempt to retrieve the object within the specified timeout
 # period, the object will be returned. If the timeout period has elapsed,
 # the TimedCache will return nil.
-# 
+#
 # e.g.:
 #   cache = TimedCache.new
 #   cache.put :my_object_key, &quot;Expensive data&quot;, 10 # =&gt; &quot;Expensive data&quot;
-#   
+#
 #   cache.get :my_object_key # =&gt; &quot;Expensive data&quot;
 #   cache[:my_object_key]    # =&gt; &quot;Expensive data&quot;
-# 
+#
 # ... 10 seconds later:
 #   cache.get :my_object_key # =&gt; nil
-# 
+#
 # === Default timeout
-# 
+#
 # When creating a new TimedCache, a default timeout value can be set. This value
 # will be used for each object added to the cache, unless a different timeout value
 # is specifically set for that object.
-# 
+#
 # e.g.:
-# 
+#
 #   cache = TimedCache.new(:default_timeout =&gt; 120)
 #   cache.default_timeout # =&gt; 120
-# 
+#
 # === File-based cache
-# 
-# By default, TimedCache will use an in-memory store. A file-based store (using the 
+#
+# By default, TimedCache will use an in-memory store. A file-based store (using the
 # PStore library) can also be used.
-# 
+#
 # e.g.:
-# 
+#
 #   TimedCache.new(:type =&gt; :file, :filename =&gt; &quot;my_cache.db&quot;)
-# 
-# The file-based cache makes it possible to easily share a cache between several ruby 
+#
+# The file-based cache makes it possible to easily share a cache between several ruby
 # processes.
-# 
+#
 # Note that objects that cannot be marshalled (e.g. a Proc) can't be stored using the file-based cache.
 class TimedCache
   VERSION = &quot;0.3&quot;
-  
+
   attr_reader :default_timeout
-  
+
   # Create a new TimedCache. Available options are:
   # &lt;tt&gt;type&lt;/tt&gt;:: &lt;tt&gt;:memory&lt;/tt&gt; or &lt;tt&gt;:file&lt;/tt&gt; (defaults to &lt;tt&gt;:memory&lt;/tt&gt;).
   # &lt;tt&gt;default_timeout&lt;/tt&gt;:: Timeout to use if none is specified when adding an object to the cache.
   # &lt;tt&gt;filename&lt;/tt&gt;:: Must be specified when using the &lt;tt&gt;:file&lt;/tt&gt; type store.
-  # 
+  #
   # e.g.:
   #   TimedCache.new(:type =&gt; :file, :filename =&gt; &quot;cache.db&quot;)
   def initialize(opts = {})
@@ -62,65 +62,65 @@ class TimedCache
     @store = new_store(opts)
     @store.extend(MonitorMixin)
   end
-  
+
   # Add an object to the cache. e.g.:
   #   cache.put(:session_id, 12345)
-  # 
-  # The third parameter is an optional timeout value. If not specified, the 
+  #
+  # The third parameter is an optional timeout value. If not specified, the
   # &lt;tt&gt;:default_timeout&lt;/tt&gt; for this TimedCache will be used instead.
   def put(key, value, timeout = @default_timeout)
     @store.synchronize do
       @store.put(key, value, timeout) unless value.nil?
     end
   end
-  
+
   # Retrieve the object which the given +key+. If the object has expired or
   # is not present, +nil+ is returned.
-  # 
+  #
   # Optionally, a block can be given. The result of evaluating the block will
   # be substituted as the cache value, if the cache has expired.
-  # 
+  #
   # e.g.:
-  # 
+  #
   #   cache.get(&quot;slow_database_query&quot;) do
   #     MyDatabase.query(&quot;SELECT * FROM bigtable...&quot;)
   #   end
-  # 
+  #
   def get(key, &amp;block)
     @store.synchronize do
       @store.get(key, &amp;block)
     end
   end
-  
+
   # Add to the cache using a hash-like syntax. e.g.:
   #   cache[:name] = &quot;Nick&quot;
-  # 
+  #
   # Note that adding to the cache this way does not allow you to specify timeout values
   # on a per-object basis.
   def []=(key, value)
     put(key, value)
   end
-  
+
   # Fetch objects using the hash syntax. e.g.:
   #   cache[:name] # =&gt; &quot;Nick&quot;
   def [](key)
     get(key)
   end
-  
+
   protected
-  
+
   def new_store(options) #:nodoc:
     self.class.const_get(options[:type].to_s.capitalize + &quot;Store&quot;).new(self, options)
   end
-  
+
   class Store #:nodoc:
     def initialize(timed_cache, options)
       @timed_cache = timed_cache
       @options     = options
     end
-    
+
     protected
-    
+
     def generic_get(key, timeout, callback, fetch_key = lambda {|k| @cache[key]})
       if object_store = fetch_key.call(key)
         if object_store.expired?
@@ -137,40 +137,40 @@ class TimedCache
         run_callback_and_add_to_cache(key, object_store, callback, timeout)
       end
     end
-    
+
     def run_callback_and_add_to_cache(key, object_store, callback, timeout)
       object_store.no_expiry! if object_store
-      
+
       begin
         result = callback.call
       rescue
         object_store.reset_expiry! if object_store
         raise
       end
-      
+
       @timed_cache.put(key, result, timeout)
       result
     end
   end
-  
+
   class MemoryStore &lt; Store #:nodoc:
     def initialize(*args)
       super(*args)
       @cache = Hash.new
     end
-    
+
     def put(key, value, timeout)
       @cache[key] = ObjectContainer.new(value, timeout)
       # Return just the given value, so that references to the
       # ObjectStore instance can't be held outside this TimedCache:
       value
     end
-    
+
     def get(key, timeout = @timed_cache.default_timeout, &amp;block)
       generic_get(key, timeout, block)
     end
   end
-  
+
   class FileStore &lt; Store #:nodoc:
     def initialize(*args)
       super(*args)
@@ -180,15 +180,15 @@ class TimedCache
       end
       @cache = PStore.new(filename)
     end
-    
+
     def put(key, value, timeout)
       @cache.transaction { @cache[key] = ObjectContainer.new(value, timeout) }
-      
+
       # Return just the given value, so that references to the
       # ObjectStore instance can't be held outside this TimedCache:
       value
     end
-    
+
     def get(key, timeout = @timed_cache.default_timeout, &amp;block)
       if block
         generic_get(key, timeout, block, lambda {|k| @cache.transaction { @cache[key] } })
@@ -197,17 +197,17 @@ class TimedCache
       end
     end
   end
-  
+
   class ObjectContainer #:nodoc:
     attr_accessor :object
-    
+
     def initialize(object, timeout)
       @created_at = Time.now.utc
       @timeout    = timeout
       @object     = object
       @frozen     = false
     end
-    
+
     def expired?
       if @frozen
         false
@@ -215,11 +215,11 @@ class TimedCache
         (Time.now.utc - @timeout) &gt; @created_at
       end
     end
-    
+
     def no_expiry!
       @frozen = true
     end
-    
+
     def reset_expiry!
       @frozen = false
     end</diff>
      <filename>lib/timedcache.rb</filename>
    </modified>
    <modified>
      <diff>@@ -8,59 +8,59 @@ describe &quot;Adding and retrieving objects from the cache&quot; do
     @file_cache   = TimedCache.new(:type =&gt; :file, :filename =&gt; $filename)
     @caches       = [@memory_cache, @file_cache]
   end
-  
+
   after do
     File.delete($filename)
   end
-  
+
   it &quot;Can add an object to the cache, specifying a timeout value&quot; do
     @caches.each do |cache|
       cache.put(:myobject, &quot;This needs caching&quot;, 10).should == &quot;This needs caching&quot;
     end
   end
-    
-  it &quot;Cache should hold seperate values for each key&quot; do
-    @caches.each do |cache|    
+
+  it &quot;Cache should hold separate values for each key&quot; do
+    @caches.each do |cache|
       cache.put(:myobject, &quot;This needs caching&quot;, 10).should == &quot;This needs caching&quot;
       cache.put(:my_other_object, &quot;...and this too&quot;, 10).should == &quot;...and this too&quot;
       cache.get(:myobject).should == &quot;This needs caching&quot;
       cache.get(:my_other_object).should == &quot;...and this too&quot;
     end
   end
-  
+
   it &quot;String and symbol keys are not treated as equivalent&quot; do
     @caches.each do |cache|
       cache[:symbolkey]  = &quot;Referenced by symbol&quot;
       cache[&quot;stringkey&quot;] = &quot;Referenced by string&quot;
-      
+
       cache[:symbolkey].should == &quot;Referenced by symbol&quot;
       cache[&quot;symbolkey&quot;].should == nil
-      
+
       cache[&quot;stringkey&quot;].should == &quot;Referenced by string&quot;
       cache[:stringkey].should == nil
     end
   end
-  
+
   it &quot;After the specified timeout value has elapsed, nil should be returned&quot; do
-    @caches.each do |cache|    
+    @caches.each do |cache|
       cache.put(:myobject, &quot;This needs caching&quot;, 0).should == &quot;This needs caching&quot;
       cache.get(:myobject).should == nil
     end
   end
-  
+
   it &quot;If no object matching the given key is found, nil should be returned&quot; do
     @caches.each do |cache|
       cache.get(:my_nonexistant_object).should == nil
     end
   end
-  
+
   it &quot;Should be able to use an array as a cache key&quot; do
     @caches.each do |cache|
       cache.put([123,234], &quot;Array&quot;).should == &quot;Array&quot;
       cache.get([123,234]).should == &quot;Array&quot;
     end
   end
-  
+
   it &quot;Passing a block to the TimedCache#get method should substitute the &quot; +
      &quot;result of the block as the value for the given key&quot; do
     @caches.each do |cache|
@@ -69,8 +69,8 @@ describe &quot;Adding and retrieving objects from the cache&quot; do
       cache.get(&quot;block_test&quot;).should == 2001
     end
   end
-  
-  it &quot;Passing a block to TimedCache#get should add the result of the callback &quot; + 
+
+  it &quot;Passing a block to TimedCache#get should add the result of the callback &quot; +
      &quot;when there is no existing value for the key given&quot; do
     @caches.each do |cache|
       cache.get(&quot;new_key_with_block&quot;).should == nil
@@ -85,13 +85,13 @@ describe &quot;Specifying a default timeout&quot; do
     cache.should be_kind_of(TimedCache)
     cache.default_timeout.should == 20
   end
-  
+
   it &quot;If no default timeout is set, 60 seconds should be used&quot; do
     cache = TimedCache.new
     cache.should be_kind_of(TimedCache)
     cache.default_timeout.should == 60
   end
-  
+
   it &quot;Timeout specified when putting a new object into the cache should override default timeout&quot; do
     cache = TimedCache.new(:default_timeout =&gt; 20)
     cache.default_timeout.should == 20</diff>
      <filename>spec/timed_cache_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c8434e72dce665d0781f0a3afd251de7ec20e010</id>
    </parent>
  </parents>
  <author>
    <name>Nicholas Dainty</name>
    <email>nick@npad.co.uk</email>
  </author>
  <url>http://github.com/nickpad/timedcache/commit/6fbe83ee5d3cab567cf3bc631812355174a6f411</url>
  <id>6fbe83ee5d3cab567cf3bc631812355174a6f411</id>
  <committed-date>2009-03-29T05:31:13-07:00</committed-date>
  <authored-date>2009-03-29T05:31:13-07:00</authored-date>
  <message>tidying.</message>
  <tree>3f6b384600f480a9a557c2eb438c65aac102713c</tree>
  <committer>
    <name>Nicholas Dainty</name>
    <email>nick@npad.co.uk</email>
  </committer>
</commit>
