[Bps-public-commit] r11400 - in SVN-PropDB/lib/Prophet: Resolver

clkao at bestpractical.com clkao at bestpractical.com
Wed Apr 2 19:12:32 EDT 2008


Author: clkao
Date: Wed Apr  2 19:12:31 2008
New Revision: 11400

Modified:
   SVN-PropDB/lib/Prophet/CLI.pm
   SVN-PropDB/lib/Prophet/Collection.pm
   SVN-PropDB/lib/Prophet/Resolver/Failed.pm

Log:
record-type handler for cli.

Modified: SVN-PropDB/lib/Prophet/CLI.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/CLI.pm	(original)
+++ SVN-PropDB/lib/Prophet/CLI.pm	Wed Apr  2 19:12:31 2008
@@ -45,6 +45,35 @@
     return $self->_resdb_handle();
 }
 
+=head2 record_cmd
+
+Returns a closure that handles the subcommand for a particular type
+
+=cut
+
+
+our %CMD_MAP = (
+    ls   => 'search',
+    new  => 'create',
+    edit => 'update',
+    rm   => 'delete',
+    del  => 'delete',
+    list => 'search'
+);
+
+sub record_cmd {
+    my ($self, $type) = @_;
+    return sub {
+        my $cmd = shift @ARGV or die "record subcommand required";
+        $cmd =~ s/^--//g;
+        $cmd = $CMD_MAP{$cmd} if exists $CMD_MAP{$cmd};
+        my $func = $self->can("do_$cmd") or die "no such crecord ommand $cmd";
+        $self->type($type);
+        $self->parse_record_cmd_args();
+        $func->($self);
+    };
+}
+
 =head2 parse_args
 
 This routine pulls arguments passed on the command line out of ARGV and sticks them in L</args>. The keys have leading "--" stripped.

Modified: SVN-PropDB/lib/Prophet/Collection.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Collection.pm	(original)
+++ SVN-PropDB/lib/Prophet/Collection.pm	Wed Apr  2 19:12:31 2008
@@ -52,6 +52,8 @@
     return undef unless $self->handle->type_exists( type => $self->type );
 
     # find all items,
+    Carp::cluck unless defined $self->type;
+    
     my $nodes = $self->handle->current_root->dir_entries( $self->handle->db_root . '/' . $self->type . '/' );
 
     # run coderef against each item;

Modified: SVN-PropDB/lib/Prophet/Resolver/Failed.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Resolver/Failed.pm	(original)
+++ SVN-PropDB/lib/Prophet/Resolver/Failed.pm	Wed Apr  2 19:12:31 2008
@@ -8,7 +8,9 @@
     my $self               = shift;
     my $conflicting_change = shift;
     my $conflict           = shift;
-
+    Carp::cluck Dumper($conflict);
+    use Data::Dumper;
+    
     die "The resolution was not resolved. Sorry dude. (Once Prophet works, you should NEVER see this message)";
 }
 



More information about the Bps-public-commit mailing list