[Bps-public-commit] Prophet branch, master, updated. 6775dd19eb09519d479f4c721653a041b17313b6

Alex M Vandiver alexmv at bestpractical.com
Mon Apr 27 12:56:34 EDT 2009


The branch, master has been updated
       via  6775dd19eb09519d479f4c721653a041b17313b6 (commit)
      from  32408431194e3c5041db8261358f18022e957e7f (commit)

Summary of changes:
 lib/Prophet/App.pm          |   14 ++++----------
 lib/Prophet/Replica/file.pm |   17 ++++++++++++++++-
 2 files changed, 20 insertions(+), 11 deletions(-)

- Log -----------------------------------------------------------------
commit 6775dd19eb09519d479f4c721653a041b17313b6
Author: Alex Vandiver <alexmv at mit.edu>
Date:   Mon Apr 27 12:56:27 2009 -0400

    file:// replicas auto-detect sqlite vs prophet replica types

diff --git a/lib/Prophet/App.pm b/lib/Prophet/App.pm
index 9f09765..b696c85 100644
--- a/lib/Prophet/App.pm
+++ b/lib/Prophet/App.pm
@@ -12,19 +12,13 @@ has handle => (
         my $self = shift;
 
         if ( ! $ENV{PROPHET_REPO}) { 
-            my $type = $self->default_replica_type;
-            $ENV{'PROPHET_REPO'} = $type.":file://".File::Spec->catdir($ENV{'HOME'}, '.prophet');
+            $ENV{'PROPHET_REPO'} = "file://".File::Spec->catdir($ENV{'HOME'}, '.prophet');
 
         }
         elsif   ($ENV{'PROPHET_REPO'} !~ /^[\w\+]+\:/ ) {
-            if ( !File::Spec->file_name_is_absolute($ENV{'PROPHET_REPO'}) ) {
-            # if PROPHET_REPO env var exists and is relative, make it absolute
-            # to avoid breakage/confusing error messages later
-            $ENV{'PROPHET_REPO'} = $self->default_replica_type . ":file://".  File::Spec->rel2abs(glob($ENV{'PROPHET_REPO'}));
-
-            } else {
-            $ENV{'PROPHET_REPO'} = $self->default_replica_type . ":file://".  $ENV{'PROPHET_REPO'};
-            }
+            my $path = $ENV{PROPHET_REPO};
+            $path = File::Spec->rel2abs(glob($path)) unless File::Spec->file_name_is_absolute($path);
+            $ENV{PROPHET_REPO} = "file://$path";
         }
 
         return Prophet::Replica->get_handle( url =>  $ENV{'PROPHET_REPO'}, app_handle => $self, );
diff --git a/lib/Prophet/Replica/file.pm b/lib/Prophet/Replica/file.pm
index ebab005..c60d150 100644
--- a/lib/Prophet/Replica/file.pm
+++ b/lib/Prophet/Replica/file.pm
@@ -1,5 +1,20 @@
 package Prophet::Replica::file;
 use base 'Prophet::Replica::prophet';
-sub scheme { 'file'}
+sub scheme { 'file' }
+
+sub new {
+    my $class = shift;
+    my %args = @_;
+
+    for (qw/sqlite prophet/) {
+        my $ret = eval {
+            my $other = "Prophet::Replica::$_";
+            Prophet::App->require($other);
+            $ret = $other->new(@_);
+        };
+        return $ret if not $@ and $ret and $ret->replica_exists;
+    }
+    return $class->SUPER::new(@_);
+}
 
 1;

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list