[Bps-public-commit] r11255 - in SVN-PropDB: . bin lib/Prophet

jesse at bestpractical.com jesse at bestpractical.com
Fri Mar 28 14:32:23 EDT 2008


Author: jesse
Date: Fri Mar 28 14:32:17 2008
New Revision: 11255

Modified:
   SVN-PropDB/   (props changed)
   SVN-PropDB/bin/prophet-node-create
   SVN-PropDB/bin/prophet-node-delete
   SVN-PropDB/bin/prophet-node-history
   SVN-PropDB/bin/prophet-node-search
   SVN-PropDB/bin/prophet-node-show
   SVN-PropDB/bin/prophet-node-update
   SVN-PropDB/lib/Prophet.pm
   SVN-PropDB/lib/Prophet/CLI.pm
   SVN-PropDB/lib/Prophet/Change.pm
   SVN-PropDB/lib/Prophet/PropChange.pm

Log:
 r28754 at 100:  jesse | 2008-03-28 11:35:16 -0400
 * create, show work now


Modified: SVN-PropDB/bin/prophet-node-create
==============================================================================
--- SVN-PropDB/bin/prophet-node-create	(original)
+++ SVN-PropDB/bin/prophet-node-create	Fri Mar 28 14:32:17 2008
@@ -3,10 +3,9 @@
 use strict;
 
 use Prophet::CLI;
-my $prophet = Prophet->new();
-my $cli_handle = Prophet::CLI->new();
-$cli_handle->parse_record_cmd_args();
+my $cli = Prophet::CLI->new();
+$cli->parse_record_cmd_args();
 
-my $record = Prophet::Record->new(handle => $prophet->handle, type => $cli_handle->type);
-my ($id, $results)= $record->create( props => $cli_handle->args);
-print "Created $type ".$record->uuid."\n";
+my $record = Prophet::Record->new(handle => $cli->handle, type => $cli->type);
+my ($id, $results)= $record->create( props => $cli->args);
+print "Created ". $cli->type." ".$record->uuid."\n";

Modified: SVN-PropDB/bin/prophet-node-delete
==============================================================================
--- SVN-PropDB/bin/prophet-node-delete	(original)
+++ SVN-PropDB/bin/prophet-node-delete	Fri Mar 28 14:32:17 2008
@@ -2,13 +2,13 @@
 use warnings;
 use strict;
 
+
 use Prophet::CLI;
-my $prophet = Prophet->new();
-my $cli_handle = Prophet::CLI->new();
-$cli_handle->parse_record_cmd_args();
+my $cli = Prophet::CLI->new();
+$cli->parse_record_cmd_args();
 
-my $record = Prophet::Record->new( handle => $prophet->handle);
-$record->load(uuid => $cli_handle->uuid;
+my $record = Prophet::Record->new(handle => $cli->handle, type => $cli->type);
+$record->load(uuid => $cli->uuid)
 if( $record->delete ) {
     print $record->type." ".$record->uuid." deleted.\n";
 } else {

Modified: SVN-PropDB/bin/prophet-node-history
==============================================================================
--- SVN-PropDB/bin/prophet-node-history	(original)
+++ SVN-PropDB/bin/prophet-node-history	Fri Mar 28 14:32:17 2008
@@ -3,14 +3,11 @@
 use strict;
 
 use Prophet::CLI;
-my $prophet = Prophet->new();
-my $cli_handle = Prophet::CLI->new();
-$cli_handle->parse_record_cmd_args();
+my $cli = Prophet::CLI->new();
+$cli->parse_record_cmd_args();
 
-my $record = Prophet::Record->new(handle => $prophet->handle, type => $cli_handle->type);
-
-
-$record->load(uuid => $cli_handle->uuid);
+my $record = Prophet::Record->new(handle => $cli->handle, type => $cli->type);
+$record->load(uuid => $cli->uuid);
 
 print "id: ".$record->uuid."\n";
 my $props = $record->get_props();

Modified: SVN-PropDB/bin/prophet-node-search
==============================================================================
--- SVN-PropDB/bin/prophet-node-search	(original)
+++ SVN-PropDB/bin/prophet-node-search	Fri Mar 28 14:32:17 2008
@@ -2,12 +2,17 @@
 use warnings;
 use strict;
 
-unless  ($regex = $cli_handle->args->{regex}) {
+
+use Prophet::CLI;
+my $cli = Prophet::CLI->new();
+$cli->parse_record_cmd_args();
+my $regex;
+unless  ($regex = $cli->args->{regex}) {
    die "Specify a regular expression and we'll search for records matching that regex"
 }
 
 
-my $records = Prophet::Collection->new(handle => $svb->handle, type => $cli_handle->type);
+my $records = Prophet::Collection->new(handle => $cli->handle, type => $cli->type);
 $records->matching( sub {
             my $item = shift; 
             my $props = $item->get_props;

Modified: SVN-PropDB/bin/prophet-node-show
==============================================================================
--- SVN-PropDB/bin/prophet-node-show	(original)
+++ SVN-PropDB/bin/prophet-node-show	Fri Mar 28 14:32:17 2008
@@ -3,13 +3,11 @@
 use strict;
 
 use Prophet::CLI;
-my $prophet = Prophet->new();
-my $cli_handle = Prophet::CLI->new();
-$cli_handle->parse_record_cmd_args();
-
-my $record = Prophet::Record->new(handle => $prophet->handle, type => $cli_handle->type);
-
-$record->load(uuid => $cli_handle->uuid);
+my $cli = Prophet::CLI->new();
+$cli->parse_record_cmd_args();
+my $record = Prophet::Record->new(handle => $cli->handle, type => $cli->type);
+warn "Loading ".$cli->uuid;
+$record->load(uuid => $cli->uuid);
 print "id: ".$record->uuid."\n";
 my $props = $record->get_props();
 for (keys %$props) {

Modified: SVN-PropDB/bin/prophet-node-update
==============================================================================
--- SVN-PropDB/bin/prophet-node-update	(original)
+++ SVN-PropDB/bin/prophet-node-update	Fri Mar 28 14:32:17 2008
@@ -3,13 +3,10 @@
 use strict;
 
 use Prophet::CLI;
-my $prophet = Prophet->new();
-my $cli_handle = Prophet::CLI->new();
-$cli_handle->parse_record_cmd_args();
-
-my $record = Prophet::Record->new(handle => $prophet->handle, type => $cli_handle->type);
-
-$record->load(uuid => $cli_handle->uuid);
+my $cli = Prophet::CLI->new();
+$cli->parse_record_cmd_args();
+my $record = Prophet::Record->new(handle => $cli->handle, type => $cli->type);
+$record->load(uuid => $cli->uuid);
 $record->set_props(props => $prophet->args);
    
 warn "We want more feedback here";

Modified: SVN-PropDB/lib/Prophet.pm
==============================================================================
--- SVN-PropDB/lib/Prophet.pm	(original)
+++ SVN-PropDB/lib/Prophet.pm	Fri Mar 28 14:32:17 2008
@@ -4,4 +4,34 @@
 package Prophet;
 
 our $VERSION = '0.01';
+
+=head1 NAME
+
+Prophet
+
+=head1 DESCRIPTION
+
+Prophet is a distributed database system designed for small to medium scale database applications (currently up to around 50,000 records of a given type).
+Our early targets include things such as bug tracking.
+
+=head2 Design goals
+
+=head3 Arbitrary record schema
+
+=head3 Replication
+
+=head3 Disconnected operation
+
+=head3 Peer to peer synchronization
+
+
+
+=head2 Design constraints
+
+=head3 Scaling
+
+We don't currently intend for the first implementation of Prophet to scale to databases with millions of rows or hundreds of concurrent users. There's nothing that makes the design infeasible, but the infrastructure necessary for such a system will...needlessly hamstring it.
+
+=cut
+
 1;

Modified: SVN-PropDB/lib/Prophet/CLI.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/CLI.pm	(original)
+++ SVN-PropDB/lib/Prophet/CLI.pm	Fri Mar 28 14:32:17 2008
@@ -3,8 +3,32 @@
 
 package Prophet::CLI;
 use base qw/Class::Accessor/;
-__PACKAGE__->mk_accessors(qw/type uuid/);
+__PACKAGE__->mk_accessors(qw/type uuid _handle/);
+
+use Path::Class;
 use Prophet;
+use Prophet::Handle;
+use Prophet::Record;
+use Prophet::Collection;
+
+
+=head2 handle
+
+
+=cut
+
+sub handle {
+    my $self = shift;
+    unless ($self->_handle) {
+    my $root = $ENV{'PROPHET_ROOT'} || dir($ENV{'HOME'},'.prophet');
+    my $path = $ENV{'PROPHET_REPO_PATH'} ||'_prophet';
+    $self->_handle( Prophet::Handle->new( repository => $root, db_root => $path ));
+
+    }
+    return $self->_handle();
+}
+
+
 
 =head2 parse_args
 
@@ -15,8 +39,8 @@
 
 sub parse_args {
     my $self = shift;
-    $self->{args} = @ARGV;
-    for my $name ( keys $self->{'args'} ) {
+    %{$self->{'args'}} = @ARGV;
+    for my $name ( keys %{$self->{'args'}} ) {
         die "$name doesn't look like --prop-name" if ( $name !~ /^--/ );
         $name =~ /^--(.*)$/;
         $self->{args}->{$1} = delete $self->{'args'}->{$name};
@@ -35,7 +59,7 @@
     $self->parse_args();
 
     if ( my $uuid = delete $self->{args}->{uuid} ) {
-        $self->type( $uuid);
+        $self->uuid( $uuid);
     }
     if ( $self->{args}->{type} ) {
         $self->type( delete $self->{args}->{'type'} );

Modified: SVN-PropDB/lib/Prophet/Change.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Change.pm	(original)
+++ SVN-PropDB/lib/Prophet/Change.pm	Fri Mar 28 14:32:17 2008
@@ -9,16 +9,50 @@
 use Params::Validate;
 __PACKAGE__->mk_accessors(qw/node_type node_uuid change_type/);
 
+=head1 NAME
+
+Prophet::Change
+
+=head1 DESCRIPTION
+
+This class encapsulates a change to a single node in a Prophet replica.
+
+=head1 METHODS
+
+=head2 node_type
+
+The record type for the node.
+
+=head2 node_uuid
+
+The UUID of the node being changed
+
+=head2 change_type
+
+One of create_file, add_dir, update_file, delete
+XXX TODO is it create_file or add_file?
+
+=head2 prop_changes
+
+Returns a list of L<Prophet::PropChange/> associated with this Change
+
+=cut
 
-# Valid values for change_type:
-# add_file add_dir update_file delete
-#
 
 sub prop_changes {
     my $self = shift;
     return @{$self->{prop_changes}};
 }
 
+
+=head2 add_prop_change { new => __, old => ___, name => ___ }
+
+Adds a new L<Prophet::PropChange> to this L<Prophet::Change>.
+
+Takes a C<name>, and the C<old> and C<new> values.
+
+=cut
+
 sub add_prop_change {
     my $self = shift;
     my %args = validate(@_, { name => 1, old => 0, new => 0 } );

Modified: SVN-PropDB/lib/Prophet/PropChange.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/PropChange.pm	(original)
+++ SVN-PropDB/lib/Prophet/PropChange.pm	Fri Mar 28 14:32:17 2008
@@ -5,5 +5,29 @@
 
 __PACKAGE__->mk_accessors(qw/name old_value new_value/);
 
+=head1 NAME
+
+Prophet::PropChange
+
+=head1 DESCRIPTION
+
+This class encapsulates a single property change. 
+
+=head1 METHODS
+
+=head2 name
+
+The name of the property we're talking about.
+
+=head2 old_value
+
+What L</name> changed I<from>.
+
+=head2 new_value
+
+What L</name> changed I<to>.
+
+
+=cut
 
 1;



More information about the Bps-public-commit mailing list