<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -16,3 +16,4 @@
 0.8.0 - Allow :id and :rev in attributes= method, although values will be ignored.  Minor version change an accident, should have been patch
 0.8.1 - Address.find.all in readme should be Address.all
 0.8.2 - Add link to blog post on using objects with models
+0.8.3 - Fix API changes in CouchREST, proper exception thrown for non-started CouchDB and catch CouchDB 0.9 new conflict codes</diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -52,7 +52,7 @@ It is recommend that you read the quick start and performance sections in the rd
   CouchFoo::Base.set_database(:host =&gt; &quot;http://localhost:5984&quot;, :database =&gt; &quot;mydatabase&quot;)
   CouchFoo::Base.logger = Rails.logger
 
-If using with Rails you will need to create an initializer to do this (until proper integration is added)
+If using with Rails you will need to create an initializer to do this (until proper integration is added).  Also note depending on your version of CouchDB will depend on the version of the CouchREST gem you will require - CouchDB 0.9 requires CouchREST greater than 0.2 and CouchDB 0.8 requires CouchREST between 0.16 and 0.2.  You will be warned on CouchFoo initialization if this is wrong.
 
 
 == Examples of usage
@@ -127,7 +127,7 @@ Please feel free to fork and hit me with a request to merge back in.  At the mom
 * Proper integration with rails using a couchdb.yml config file
 * Example ruby script for updating indexes as an external process, and the same for database compacting  
 * :include for database queries
-* Remove dependency from CouchRest?  Add support for attachments and log calls to server so know performance times.  General tidy up of database.rb
+* Remove dependency from CouchRest - keep support for both CouchDB 0.8 and 0.9 for now.  Add support for attachments and log calls to server so know performance times.  General tidy up of database.rb.  Add support for etags?
 * inline and HABTM inline associations.  Also x_id and x_type properties should be automatically defined
 * compatability with willpaginate and friends
 * cleanup of associations, reflection, validations classes (were modified in a rush)</diff>
      <filename>README.rdoc</filename>
    </modified>
    <modified>
      <diff>@@ -9,7 +9,24 @@ module CouchFoo
     def initialize(options, bulk_save_default, *args)
       self.database = CouchRest.database(options[:host] + &quot;/&quot; + options[:database])
       self.bulk_save_default = bulk_save_default
-      self.database_version = (JSON.parse(RestClient.get(options[:host]))[&quot;version&quot;]).gsub(/-.+/,&quot;&quot;).to_f
+      
+      # Check database ok
+      begin
+        self.database_version = (JSON.parse(RestClient.get(options[:host]))[&quot;version&quot;]).gsub(/-.+/,&quot;&quot;).to_f
+      rescue Exception =&gt; e
+        if e.is_a?(Errno::ECONNREFUSED)
+          raise CouchFooError, &quot;CouchDB not started&quot;
+        else
+          raise CouchFooError, &quot;Error determining CouchDB version&quot;
+        end
+      end
+      
+      # Due to CouchDB view API changes in 0.9 and CouchREST only supporting newer version
+      if version &gt; 0.8 &amp;&amp; CouchRest::VERSION.to_f &lt; 0.21
+        raise CouchFooError, &quot;CouchFoo requires CouchRest &gt; 0.2 for use with CouchDB 0.9&quot;
+      elsif version &lt; 0.9 &amp;&amp; (CouchRest::VERSION.to_f &gt;= 0.21 || CouchRest::VERSION.to_f &lt;= 0.15)
+        raise CouchFooError, &quot;CouchFoo requires 0.15 &lt; CouchRest &lt; 0.21 for use with CouchDB 0.8&quot;
+      end
     end
     
     def save(doc, bulk_save = bulk_save?)
@@ -92,7 +109,7 @@ module CouchFoo
     def handle_exception(exception)
       if exception.is_a?(RestClient::ResourceNotFound)
         raise DocumentNotFound, &quot;Couldn't find document&quot;
-      elsif exception.is_a?(RestClient::RequestFailed) &amp;&amp; exception.respond_to?(:http_code) &amp;&amp; exception.http_code == 412
+      elsif exception.is_a?(RestClient::RequestFailed) &amp;&amp; exception.respond_to?(:http_code) &amp;&amp; (exception.http_code == 412 || exception.http_code == 409)
         
         raise DocumentConflict, &quot;Document has been updated whilst object loaded&quot;
       else
@@ -114,7 +131,7 @@ module CouchFoo
       def database
         if @active_database.nil?
           if self == CouchFoo::Base
-            raise Exception, &quot;No databases setup&quot;
+            raise CouchFooError, &quot;No databases setup&quot;
           else
             superclass.database
           end</diff>
      <filename>lib/couch_foo/database.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>332abedfdb7b6bf22e71409bc2da24a010992806</id>
    </parent>
  </parents>
  <author>
    <name>George Palmer</name>
    <email>george.palmer@gmail.com</email>
  </author>
  <url>http://github.com/georgepalmer/couch_foo/commit/cc7c63487a6815ea45b70038c3360c94e22e2c26</url>
  <id>cc7c63487a6815ea45b70038c3360c94e22e2c26</id>
  <committed-date>2009-04-21T04:57:33-07:00</committed-date>
  <authored-date>2009-04-21T04:57:33-07:00</authored-date>
  <message>Fix CouchRest API changes, add support for conflict detection on CouchDB 0.9 and proper exception thrown if CouchDB not started</message>
  <tree>45feb94e2a317bb48de09aa364d1302488ae943c</tree>
  <committer>
    <name>George Palmer</name>
    <email>george.palmer@gmail.com</email>
  </committer>
</commit>
