[Bps-public-commit] r11835 - in Prophet/trunk: . t

jesse at bestpractical.com jesse at bestpractical.com
Tue Apr 22 20:34:26 EDT 2008


Author: jesse
Date: Tue Apr 22 20:34:22 2008
New Revision: 11835

Modified:
   Prophet/trunk/   (props changed)
   Prophet/trunk/lib/Prophet/App.pm
   Prophet/trunk/lib/Prophet/CLI.pm
   Prophet/trunk/lib/Prophet/ReplicaExporter.pm
   Prophet/trunk/t/export.t

Log:
 r29980 at 31b:  jesse | 2008-04-22 18:36:07 -0400
 * export cleanups (now export resolutions), no longer export into a uuid dir


Modified: Prophet/trunk/lib/Prophet/App.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/App.pm	(original)
+++ Prophet/trunk/lib/Prophet/App.pm	Tue Apr 22 20:34:22 2008
@@ -17,6 +17,8 @@
 
 sub new {
     my $self = shift->SUPER::new(@_);
+   
+    $self->_load_replica_types();
 
     # Initialize our handle and resolution db handle
     $self->handle;
@@ -25,6 +27,17 @@
     return $self;
 }
 
+sub _load_replica_types {
+    my $self = shift;
+        my $replica_class = ref($self)."::Replica";
+        my $except = $replica_class."::(.*)::";
+        Module::Pluggable->import( search_path => $replica_class, sub_name => 'app_replica_types', require => 0, except => qr/$except/);
+        for my $package ( $self->app_replica_types) {
+            $package->require;
+        Prophet::Replica->register_replica_scheme(scheme => $package->scheme, class => $package) 
+        }
+    }
+
 =head2 handle
 
 

Modified: Prophet/trunk/lib/Prophet/CLI.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI.pm	Tue Apr 22 20:34:22 2008
@@ -15,14 +15,6 @@
     my $self  = $class->SUPER::new(@_);
     $self->record_class('Prophet::Record') unless $self->record_class;
     
-    if($self->app_class) {
-        my $replica_class = $self->app_class."::Replica";
-        my $except = $replica_class."::(.*)::";
-        Module::Pluggable->import( search_path => $replica_class, sub_name => 'app_replica_types', require => 1, except => qr/$except/);
-        Prophet::Replica->register_replica_scheme(scheme => $_->scheme, class => $_) for ( __PACKAGE__->app_replica_types);
-    }
-
-
     my $app_class = $self->app_class || 'Prophet::App';
     $app_class->require();# unless exists $INC{$app_class_path};
     $self->app_handle($app_class->new);

Modified: Prophet/trunk/lib/Prophet/ReplicaExporter.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/ReplicaExporter.pm	(original)
+++ Prophet/trunk/lib/Prophet/ReplicaExporter.pm	Tue Apr 22 20:34:22 2008
@@ -7,8 +7,7 @@
 use Path::Class;
 use UNIVERSAL::require;
 
-__PACKAGE__->mk_accessors(
-    qw( source_replica target_path target_replica));
+__PACKAGE__->mk_accessors(qw( source_replica target_path target_replica));
 
 =head1 NAME
 
@@ -159,28 +158,29 @@
 
     $self->target_replica(
         Prophet::Replica->new(
-            { url => "prophet:file://" . $self->target_path . "/" . $self->source_replica->db_uuid }
+            { url => "prophet:file://" . $self->target_path }
         )
     );
     $self->target_replica->initialize();
     $self->_init_export_metadata();
-    $self->export_records( type => $_ ) for ( @{ $self->source_replica->list_types } );
+    $self->export_records( type => $_ )
+        for ( @{ $self->source_replica->list_types } );
     $self->export_changesets();
 
-    #$self->export_resolutions( path => dir( $fs_root, 'resolutions'), resdb_handle => $args{'resdb_handle'} );
-
-}
-
-sub export_resolutions {
-    my $self    = shift;
-    my $replica = Prophet::Replica->new();
-
-    # ...
+    unless ($self->source_replica->is_resdb) {
+    my $resolutions = Prophet::ReplicaExporter->new(
+        {   target_path => dir($self->target_path, 'resolutions' ),
+            source_replica => $self->source_replica->resolution_db_handle
+        }
+    );
+    $resolutions->export();
+    }
 }
 
 sub _init_export_metadata {
     my $self = shift;
-    $self->target_replica->set_latest_sequence_no( $self->source_replica->latest_sequence_no );
+    $self->target_replica->set_latest_sequence_no(
+        $self->source_replica->latest_sequence_no );
     $self->target_replica->set_replica_uuid( $self->source_replica->uuid );
 
 }
@@ -191,7 +191,8 @@
 
     my $collection = Prophet::Collection->new(
         handle => $self->source_replica,
-        type   => $args{type});
+        type   => $args{type}
+    );
     $collection->matching( sub {1} );
     $self->target_replica->_write_record( record => $_ ) for @$collection;
 
@@ -201,8 +202,13 @@
     my $self = shift;
 
     my $cs_file = $self->target_replica->_get_changeset_index_handle();
-    foreach my $changeset ( @{ $self->source_replica->fetch_changesets( after => 0 ) } ) {
-        $self->target_replica->_write_changeset( index_handle => $cs_file, changeset => $changeset );
+    foreach my $changeset (
+        @{ $self->source_replica->fetch_changesets( after => 0 ) } )
+    {
+        $self->target_replica->_write_changeset(
+            index_handle => $cs_file,
+            changeset    => $changeset
+        );
 
     }
     close($cs_file);

Modified: Prophet/trunk/t/export.t
==============================================================================
--- Prophet/trunk/t/export.t	(original)
+++ Prophet/trunk/t/export.t	Tue Apr 22 20:34:22 2008
@@ -46,7 +46,6 @@
 
     run_ok( 'prophet', [ 'export', '--path', $path ] );
     my $cli = Prophet::CLI->new;
-    $path = $path->subdir( $cli->app_handle->handle->db_uuid );
     ok( -d $path,                       'found db-uuid root ' . $path );
     ok( -e $path->file('replica-uuid'), 'found replica uuid file' );
     lives_and {



More information about the Bps-public-commit mailing list