[Bps-public-commit] r15397 - in Prophet/trunk: lib/Prophet/CLI lib/Prophet/Replica t

jesse at bestpractical.com jesse at bestpractical.com
Fri Aug 22 20:40:17 EDT 2008


Author: jesse
Date: Fri Aug 22 20:40:15 2008
New Revision: 15397

Modified:
   Prophet/trunk/lib/Prophet/CLI.pm
   Prophet/trunk/lib/Prophet/CLI/RecordCommand.pm
   Prophet/trunk/lib/Prophet/Record.pm
   Prophet/trunk/lib/Prophet/Replica.pm
   Prophet/trunk/lib/Prophet/Replica/prophet.pm
   Prophet/trunk/lib/Prophet/Replica/svn.pm
   Prophet/trunk/lib/Prophet/ReplicaExporter.pm
   Prophet/trunk/lib/Prophet/Server.pm
   Prophet/trunk/lib/Prophet/Test.pm
   Prophet/trunk/t/luid.t
   Prophet/trunk/t/resty-server.t

Log:
* more delay-loading 

Modified: Prophet/trunk/lib/Prophet/CLI.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI.pm	Fri Aug 22 20:40:15 2008
@@ -3,8 +3,6 @@
 use MooseX::ClassAttribute;
 
 use Prophet;
-use Prophet::Record;
-use Prophet::Collection;
 use Prophet::Replica;
 use Prophet::CLI::Command;
 
@@ -19,6 +17,7 @@
 has record_class => (
     is      => 'rw',
     isa     => 'ClassName',
+    lazy    => 1,
     default => 'Prophet::Record',
 );
 

Modified: Prophet/trunk/lib/Prophet/CLI/RecordCommand.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/RecordCommand.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI/RecordCommand.pm	Fri Aug 22 20:40:15 2008
@@ -1,6 +1,8 @@
 package Prophet::CLI::RecordCommand;
 use Moose::Role;
 use Params::Validate;
+use Prophet::Record;
+
 
 has type => (
     is        => 'rw',

Modified: Prophet/trunk/lib/Prophet/Record.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Record.pm	(original)
+++ Prophet/trunk/lib/Prophet/Record.pm	Fri Aug 22 20:40:15 2008
@@ -2,7 +2,6 @@
 use Moose;
 use MooseX::ClassAttribute;
 use Params::Validate;
-use Data::UUID;
 use Prophet::App; # for require_module. Kinda hacky
 
 use constant collection_class => 'Prophet::Collection';
@@ -68,7 +67,13 @@
     documentation => 'A hash of properties that a record class declares.',
 );
 
-my $UUIDGEN = Data::UUID->new();
+
+class_has uuid_generator => (
+    is => 'ro',
+    isa => 'Data::UUID',
+    lazy => 1,
+    default => sub { require Data::UUID; Data::UUID->new()}
+);
 
 =head1 METHODS
 
@@ -212,7 +217,7 @@
 sub create {
     my $self = shift;
     my %args = validate( @_, { props => 1 } );
-    my $uuid = $UUIDGEN->create_str;
+    my $uuid = $self->uuid_generator->create_str;
 
     $self->default_props($args{'props'});
     $self->canonicalize_props( $args{'props'} );

Modified: Prophet/trunk/lib/Prophet/Replica.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Replica.pm	(original)
+++ Prophet/trunk/lib/Prophet/Replica.pm	Fri Aug 22 20:40:15 2008
@@ -392,7 +392,7 @@
 sub conflicts_from_changeset {
     my $self = shift;
     my ($changeset) = validate_pos( @_, { isa => "Prophet::ChangeSet" } );
-
+    require Prophet::Conflict;
     my $conflict = Prophet::Conflict->new( { changeset => $changeset,
                                              prophet_handle => $self} );
 
@@ -966,6 +966,7 @@
     my $self = shift;
     my ( $name, $source_uuid, $prop_name ) = validate_pos( @_, 1, 1, 1 );
 
+    require Prophet::Record;
     my $entry = Prophet::Record->new( handle => $self, type => $name );
     unless ( $entry->load( uuid => $source_uuid )) {
         return undef;

Modified: Prophet/trunk/lib/Prophet/Replica/prophet.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Replica/prophet.pm	(original)
+++ Prophet/trunk/lib/Prophet/Replica/prophet.pm	Fri Aug 22 20:40:15 2008
@@ -9,7 +9,6 @@
 use JSON;
 
 use Prophet::ChangeSet;
-use Prophet::Conflict;
 
 has '+db_uuid' => (
     lazy    => 1,

Modified: Prophet/trunk/lib/Prophet/Replica/svn.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Replica/svn.pm	(original)
+++ Prophet/trunk/lib/Prophet/Replica/svn.pm	Fri Aug 22 20:40:15 2008
@@ -5,7 +5,6 @@
 
 # require rather than use to make them late-binding
 use Prophet::ChangeSet;
-use Prophet::Conflict;
 
 has ra => (
     is      => 'rw',

Modified: Prophet/trunk/lib/Prophet/ReplicaExporter.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/ReplicaExporter.pm	(original)
+++ Prophet/trunk/lib/Prophet/ReplicaExporter.pm	Fri Aug 22 20:40:15 2008
@@ -2,6 +2,8 @@
 use Moose;
 use Params::Validate qw(:all);
 use Path::Class;
+use Prophet::Record;
+use Prophet::Collection;
 
 has source_replica => (
     is  => 'rw',

Modified: Prophet/trunk/lib/Prophet/Server.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Server.pm	(original)
+++ Prophet/trunk/lib/Prophet/Server.pm	Fri Aug 22 20:40:15 2008
@@ -105,6 +105,7 @@
 
     elsif ( $p =~ m|^/records/(.*).json| ) {
         my $type = $1;
+        require Prophet::Collection;
         my $col = Prophet::Collection->new( handle => $self->handle, type => $type );
         $col->matching( sub {1} );
         warn "Query language not implemented yet.";
@@ -152,7 +153,7 @@
 sub load_record {
     my $self = shift;
     my %args = validate( @_, { type => 1, uuid => 0 } );
-
+    require Prophet::Record;
     my $record = Prophet::Record->new( handle => $self->handle, type => $args{type} );
     if ( $args{'uuid'} ) {
         return undef unless ( $self->handle->record_exists( type => $args{'type'}, uuid => $args{'uuid'} ) );

Modified: Prophet/trunk/lib/Prophet/Test.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Test.pm	(original)
+++ Prophet/trunk/lib/Prophet/Test.pm	Fri Aug 22 20:40:15 2008
@@ -267,6 +267,7 @@
 sub replica_merge_tickets {
     my $self    = shift;
     my $cli     = Prophet::CLI->new();
+    require Prophet::Collection;
     my $tickets = Prophet::Collection->new( handle => $cli->handle, type => $Prophet::Replica::MERGETICKET_METATYPE );
     $tickets->matching( sub {1} );
     return { map { $_->uuid => $_->prop('last-changeset') } $tickets->items };
@@ -391,7 +392,7 @@
     sub load_record {
         my $type = shift;
         my $uuid = shift;
-
+        require Prophet::Record;
         my $record = Prophet::Record->new(handle => $connection, type => $type);
         $record->load(uuid => $uuid);
         return $record;

Modified: Prophet/trunk/t/luid.t
==============================================================================
--- Prophet/trunk/t/luid.t	(original)
+++ Prophet/trunk/t/luid.t	Fri Aug 22 20:40:15 2008
@@ -1,10 +1,11 @@
 use warnings;
 use strict;
-use Test::More tests => 10;
+use Test::More tests => 11;
 
 use File::Temp qw'tempdir';
 
 use_ok('Prophet::CLI');
+use_ok('Prophet::Record');
 $ENV{'PROPHET_REPO'} = tempdir( CLEANUP => 0 ) . '/repo-' . $$;
 $ENV{'PROPHET_METADATA_DIRECTORY'} = tempdir( CLEANUP => 0 ) . '/repo-' . $$;
 

Modified: Prophet/trunk/t/resty-server.t
==============================================================================
--- Prophet/trunk/t/resty-server.t	(original)
+++ Prophet/trunk/t/resty-server.t	Fri Aug 22 20:40:15 2008
@@ -8,10 +8,12 @@
 
 }
 
-use Prophet::Test tests => 25;
+use Prophet::Test tests => 26;
 use Test::WWW::Mechanize;
 use JSON;
 
+use_ok('Prophet::Record');
+
 my $ua  = Test::WWW::Mechanize->new();
 my $cli = Prophet::CLI->new();
 my $s   = Prophet::TestServer->new();



More information about the Bps-public-commit mailing list