<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>README.rdoc</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1 +1,3 @@
-pkg
\ No newline at end of file
+pkg
+.DS_Store
+rdoc</diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,7 @@
+# Contains the complete public API for APICache.
+# 
+# Uses Cache and API classes to determine the correct behaviour.
+# 
 class APICache
   class NotAvailableError &lt; RuntimeError; end
   class Invalid &lt;  RuntimeError; end
@@ -10,6 +14,7 @@ class APICache
   end
   
   # Initializes the cache
+  # 
   def self.start(store = nil, logger = nil)
     APICache.logger = logger || APICache::Logger.new
     APICache::Cache.store = (store || APICache::MemcacheStore).new</diff>
      <filename>lib/api_cache.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,25 +1,27 @@
-class APICache::AbstractStore
-  def initialize
-    raise &quot;Method not implemented. Called abstract class.&quot;
-  end
-  
-  # Set value. Returns true if success.
-  def set(key, value)
-    raise &quot;Method not implemented. Called abstract class.&quot;
-  end
-  
-  # Get value.
-  def get(key)
-    raise &quot;Method not implemented. Called abstract class.&quot;
-  end
-  
-  # Does a given key exist in the cache?
-  def exists?(key)
-    raise &quot;Method not implemented. Called abstract class.&quot;
-  end
-  
-  # Has a given time passed since the key was set?
-  def expired?(key, timeout)
-    raise &quot;Method not implemented. Called abstract class.&quot;
+class APICache
+  class AbstractStore
+    def initialize
+      raise &quot;Method not implemented. Called abstract class.&quot;
+    end
+
+    # Set value. Returns true if success.
+    def set(key, value)
+      raise &quot;Method not implemented. Called abstract class.&quot;
+    end
+
+    # Get value.
+    def get(key)
+      raise &quot;Method not implemented. Called abstract class.&quot;
+    end
+
+    # Does a given key exist in the cache?
+    def exists?(key)
+      raise &quot;Method not implemented. Called abstract class.&quot;
+    end
+
+    # Has a given time passed since the key was set?
+    def expired?(key, timeout)
+      raise &quot;Method not implemented. Called abstract class.&quot;
+    end
   end
 end</diff>
      <filename>lib/api_cache/abstract_store.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,92 +1,95 @@
 require 'net/http'
 
-# This class wraps up querying the API and remembers when each API was
-# last queried in case there is a limit to the number that can be made.
-#
-class APICache::API
-  @query_times = {}
-  class &lt;&lt; self
-    attr_reader :query_times
-  end
-  
-  # Takes the following options
-  # 
-  # period:: Maximum frequency to call the API
-  # timeout:: Timeout when calling api (either to the proviced url or 
-  #           excecuting the passed block)
-  # block:: If passed then the block is excecuted instead of HTTP GET against 
-  #         the provided key
+class APICache
+  # Wraps up querying the API.
   # 
-  def initialize(key, options, &amp;block)
-    @key, @block = key, block
-    @timeout = options[:timeout]
-    @period = options[:period]
-  end
-
-  # Checks whether the API can be queried (i.e. whether :period has passed
-  # since the last query to the API).
-  #
-  # If :period is 0 then there is no limit on how frequently queries can
-  # be made to the API.
+  # Ensures that the API is not called more frequently than every +period+ seconds, and times out API requests after +timeout+ seconds.
   #
-  def queryable?
-    if query_times[@key]
-      if Time.now - query_times[@key] &gt; @period
-        APICache.logger.log &quot;Queryable: true - retry_time has passed&quot;
-        true
+  class API
+    @query_times = {}
+    class &lt;&lt; self
+      attr_reader :query_times
+    end
+
+    # Takes the following options
+    #
+    # period:: Maximum frequency to call the API
+    # timeout:: Timeout when calling api (either to the proviced url or
+    #           excecuting the passed block)
+    # block:: If passed then the block is excecuted instead of HTTP GET 
+    #         against the provided key
+    #
+    def initialize(key, options, &amp;block)
+      @key, @block = key, block
+      @timeout = options[:timeout]
+      @period = options[:period]
+    end
+
+    # Checks whether the API can be queried (i.e. whether :period has passed
+    # since the last query to the API).
+    #
+    # If :period is 0 then there is no limit on how frequently queries can
+    # be made to the API.
+    #
+    def queryable?
+      if query_times[@key]
+        if Time.now - query_times[@key] &gt; @period
+          APICache.logger.log &quot;Queryable: true - retry_time has passed&quot;
+          true
+        else
+          APICache.logger.log &quot;Queryable: false - queried too recently&quot;
+          false
+        end
       else
-        APICache.logger.log &quot;Queryable: false - queried too recently&quot;
-        false
+        APICache.logger.log &quot;Queryable: true - never used API before&quot;
+        true
       end
-    else
-      APICache.logger.log &quot;Queryable: true - never used API before&quot;
-      true
     end
-  end
 
-  # Fetch data from the API.
-  #
-  # If no block is given then the key is assumed to be a URL and which will
-  # be queried expecting a 200 response. Otherwise the return value of the
-  # block will be used.
-  #
-  # If the block is unable to fetch the value from the API it should raise
-  # APICache::Invalid.
-  #
-  def get
-    APICache.logger.log &quot;Fetching data from the API&quot;
-    query_times[@key] = Time.now
-    Timeout::timeout(@timeout) do
-      if @block
-        # This should raise APICache::Invalid if it is not correct
-        @block.call
-      else
-        get_key_via_http
+    # Fetch data from the API.
+    #
+    # If no block is given then the key is assumed to be a URL and which will
+    # be queried expecting a 200 response. Otherwise the return value of the
+    # block will be used.
+    #
+    # If the block is unable to fetch the value from the API it should raise
+    # APICache::Invalid.
+    #
+    def get
+      APICache.logger.log &quot;Fetching data from the API&quot;
+      query_times[@key] = Time.now
+      Timeout::timeout(@timeout) do
+        if @block
+          # This should raise APICache::Invalid if it is not correct
+          @block.call
+        else
+          get_key_via_http
+        end
       end
+    rescue Timeout::Error, APICache::Invalid =&gt; e
+      raise APICache::CannotFetch, e.message
     end
-  rescue Timeout::Error, APICache::Invalid =&gt; e
-    raise APICache::CannotFetch, e.message
-  end
 
-  private
+    private
+
+    def get_key_via_http
+      response = redirecting_get(@key)
+      case response
+      when Net::HTTPSuccess
+        # 2xx response code
+        response.body
+      else
+        raise APICache::Invalid, &quot;Invalid http response: #{response.code}&quot;
+      end
+    end
 
-  def get_key_via_http
-    response = redirecting_get(@key)
-    case response
-    when Net::HTTPSuccess
-      # 2xx response code
-      response.body
-    else
-      raise APICache::Invalid, &quot;Invalid http response: #{response.code}&quot;
+    def redirecting_get(url)
+      r = Net::HTTP.get_response(URI.parse(url))
+      r.header['location'] ? redirecting_get(r.header['location']) : r
     end
-  end
 
-  def redirecting_get(url)
-    r = Net::HTTP.get_response(URI.parse(url))
-    r.header['location'] ? redirecting_get(r.header['location']) : r
-  end
-  
-  def query_times
-    self.class.query_times
+    def query_times
+      self.class.query_times
+    end
   end
 end</diff>
      <filename>lib/api_cache/api.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,56 +1,58 @@
 require 'digest/md5'
 
-# Cache performs calculations relating to the status of items stored in the
-# cache and delegates storage to the various cache stores.
-#
-class APICache::Cache
-  class &lt;&lt; self
-    attr_accessor :store
-  end
+class APICache
+  # Cache performs calculations relating to the status of items stored in the
+  # cache and delegates storage to the various cache stores.
+  #
+  class Cache
+    class &lt;&lt; self
+      attr_accessor :store
+    end
 
-  def initialize(key, options)
-    @key = key
-    @cache = options[:cache]
-    @valid = options[:valid]
-  end
+    def initialize(key, options)
+      @key = key
+      @cache = options[:cache]
+      @valid = options[:valid]
+    end
 
-  # Returns one of the following options depending on the state of the key:
-  #
-  # * :current (key has been set recently)
-  # * :refetch (data should be refetched but is still available for use)
-  # * :invalid (data is too old to be useful)
-  # * :missing (do data for this key)
-  #
-  def state
-    if store.exists?(hash)
-      if !store.expired?(hash, @cache)
-        :current
-      elsif (@valid == :forever) || !store.expired?(hash, @valid)
-        :refetch
+    # Returns one of the following options depending on the state of the key:
+    #
+    # * :current (key has been set recently)
+    # * :refetch (data should be refetched but is still available for use)
+    # * :invalid (data is too old to be useful)
+    # * :missing (do data for this key)
+    #
+    def state
+      if store.exists?(hash)
+        if !store.expired?(hash, @cache)
+          :current
+        elsif (@valid == :forever) || !store.expired?(hash, @valid)
+          :refetch
+        else
+          :invalid
+        end
       else
-        :invalid
+        :missing
       end
-    else
-      :missing
     end
-  end
 
-  def get
-    store.get(hash)
-  end
+    def get
+      store.get(hash)
+    end
 
-  def set(value)
-    store.set(hash, value)
-    true
-  end
-  
-  private
-  
-  def hash
-    Digest::MD5.hexdigest @key
-  end
-  
-  def store
-    self.class.store
+    def set(value)
+      store.set(hash, value)
+      true
+    end
+
+    private
+
+    def hash
+      Digest::MD5.hexdigest @key
+    end
+
+    def store
+      self.class.store
+    end
   end
 end</diff>
      <filename>lib/api_cache/cache.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,9 +1,11 @@
-class APICache::Logger
-  def initialize
-    
-  end
-  
-  def log(message)
-    # puts &quot;APICache: #{message}&quot;
+class APICache
+  class Logger
+    def initialize
+
+    end
+
+    def log(message)
+      # puts &quot;APICache: #{message}&quot;
+    end
   end
 end</diff>
      <filename>lib/api_cache/logger.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,54 +1,56 @@
 require 'memcache'
 
-class APICache::MemcacheStore &lt; APICache::AbstractStore
-  class NotReady &lt; Exception #:nodoc:
-    def initialize
-      super(&quot;Memcache server is not ready&quot;)
+class APICache
+  class MemcacheStore &lt; APICache::AbstractStore
+    class NotReady &lt; Exception #:nodoc:
+      def initialize
+        super(&quot;Memcache server is not ready&quot;)
+      end
+    end
+
+    class NotDefined &lt; Exception #:nodoc:
+      def initialize
+        super(&quot;Memcache is not defined&quot;)
+      end
     end
-  end
 
-  class NotDefined &lt; Exception #:nodoc:
     def initialize
-      super(&quot;Memcache is not defined&quot;)
+      APICache.logger.log &quot;Using memcached store&quot;
+      namespace = 'api_cache'
+      host = '127.0.0.1:11211'
+      @memcache = MemCache.new(host, {:namespace =&gt; namespace})
+      raise NotReady unless @memcache.active?
+      true
+      # rescue NameError
+      #   raise NotDefined
     end
-  end
-  
-  def initialize
-    APICache.logger.log &quot;Using memcached store&quot;
-    namespace = 'api_cache'
-    host = '127.0.0.1:11211'
-    @memcache = MemCache.new(host, {:namespace =&gt; namespace})
-    raise NotReady unless @memcache.active?
-    true
-  # rescue NameError
-  #   raise NotDefined
-  end
-  
-  def set(key, data)
-    @memcache.set(key, data)
-    @memcache.set(&quot;#{key}_created_at&quot;, Time.now)
-    APICache.logger.log(&quot;cache: set (#{key})&quot;)
-    true
-  end
-  
-  def get(key)
-    data = @memcache.get(key)
-    APICache.logger.log(&quot;cache: #{data.nil? ? &quot;miss&quot; : &quot;hit&quot;} (#{key})&quot;)
-    data
-  end
-  
-  def exists?(key)
-    # TODO: inefficient - is there a better way?
-    !@memcache.get(key).nil?
-  end
-  
-  def expired?(key, timeout)
-    Time.now - created(key) &gt; timeout
-  end
-  
-  private
 
-  def created(key)
-    @memcache.get(&quot;#{key}_created_at&quot;)
+    def set(key, data)
+      @memcache.set(key, data)
+      @memcache.set(&quot;#{key}_created_at&quot;, Time.now)
+      APICache.logger.log(&quot;cache: set (#{key})&quot;)
+      true
+    end
+
+    def get(key)
+      data = @memcache.get(key)
+      APICache.logger.log(&quot;cache: #{data.nil? ? &quot;miss&quot; : &quot;hit&quot;} (#{key})&quot;)
+      data
+    end
+
+    def exists?(key)
+      # TODO: inefficient - is there a better way?
+      !@memcache.get(key).nil?
+    end
+
+    def expired?(key, timeout)
+      Time.now - created(key) &gt; timeout
+    end
+
+    private
+
+    def created(key)
+      @memcache.get(&quot;#{key}_created_at&quot;)
+    end
   end
 end</diff>
      <filename>lib/api_cache/memcache_store.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,33 +1,35 @@
-class APICache::MemoryStore &lt; APICache::AbstractStore
-  def initialize
-    APICache.logger.log &quot;Using memory store&quot;
-    @cache = {}
-    true
-  end
+class APICache
+  class MemoryStore &lt; APICache::AbstractStore
+    def initialize
+      APICache.logger.log &quot;Using memory store&quot;
+      @cache = {}
+      true
+    end
 
-  def set(key, value)
-    APICache.logger.log(&quot;cache: set (#{key})&quot;)
-    @cache[key] = [Time.now, value]
-    true
-  end
+    def set(key, value)
+      APICache.logger.log(&quot;cache: set (#{key})&quot;)
+      @cache[key] = [Time.now, value]
+      true
+    end
 
-  def get(key)
-    data = @cache[key][1]
-    APICache.logger.log(&quot;cache: #{data.nil? ? &quot;miss&quot; : &quot;hit&quot;} (#{key})&quot;)
-    data
-  end
+    def get(key)
+      data = @cache[key][1]
+      APICache.logger.log(&quot;cache: #{data.nil? ? &quot;miss&quot; : &quot;hit&quot;} (#{key})&quot;)
+      data
+    end
 
-  def exists?(key)
-    !@cache[key].nil?
-  end
-  
-  def expired?(key, timeout)
-    Time.now - created(key) &gt; timeout
-  end
+    def exists?(key)
+      !@cache[key].nil?
+    end
+
+    def expired?(key, timeout)
+      Time.now - created(key) &gt; timeout
+    end
 
-  private
+    private
 
-  def created(key)
-    @cache[key][0]
+    def created(key)
+      @cache[key][0]
+    end
   end
 end</diff>
      <filename>lib/api_cache/memory_store.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>README.markdown</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>d320719375002784e87713f8c819f0c792b5b9ea</id>
    </parent>
  </parents>
  <author>
    <name>Martyn Loughran</name>
    <email>me@mloughran.com</email>
  </author>
  <url>http://github.com/mloughran/api_cache/commit/bdb80b368f8b28381f4b829145692ded9bba5404</url>
  <id>bdb80b368f8b28381f4b829145692ded9bba5404</id>
  <committed-date>2009-05-04T13:44:29-07:00</committed-date>
  <authored-date>2009-05-04T13:38:03-07:00</authored-date>
  <message>Fixed and improved rdoc documentation

* Changed the readme file to be rdoc formatted
* For some reason APICache::Cache makes RDoc think APICache is a module...</message>
  <tree>62c279a618ba1157911b0d0b79baa4537e1fca14</tree>
  <committer>
    <name>Martyn Loughran</name>
    <email>me@mloughran.com</email>
  </committer>
</commit>
