[Bps-public-commit] Prophet branch, master, updated. 2b8ee89bf4792b4ee112ab9b8eab5ca3cc5eb545

jesse jesse at bestpractical.com
Mon Aug 10 08:10:20 EDT 2009


The branch, master has been updated
       via  2b8ee89bf4792b4ee112ab9b8eab5ca3cc5eb545 (commit)
      from  2c14f0773d6f3db89fe75d85de77f093bc7ba803 (commit)

Summary of changes:
 lib/Prophet/App.pm |   27 ++++++++++++++++++++++-----
 lib/Prophet/CLI.pm |    4 +++-
 2 files changed, 25 insertions(+), 6 deletions(-)

- Log -----------------------------------------------------------------
commit 2b8ee89bf4792b4ee112ab9b8eab5ca3cc5eb545
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Mon Aug 10 12:48:40 2009 +0100

    Refactor the replica location docde so we can override/kill it.

diff --git a/lib/Prophet/App.pm b/lib/Prophet/App.pm
index 109bd40..7247911 100644
--- a/lib/Prophet/App.pm
+++ b/lib/Prophet/App.pm
@@ -12,14 +12,14 @@ has handle => (
     default => sub {
         my $self = shift;
 
-        if ( defined $ENV{'PROPHET_REPO'}
-                && $ENV{'PROPHET_REPO'} !~ /^[\w\+]+\:/ ) {
-            my $path = $ENV{PROPHET_REPO};
+        if ( defined $self->local_replica_url
+                && $self->local_replica_url !~ /^[\w\+]+\:/ ) {
+            my $path = $self->local_replica_url;
             $path = File::Spec->rel2abs(glob($path)) unless File::Spec->file_name_is_absolute($path);
-            $ENV{PROPHET_REPO} = "file://$path";
+            $self->local_replica_url("file://$path");
         }
 
-        return Prophet::Replica->get_handle( url =>  $ENV{'PROPHET_REPO'}, app_handle => $self, );
+        return Prophet::Replica->get_handle( url =>  $self->local_replica_url, app_handle => $self, );
     },
 );
 
@@ -69,6 +69,23 @@ sub default_replica_type {
     return $ENV{'PROPHET_REPLICA_TYPE'} || DEFAULT_REPLICA_TYPE;
 }
 
+
+=head2 local_replica_url
+
+Returns the URL of the current local replica. If no URL has been
+provided (usually via C<$ENV{PROPHET_REPO}>), returns undef.
+
+=cut
+
+sub local_replica_url {
+	my $self = shift;
+	if (@_) {
+		$ENV{'PROPHET_REPO'} = shift;
+	}
+
+	return $ENV{'PROPHET_REPO'} || undef;
+}
+
 =head2 require
 
 =cut
diff --git a/lib/Prophet/CLI.pm b/lib/Prophet/CLI.pm
index 5579f96..ffcea01 100644
--- a/lib/Prophet/CLI.pm
+++ b/lib/Prophet/CLI.pm
@@ -88,6 +88,8 @@ sub run_one_command {
     # we need to substitute $1, $2 ... in the value if there's any
 
     my $ori_cmd = join ' ', @args;
+
+	if ($self->app_handle->local_replica_url) {
     my $aliases = $self->app_handle->config->aliases;
     for my $alias ( keys %$aliases ) {
         my $command = $self->_command_matches_alias($ori_cmd, $alias, $aliases->{$alias}) || next;
@@ -97,7 +99,7 @@ sub run_one_command {
         next if ( $command eq $ori_cmd );
         return $self->run_one_command( split /\s+/, $command );
     }
-
+	}
     #  really, we shouldn't be doing this stuff from the command dispatcher
     $self->context( Prophet::CLIContext->new( app_handle => $self->app_handle ) );
     $self->context->setup_from_args(@args);

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



More information about the Bps-public-commit mailing list