<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/active_couch/support/exporter.rb</filename>
    </added>
    <added>
      <filename>spec/base/count_all_spec.rb</filename>
    </added>
    <added>
      <filename>spec/base/find_from_url_spec.rb</filename>
    </added>
    <added>
      <filename>spec/exporter/delete_spec.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -6,7 +6,7 @@ With ActiveCouch, you can easily save, query, delete documents to/from a CouchDB
 
 Why?
 ----
-As they say, necessity is the mother of invention. And as they also say, death before inconvenience. Our company, Bezurk (http://www.bezurk.com) is experimenting with CouchDB as we have a need for a document-model to store vast amounts of information, and we needed a convenience mapper in our favourite language, in order to use CouchDB elegantly. Since, the Rubyists here at Bezurk are already very familiar with ActiveRecord semantics, care has been taken to ensure that ActiveCouch resembled it in many ways.
+As they say, necessity is the mother of invention. And as they also say, death before inconvenience. Our company, Wego (http://www.wego.com) has been using CouchDB for the past six months now, as we have a need for a document-model to store vast amounts of information, and we needed a convenience mapper in our favourite language, in order to use CouchDB elegantly. Since, the Rubyists here at Wego are already very familiar with ActiveRecord semantics, care has been taken to ensure that ActiveCouch resembled it in many ways.
 
 Contributors
 ------------
@@ -20,19 +20,9 @@ Requirements
  - rubygems 0.9.4 (http://rubygems.org)
  - JSON gem (http://json.rubyforge.org) [Used for JSON encoding/decoding]
  - RSpec gem (http://rspec.rubyforge.org) [Used to run specs]
- - CouchDB 0.7.x (alpha) or 0.8.0 and upwards (http://incubator.apache.org/couchdb/community/code.html) [Some specs require running CouchDB at localhost:5984]
+ - CouchDB 0.8.0 and upwards (http://incubator.apache.org/couchdb/community/code.html) [Some specs require running CouchDB at localhost:5984]
  
 Important Notice
 ----------------
 
-- If you are running specs against the 'alpha' versions of CouchDB, i.e. pre 0.8.0 versions, please set the environment variable COUCHDB_IS_ALPHA to true
-
-In bash, this is achieved like so:
-
-% export COUCHDB_IS_ALPHA=true
-
-- Also, for all migrations, if you need to run them against 'alpha' versions of CouchDB, i.e. pre-0.8.0, please us pass the :is_alpha =&gt; true variable as part of the define block
-
-Refer spec/migration/view_js_spec.rb
-
-We would also recommend installing ZenTest (http://www.zenspider.com/ZSS/Products/ZenTest/) which provides a very convenient way to run specs.
\ No newline at end of file
+ActiveCouch v0.2.0 does not support pre-0.8.0 versions of CouchDB
\ No newline at end of file</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -1 +1 @@
-0.1.95
\ No newline at end of file
+0.2.0
\ No newline at end of file</diff>
      <filename>VERSION</filename>
    </modified>
    <modified>
      <diff>@@ -354,6 +354,22 @@ module ActiveCouch
         end
       end
 
+      # Retrieves one or more object(s) from a CouchDB database, based on the search
+      # parameters given. This method is similar to the find_by_sql method in
+      # ActiveRecord, in a way that instead of using any conditions, we use a raw 
+      # URL to query a CouchDB view.
+      # 
+      # Example:
+      #   class Person &lt; ActiveCouch::Base
+      #     has :name
+      #   end
+      #
+      #   # This returns a single instance of an ActiveCouch::Base subclass
+      #   people = Person.find_from_url(&quot;/people/_view/by_name/by_name?key=%22Mclovin%22&quot;)
+      def find_from_url(url)
+        instantiate_collection(connection.get(url))
+      end
+
       # Retrieves the count of the number of objects in the CouchDB database, based on the
       # search parameters given.
       #
@@ -371,6 +387,21 @@ module ActiveCouch
         JSON.parse(result)['total_rows'].to_i
       end
 
+      # Retrieves the count of the number of objects in the CouchDB database, irrespective of
+      # any search criteria
+      #
+      # Example:
+      #   class Person &lt; ActiveCouch::Base
+      #     has :name
+      #   end
+      #
+      #   # This returns the count of the number of objects
+      #   people_count = Person.count_all
+      def count_all
+        result = connection.get(&quot;/#{database_name}&quot;)
+        JSON.parse(result)['doc_count'].to_i
+      end
+
       # Initializes a new subclass of ActiveCouch::Base and saves in the CouchDB database
       # as a new document
       # </diff>
      <filename>lib/active_couch/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,2 +1,3 @@
 require 'active_couch/support/inflector'
-require 'active_couch/support/extensions'
\ No newline at end of file
+require 'active_couch/support/extensions'
+require 'active_couch/support/exporter'
\ No newline at end of file</diff>
      <filename>lib/active_couch/support.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,2 @@
 require 'active_couch/views/errors.rb'
-require 'active_couch/views/view.rb'
-require 'active_couch/views/exporter.rb'
\ No newline at end of file
+require 'active_couch/views/view.rb'
\ No newline at end of file</diff>
      <filename>lib/active_couch/views.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,5 @@
 require File.dirname(__FILE__) + '/../spec_helper.rb'
 
-IS_ALPHA = ENV['COUCHDB_IS_ALPHA'] == 'true'
-
 describe &quot;ActiveCouch::Base #count method with just simple attributes&quot; do
   before(:each) do
     # Define the model
@@ -11,7 +9,7 @@ describe &quot;ActiveCouch::Base #count method with just simple attributes&quot; do
     end
     # Define the view
     class ByName &lt; ActiveCouch::View
-      define :for_db =&gt; 'people', :is_alpha =&gt; IS_ALPHA do
+      define :for_db =&gt; 'people' do
         with_key 'name'
       end
     end
@@ -29,18 +27,18 @@ describe &quot;ActiveCouch::Base #count method with just simple attributes&quot; do
     Object.send(:remove_const, :Person)
   end
 
-  it &quot;should respond to the find method&quot; do
+  it &quot;should respond to the count method&quot; do
     Person.should respond_to(:count)
   end
 
-  it &quot;should return an array with one Person object in it, when sent method find with parameter :all&quot; do
+  it &quot;should return an array with one Person object in it, when sent method count with search parameters&quot; do
     count = Person.count(:params =&gt; {:name =&gt; 'McLovin'})
     count.should == 1
   end
 end
 
 
-describe &quot;ActiveCouch::Base #find method with multiple documents in the CouchDB database&quot; do
+describe &quot;ActiveCouch::Base #count method with multiple documents in the CouchDB database&quot; do
   before(:each) do
     class Person &lt; ActiveCouch::Base
       site 'http://localhost:5984'
@@ -51,7 +49,7 @@ describe &quot;ActiveCouch::Base #find method with multiple documents in the CouchDB
     
     # Define the view
     class ByLastName &lt; ActiveCouch::View
-      define :for_db =&gt; 'people', :is_alpha =&gt; IS_ALPHA do
+      define :for_db =&gt; 'people' do
         with_key 'last_name'
       end
     end
@@ -70,7 +68,7 @@ describe &quot;ActiveCouch::Base #find method with multiple documents in the CouchDB
     Object.send(:remove_const, :Person)
   end
   
-  it &quot;should find all objects in the database when find method is sent the param :all&quot; do
+  it &quot;should count all objects in the database when count method is sent with valid search parameters&quot; do
     count = Person.count(:params =&gt; {:last_name =&gt; 'McLovin'})
     count.should == 2
   end</diff>
      <filename>spec/base/count_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -28,71 +28,35 @@ describe ActiveCouch::Exporter, &quot;#export (that actually connects to a CouchDB se
   end
 end
 
-describe ActiveCouch::Exporter, &quot;#export with site and migration&quot; do
-  before(:all) do
+describe ActiveCouch::Exporter, &quot;#export twice (that actually connects to a CouchDB server)&quot; do
+  before(:each) do
     class ByFace &lt; ActiveCouch::View
-      define :for_db =&gt; 'test_db' do
+      define :for_db =&gt; 'ac_test_3' do
         with_key 'face'
       end
     end
-  end
-
-  before(:each) do
-    @conn = mock(ActiveCouch::Connection)
-    @response = mock(Object, :code =&gt; '201')
-  end
-
-  after(:all) do
-    Object.send :remove_const, :ByFace
-  end
-
-  def mock_connection_and_response(options = {})
-    ByFace.should_receive(:view).any_number_of_times.and_return('by_face')
-    ByFace.should_receive(:to_json).any_number_of_times.and_return('{ &quot;some&quot; =&gt; &quot;view json&quot; }')
-
-    ActiveCouch::Connection.should_receive(:new).with(options[:site]).and_return(@conn)
-    @conn.should_receive(:put).with('/test_db/_design/by_face', '{ &quot;some&quot; =&gt; &quot;view json&quot; }').and_return(@response)
-  end
-
-  it &quot;should create a new Connection to the given site and send a PUT to the view URL&quot; do
-    ByFace.should_receive(:view).any_number_of_times.and_return('by_face')
-    ByFace.should_receive(:to_json).any_number_of_times.and_return('{ &quot;some&quot; =&gt; &quot;view json&quot; }')
-
-    ActiveCouch::Connection.should_receive(:new).with('http://test.host:5984/').and_return(@conn)
-    @conn.should_receive(:put).with('/test_db/_design/by_face', '{ &quot;some&quot; =&gt; &quot;view json&quot; }').and_return(@response)
-
-    ActiveCouch::Exporter.export('http://test.host:5984/', ByFace)
-  end
-
-  it &quot;should return true if the response code is HTTP status 201&quot; do
-    mock_connection_and_response(:site =&gt; 'http://test.host:5984/')
-    @response.should_receive(:code).any_number_of_times.and_return('201')
-
-    ActiveCouch::Exporter.export('http://test.host:5984/', ByFace).should == true
-  end
 
-  it &quot;should raise an ActiveCouch::ViewError if the response code is not HTTP status 201&quot; do
-    mock_connection_and_response(:site =&gt; 'http://test.host:5984/')
-    @response.should_receive(:code).any_number_of_times.and_return('500')
-
-    lambda {
-      ActiveCouch::Exporter.export('http://test.host:5984/', ByFace)
-    }.should raise_error(ActiveCouch::ViewError)
+    ActiveCouch::Exporter.create_database('http://localhost:5984/', 'ac_test_3')
   end
 
-  it &quot;should raise an ActiveCouch::ViewError if the migration has no view&quot; do
-    ByFace.should_receive(:name).and_return(nil)
-
-    lambda {
-      ActiveCouch::Exporter.export('http://test.host:5984/', ByFace)
-    }.should raise_error(ActiveCouch::ViewError)
+  after(:each) do
+    ActiveCouch::Exporter.delete_database('http://localhost:5984/', 'ac_test_3')
   end
 
-  it &quot;should raise an ActiveCouch::ViewError if the migration has no database&quot; do
-    ByFace.should_receive(:database).and_return(nil)
+  it &quot;should be able to create a permanent view when sent the export method, after the view has already been saved&quot; do
+    ActiveCouch::Exporter.export('http://localhost:5984', ByFace).should == true
+    # This is the view document. To actually query this particular view, the URL to be used
+    # is http://#{host}:#{port}/ac_test_1/_view/by_face/by_face 
+    # A little unwieldy I know, but the point of ActiveCouch is to abstract this unwieldiness
+    response = Net::HTTP.get_response URI.parse(&quot;http://localhost:5984/ac_test_3/_design/by_face&quot;)
+    response.code.should == '200'
+    
 
-    lambda {
-      ActiveCouch::Exporter.export('http://test.host:5984/', ByFace)
-    }.should raise_error(ActiveCouch::ViewError)
+    ActiveCouch::Exporter.export('http://localhost:5984', ByFace).should == true
+    # This is the view document. To actually query this particular view, the URL to be used
+    # is http://#{host}:#{port}/ac_test_1/_view/by_face/by_face 
+    # A little unwieldy I know, but the point of ActiveCouch is to abstract this unwieldiness
+    response = Net::HTTP.get_response URI.parse(&quot;http://localhost:5984/ac_test_3/_design/by_face&quot;)
+    response.code.should == '200'
   end
 end
\ No newline at end of file</diff>
      <filename>spec/exporter/export_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,22 +3,11 @@ require File.dirname(__FILE__) + '/../spec_helper.rb'
 describe &quot;ActiveCouch::View #define method&quot; do
   it &quot;should set @name and @database correctly if the first param is a String/Symbol&quot; do
     class ByName &lt; ActiveCouch::View
-      define :by_name, :for_db =&gt; 'people', :is_alpha =&gt; true
+      define :by_name, :for_db =&gt; 'people'
     end
 
     ByName.instance_variable_get(&quot;@name&quot;).should == 'by_name'
     ByName.instance_variable_get(&quot;@database&quot;).should == 'people'
-    ByName.instance_variable_get(&quot;@is_alpha&quot;).should == true
-  end
-
-  it &quot;should set @is_alpha to false if nothing is specified&quot; do
-    class ByAge &lt; ActiveCouch::View
-      define :by_age, :for_db =&gt; 'people'
-    end
-
-    ByAge.instance_variable_get(&quot;@name&quot;).should == 'by_age'
-    ByAge.instance_variable_get(&quot;@database&quot;).should == 'people'
-    ByAge.instance_variable_get(&quot;@is_alpha&quot;).should == false
   end
 
   it &quot;should set @name correctly if the first param passed is not a String/Symbol&quot; do
@@ -28,7 +17,6 @@ describe &quot;ActiveCouch::View #define method&quot; do
 
     ByFace.instance_variable_get(&quot;@name&quot;).should == 'by_face'
     ByFace.instance_variable_get(&quot;@database&quot;).should == 'people'
-    ByFace.instance_variable_get(&quot;@is_alpha&quot;).should == false
   end
   
   it &quot;should raise an exception if neither the view nor the database is given as parameters&quot; do</diff>
      <filename>spec/views/define_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,30 +1,23 @@
 require File.dirname(__FILE__) + '/../spec_helper.rb'
 
-# Needed to pass specs successfully
-IS_ALPHA = ENV['COUCHDB_IS_ALPHA'] == 'true'
-
 describe &quot;ActiveCouch::View #to_json method&quot; do
   before(:each) do
     class ByName &lt; ActiveCouch::View
-      define :by_name, :for_db =&gt; 'people', :is_alpha =&gt; IS_ALPHA do
+      define :by_name, :for_db =&gt; 'people' do
         with_key 'name'
       end
     end
   end
   
   it &quot;should generate the correct javascript to be used in the view&quot; do
-    if IS_ALPHA
-      (ByName.to_json =~ /map\(doc\.name, doc\);/).should_not == nil
-    else
-      (ByName.to_json =~ /emit\(doc\.name, doc\);/).should_not == nil
-    end
+    (ByName.to_json =~ /emit\(doc\.name, doc\);/).should_not == nil
   end
 end
 
 describe &quot;ActiveCouch::View #to_json method while calling the with_key and with_filter methods&quot; do
   before(:each) do
     class ByLatitude &lt; ActiveCouch::View
-      define :for_db =&gt; 'hotels', :is_alpha =&gt; IS_ALPHA do
+      define :for_db =&gt; 'hotels' do
         with_key 'latitude'
         with_filter 'doc.name == &quot;Hilton&quot;'
       end
@@ -32,12 +25,7 @@ describe &quot;ActiveCouch::View #to_json method while calling the with_key and with_
   end
   
   it &quot;should generate the correct javascript to be used in the view&quot; do
-    if IS_ALPHA
-      (ByLatitude.to_json =~ /map\(doc\.latitude, doc\);/).should_not == nil
-    else
-      (ByLatitude.to_json =~ /emit\(doc\.latitude, doc\);/).should_not == nil
-    end
-    
+    (ByLatitude.to_json =~ /emit\(doc\.latitude, doc\);/).should_not == nil
     (ByLatitude.to_json =~ /if\(doc\.name == \\&quot;Hilton\\&quot;\)/).should_not == nil
   end
 end
@@ -45,7 +33,7 @@ end
 describe &quot;A subclass of ActiveCouch::View while calling with_key and include_attributes method&quot; do
   before(:each) do
     class ByLongitude &lt; ActiveCouch::View
-      define :for_db =&gt; 'hotels', :is_alpha =&gt; IS_ALPHA do
+      define :for_db =&gt; 'hotels' do
         with_key 'latitude'
         include_attributes :name, :rating, :latitude, :longitude, :address
       end
@@ -53,10 +41,6 @@ describe &quot;A subclass of ActiveCouch::View while calling with_key and include_att
   end
 
   it &quot;should generate the correct javascript which will be used in the permanent view&quot; do
-    if IS_ALPHA
-      (ByLongitude.to_json =~ /map\(doc\.latitude, \{name: doc\.name , rating: doc\.rating , latitude: doc\.latitude , longitude: doc\.longitude , address: doc\.address\}\);/).should_not == nil
-    else
-      (ByLongitude.to_json =~ /emit\(doc\.latitude, \{name: doc\.name , rating: doc\.rating , latitude: doc\.latitude , longitude: doc\.longitude , address: doc\.address\}\);/).should_not == nil      
-    end
+    (ByLongitude.to_json =~ /emit\(doc\.latitude, \{name: doc\.name , rating: doc\.rating , latitude: doc\.latitude , longitude: doc\.longitude , address: doc\.address\}\);/).should_not == nil      
   end
 end
\ No newline at end of file</diff>
      <filename>spec/views/to_json_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -52,6 +52,7 @@ namespace :activecouch do
     end
   end
   
+  desc &quot;Deletes a view in CouchDB&quot;
   task :delete_view do
     unless (view_name = ENV['view']).nil?
       site = YAML::load(File.open(File.join(Rails.root, 'config', 'activecouch.yml')))[Rails.env]['site']</diff>
      <filename>tasks/activecouch.rake</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>ROADMAP</filename>
    </removed>
    <removed>
      <filename>STATUS</filename>
    </removed>
    <removed>
      <filename>lib/active_couch/views/exporter.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>24c26442decf5f57d36114f05396b9889ed1aba6</id>
    </parent>
  </parents>
  <author>
    <name>Arun Thampi</name>
    <email>arun@Macintosh.(none)</email>
  </author>
  <url>http://github.com/chuyeow/activecouch/commit/38b50ec9a8d022057835cb505e7c79bc30f7c997</url>
  <id>38b50ec9a8d022057835cb505e7c79bc30f7c997</id>
  <committed-date>2008-10-21T23:36:49-07:00</committed-date>
  <authored-date>2008-10-21T23:36:49-07:00</authored-date>
  <message>Cleaning up for v0.2.0 release. Added find_from_url and count_all methods to ActiveCouch::Base. Moved ActiveCouch::Exporter to be under lib/support</message>
  <tree>3e7e1696b23992ac3267bc3aa5dbb1538b9f6349</tree>
  <committer>
    <name>Arun Thampi</name>
    <email>arun@Macintosh.(none)</email>
  </committer>
</commit>
