<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>couchdbfs_lib.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,200 +1,24 @@
-require 'fusefs'
-require 'rubygems'
-require 'couchrest'
+require 'couchdbfs_lib'
 
-DEBUG = false #true
-
-class CouchdbDir
-  def initialize()
-  	@db = CouchRest.database!(&quot;http://127.0.0.1:5984/couchfs&quot;)
-		create_view()
-		create_root()
-  end
-
-	def create_view
-      @view = {}
-			@view['path'] = {'map' =&gt; &quot;function(doc) {
-            if (doc['path']) {
-						if(doc['path'] == \&quot;/\&quot;)
-						{
-              emit(doc['path'], null);
-						}
-						else
-						{
-              emit(doc['path'].replace(/\\/$/, \&quot;\&quot;), null);
-            }
-				}
-          }&quot;
-			}
-
-			@view['base_path'] = {'map' =&gt; &quot;function(doc) {
-            if (doc['base_path']) {
-						if(doc['base_path'] == \&quot;/\&quot;)
-						{
-              emit(doc['base_path'], null);
-						}
-						else
-						{
-              emit(doc['base_path'].replace(/\\/$/, \&quot;\&quot;), null);
-            }
-				}
-          }&quot;
-			}
-      @db.save({
-        &quot;_id&quot; =&gt; &quot;_design/doc&quot;,
-        :views =&gt; @view
-      })
-	end
-
-	#create the root dir
-	def create_root
-		if @db.view(&quot;doc/path&quot;, :key =&gt; &quot;/&quot;)['rows'].nitems == 0
-	    ret = {&quot;path&quot; =&gt; &quot;/&quot;, &quot;name&quot; =&gt; &quot;/&quot;, &quot;files&quot; =&gt; []}
-			@db.save(ret)
-		end
-	end
-
-  def contents(path)
-		p &quot;call:contents?(#{path})&quot; if DEBUG
-		files = @db.view(&quot;doc/base_path&quot;, :key =&gt; path)
-		p files if DEBUG
-		ret = []
-		files['rows'].each do |fil|
-			ret &lt;&lt; @db.get(fil['id'])['name']
-		end
-		return ret
-  end
-  def directory?(path)
-		dir = @db.view(&quot;doc/path&quot;, :key =&gt; path)['rows']
-		if dir.nitems &gt; 0
-			return !@db.get(dir[0]['id']).key?(&quot;size&quot;)
-		else
-			return false
-		end
-  end
-
-  def file?(path)
-		dir = @db.view(&quot;doc/path&quot;, :key =&gt; path)['rows']
-		if dir.nitems &gt; 0
-			return @db.get(dir[0]['id']).key?(&quot;size&quot;)
-		else
-			return false
-		end
+if (File.basename($0) == File.basename(__FILE__))
+  if (ARGV.size &lt; 1)
+    puts &quot;Usage: #{$0} &lt;directory&gt; &lt;options&gt;&quot;
+    exit
   end
 
-  def touch(path)
-    write_to(path, &quot;&quot;)
-  end
-  def read_file(path)
-    ret = @db.view(&quot;doc/path&quot;, :key =&gt; path)
-		if ret['rows'].nitems &gt; 0
-			file = @db.get(ret['rows'][0]['id'])
-			if file.key?(&quot;size&quot;)
-				return @db.fetch_attachment(file[&quot;_id&quot;], file[&quot;name&quot;])
-			end
-		end
-		return false
-  end
-  def size(path)
-		ret = @db.view(&quot;doc/path&quot;, :key =&gt; path)
-		if ret['rows'].nitems &gt; 0
-			file = @db.get(ret['rows'][0]['id'])
-			if file.key?(&quot;size&quot;)
-				return file[&quot;size&quot;]
-			else
-				#directory
-				return 0
-			end
-		end
-		return 0
-  end
+  dirname, yamlfile = ARGV.shift, ARGV.shift
 
-  # File writing
-  def can_write?(path)
-		return @db.view(&quot;doc/path&quot;, :key =&gt; path)['rows'].nitems == 0
+  unless File.directory?(dirname)
+    puts &quot;Usage: #{dirname} is not a directory.&quot;
+    exit
   end
-	def write_to(path, body)
-		name = File.basename(path)
-		path_only = path.sub(/#{name}$/, &quot;&quot;)
-    file = {&quot;path&quot; =&gt; path, &quot;base_path&quot; =&gt; path_only, &quot;_attachments&quot; =&gt; { name =&gt; {&quot;data&quot; =&gt; body}}, &quot;name&quot; =&gt; name, &quot;size&quot; =&gt; body.length, &quot;type&quot; =&gt; &quot;f&quot;}
-		@db.save(file)
-	end
 
-  # Delete a file
-  def can_delete?(path)
-		rows = @db.view(&quot;doc/path&quot;, :key =&gt; path)['rows']
-		if rows.nitems &gt; 0
-			file = @db.get(rows[0]['id'])
-			if file.key?(&quot;size&quot;)
-				return true
-			end
-		end
-		false
-  end
-  def delete(path)
-		row = @db.view(&quot;doc/path&quot;, :key =&gt; path)['rows']
-		if row.nitems &gt; 0
-			file = @db.get(row[0]['id'])
-			@db.delete(file)
-		end
-  end
+  root = CouchdbDir.new()
 
-  def can_mkdir?(path)
-		return @db.view(&quot;doc/path&quot;, :key =&gt; path)['rows'].nitems == 0
-  end
-  def mkdir(path)
-		name = File.basename(path)
-		path_only = path.sub(/#{name}$/, &quot;&quot;)
-    dir = {&quot;path&quot; =&gt; path, &quot;base_path&quot; =&gt; path_only, &quot;name&quot; =&gt; name}
-		@db.save(dir)
-	end
+  # Set the root FuseFS
+  FuseFS.set_root(root)
 
-  # rmdir
-  def can_rmdir?(path)
-		if path != &quot;/&quot;
-			if @db.view(&quot;doc/base_path&quot;, :key =&gt; path)['rows'].nitems == 0
-				row = @db.view(&quot;doc/path&quot;, :key =&gt; path)['rows']
-				if row.nitems &gt; 0
-					file = @db.get(row[0]['id'])
-					if !file.key?('size')
-						return true
-					end
-				end
-			end
-		end
-		return false
-  end
-  def rmdir(path)
-    ret = @db.view(&quot;doc/path&quot;, :key =&gt; path)
-		ret.each do |fil|
-			fil.destroy
-		end
-  end
+  FuseFS.mount_under(dirname, *ARGV)
 
-	def delete_db
-		@db.delete!
-	end
+  FuseFS.run # This doesn't return until we're unmounted.
 end
-
-#if (File.basename($0) == File.basename(__FILE__))
-#  if (ARGV.size &lt; 1)
-#    puts &quot;Usage: #{$0} &lt;directory&gt; &lt;options&gt;&quot;
-#    exit
-#  end
-#
-#  dirname, yamlfile = ARGV.shift, ARGV.shift
-#
-#  unless File.directory?(dirname)
-#    puts &quot;Usage: #{dirname} is not a directory.&quot;
-#    exit
-#  end
-#
-#  root = CouchdbDir.new()
-#
-#  # Set the root FuseFS
-#  FuseFS.set_root(root)
-#
-#  FuseFS.mount_under(dirname, *ARGV)
-#
-#  FuseFS.run # This doesn't return until we're unmounted.
-#end</diff>
      <filename>couchdbfs.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 require 'test/unit'
-require 'couchdbfs'
+require 'couchdbfs_lib'
 
 class TestCouchFs &lt; Test::Unit::TestCase
 
@@ -228,9 +228,15 @@ class TestCouchFs &lt; Test::Unit::TestCase
 	#17
 	def test_rmdir
 		test_create_dir_with_file()
+		ret = @root.contents(&quot;/&quot;)
+		assert(ret.include?(&quot;dir_test1&quot;))
 		ret = @root.delete(&quot;/dir_test1/test3&quot;)
 		ret = @root.delete(&quot;/dir_test1/test&quot;)
-		assert(!@root.rmdir?(&quot;/dir_test1&quot;))
+		ret = @root.contents(&quot;/&quot;)
+		assert(ret.include?(&quot;dir_test1&quot;))
+		ret = @root.rmdir(&quot;/dir_test1&quot;)
+		ret = @root.contents(&quot;/&quot;)
+		assert(!ret.include?(&quot;dir_test1&quot;))
 	end
 
   def teardown</diff>
      <filename>couchdbfs_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>4d45a58c0e1fc01ddd50aaf828013cefbe749001</id>
    </parent>
  </parents>
  <author>
    <name>nik</name>
    <email>sacchi.nicola@gmail.com</email>
  </author>
  <url>http://github.com/niky81/couchdbfs/commit/0f1fc175daece32d0b4b0bb16aaed9994d37fbc8</url>
  <id>0f1fc175daece32d0b4b0bb16aaed9994d37fbc8</id>
  <committed-date>2009-03-02T04:58:33-08:00</committed-date>
  <authored-date>2009-03-02T04:58:33-08:00</authored-date>
  <message>not working</message>
  <tree>3046a98a2b9c5184bd12d5e4008591abb8dea1c7</tree>
  <committer>
    <name>nik</name>
    <email>sacchi.nicola@gmail.com</email>
  </committer>
</commit>
