Index: /trunk/Nebulous/Changes
===================================================================
--- /trunk/Nebulous/Changes	(revision 17447)
+++ /trunk/Nebulous/Changes	(revision 17448)
@@ -1,3 +1,6 @@
 Revision history for Nebulous
+
+0.08
+    - add Nebulous::Client::open() '>' (truncate) mode
 
 0.07
Index: /trunk/Nebulous/lib/Nebulous/Client.pm
===================================================================
--- /trunk/Nebulous/lib/Nebulous/Client.pm	(revision 17447)
+++ /trunk/Nebulous/lib/Nebulous/Client.pm	(revision 17448)
@@ -1,5 +1,5 @@
 # Copyright (c) 2004-2008  Joshua Hoblitt
 #
-# $Id: Client.pm,v 1.41 2008-03-21 01:53:36 jhoblitt Exp $
+# $Id: Client.pm,v 1.42 2008-04-18 00:08:23 jhoblitt Exp $
 
 package Nebulous::Client;
@@ -503,5 +503,5 @@
             type        => SCALAR,
             callbacks   => {
-                'is read or write' => sub { $_[0] =~ /^(?:read|write)$/ },
+                'is read or write' => sub { $_[0] =~ /^(?:read|write|>)$/ },
             },
         },
@@ -538,5 +538,5 @@
     }
 
-    if ( $type eq 'write' ) {
+    if ( $type eq 'write' or $type eq '>' ) {
         my $num_instances = scalar @$locations;
 
@@ -551,4 +551,8 @@
         };
         $log->logdie( $@ ) if $@;
+
+        if ($type eq '>') {
+            truncate($fh, 0) or $log->logdie("truncate failed: $!");
+        }
     } elsif ( $type eq 'read' ) {
         eval {
Index: /trunk/Nebulous/lib/Nebulous/Client.pod
===================================================================
--- /trunk/Nebulous/lib/Nebulous/Client.pod	(revision 17447)
+++ /trunk/Nebulous/lib/Nebulous/Client.pod	(revision 17448)
@@ -285,5 +285,7 @@
 =item * type
 
-The type of lock to acquire.  Either C<read> or C<write>.
+The type of lock to acquire.  One of [C<read>, C<write>, C<>>].
+
+C<>> truncates any pre-existing files to zero length and opens it for writing.
 
 =back
Index: /trunk/Nebulous/t/58_client_open.t
===================================================================
--- /trunk/Nebulous/t/58_client_open.t	(revision 17447)
+++ /trunk/Nebulous/t/58_client_open.t	(revision 17448)
@@ -3,5 +3,5 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 58_client_open.t,v 1.1 2005-12-03 02:52:31 jhoblitt Exp $
+# $Id: 58_client_open.t,v 1.2 2008-04-18 00:08:23 jhoblitt Exp $
 
 use strict;
@@ -10,5 +10,5 @@
 use Apache::Test qw( -withtestmore );
 
-plan tests => 8;
+plan tests => 10;
 
 use lib qw( ./t ./lib );
@@ -17,4 +17,5 @@
 use Nebulous::Util qw( :standard );
 use Test::Nebulous;
+use File::stat;
 
 my $hostport = Apache::Test->config->{ 'hostport' };
@@ -68,4 +69,21 @@
 Test::Nebulous->setup;
 
+# truncation test
+{
+    my $neb = Nebulous::Client->new(
+        proxy => "http://$hostport/nebulous",
+    );
+    my $fh = $neb->open( "foo", 'write' );
+    print $fh "foobar";
+    close $fh;
+
+    $fh = $neb->open( "foo", '>' );
+    ok($fh, "open in trucate mode" );
+    my $sb = stat($fh);
+    is($sb->size, 0, "file was truncated");
+}
+
+Test::Nebulous->setup;
+
 {
     my $neb = Nebulous::Client->new(
