[Bps-public-commit] Prophet branch, master, updated. 0598b0a322418b7f930ad870c57e5ac3a819b83e

jesse jesse at bestpractical.com
Tue Jun 9 10:57:14 EDT 2009


The branch, master has been updated
       via  0598b0a322418b7f930ad870c57e5ac3a819b83e (commit)
       via  c8de81c3cf596565ebf94d97117c9a39b9cae5c3 (commit)
      from  9b2440ab3165c32a1ea54f6ca722e76ebf4fe98a (commit)

Summary of changes:
 lib/Prophet/App.pm          |    2 +-
 lib/Prophet/Replica/file.pm |   23 ++++++++++++++---------
 2 files changed, 15 insertions(+), 10 deletions(-)

- Log -----------------------------------------------------------------
commit c8de81c3cf596565ebf94d97117c9a39b9cae5c3
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Tue Jun 9 10:36:05 2009 -0400

    Unify "default_replica_type" codepaths

diff --git a/lib/Prophet/App.pm b/lib/Prophet/App.pm
index 9077d39..71b7e0a 100644
--- a/lib/Prophet/App.pm
+++ b/lib/Prophet/App.pm
@@ -14,7 +14,7 @@ has handle => (
         if   ($ENV{'PROPHET_REPO'} !~ /^[\w\+]+\:/ ) {
             my $path = $ENV{PROPHET_REPO};
             $path = File::Spec->rel2abs(glob($path)) unless File::Spec->file_name_is_absolute($path);
-            $ENV{PROPHET_REPO} = $self->default_replica_type.":file://$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 ec7c42b..b33a6d6 100644
--- a/lib/Prophet/Replica/file.pm
+++ b/lib/Prophet/Replica/file.pm
@@ -14,7 +14,7 @@ sub new {
     my %args = @_;
 
     my @types = ('file','sqlite');
-    unshift @types, $ENV{PROPHET_REPLICA_TYPE} if $ENV{PROPHET_REPLICA_TYPE};
+    unshift @types, $args{app_handle}->default_replica_type;
 
     my @possible;
     for my $type (@types) {

commit 0598b0a322418b7f930ad870c57e5ac3a819b83e
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Tue Jun 9 10:56:18 2009 -0400

    If the replica type can't be probed and we can't init one with the default replica type, explode.
    Any::Moose Replica::file for greater strictness

diff --git a/lib/Prophet/Replica/file.pm b/lib/Prophet/Replica/file.pm
index b33a6d6..6de4e43 100644
--- a/lib/Prophet/Replica/file.pm
+++ b/lib/Prophet/Replica/file.pm
@@ -1,5 +1,6 @@
 package Prophet::Replica::file;
-use base 'Prophet::Replica::prophet';
+use Any::Moose;
+extends 'Prophet::Replica::prophet';
 sub scheme { 'file' }
 
 sub replica_exists {
@@ -12,22 +13,26 @@ sub replica_exists {
 sub new {
     my $class = shift;
     my %args = @_;
+    
+    my @probe_types = ($args{app_handle}->default_replica_type, 'file', 'sqlite');
 
-    my @types = ('file','sqlite');
-    unshift @types, $args{app_handle}->default_replica_type;
-
-    my @possible;
-    for my $type (@types) {
-        my $ret = eval {
+    my %possible;
+    for my $type (@probe_types) {
+        my $ret;
+        eval {
             my $other = "Prophet::Replica::$type";
             Prophet::App->try_to_require($other);
             $ret = $type eq "file" ? $other->SUPER::new(@_) : $other->new(@_);
         };
         next if $@ or not $ret;
         return $ret if $ret->replica_exists;
-        push @possible, $ret;
+        $possible{$type} = $ret;
+    }
+    if (my $default_type =  $possible{$args{app_handle}->default_replica_type} ) { 
+        return $default_type;
+    } else {
+        $class->log_fatal("I don't know what to do with the Prophet replica type you specified: ".$args{app_handle}->default_replica_type);
     }
-    return $possible[0];
 }
 
 1;

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



More information about the Bps-public-commit mailing list