[Bps-public-commit] r14941 - in Prophet/trunk: . lib/Prophet lib/Prophet/CLI lib/Prophet/CLI/Command lib/Prophet/Test
sartak at bestpractical.com
sartak at bestpractical.com
Sat Aug 9 12:17:49 EDT 2008
Author: sartak
Date: Sat Aug 9 12:17:49 2008
New Revision: 14941
Modified:
Prophet/trunk/ (props changed)
Prophet/trunk/lib/Prophet/CLI.pm
Prophet/trunk/lib/Prophet/CLI/CollectionCommand.pm
Prophet/trunk/lib/Prophet/CLI/Command.pm
Prophet/trunk/lib/Prophet/CLI/Command/Config.pm
Prophet/trunk/lib/Prophet/CLI/Command/Export.pm
Prophet/trunk/lib/Prophet/CLI/Command/Merge.pm
Prophet/trunk/lib/Prophet/CLI/Command/Publish.pm
Prophet/trunk/lib/Prophet/CLI/Command/Pull.pm
Prophet/trunk/lib/Prophet/CLI/Command/Push.pm
Prophet/trunk/lib/Prophet/CLI/RecordCommand.pm
Prophet/trunk/lib/Prophet/ForeignReplica.pm
Prophet/trunk/lib/Prophet/Server.pm
Prophet/trunk/lib/Prophet/Test.pm
Prophet/trunk/lib/Prophet/Test/Arena.pm
Prophet/trunk/lib/Prophet/Test/Participant.pm
Prophet/trunk/t/canonicalize.t
Prophet/trunk/t/config.t
Prophet/trunk/t/create.t
Prophet/trunk/t/default.t
Prophet/trunk/t/export.t
Prophet/trunk/t/generalized_sync_n_merge.t
Prophet/trunk/t/history.t
Prophet/trunk/t/luid.t
Prophet/trunk/t/publish-pull.t
Prophet/trunk/t/resty-server.t
Prophet/trunk/t/validate.t
Prophet/trunk/t/validation.t
Log:
r68995 at onn: sartak | 2008-08-09 12:17:29 -0400
Install delegation so $cmd->cli->app_handle->handle becomes just $cmd->handle
Modified: Prophet/trunk/lib/Prophet/CLI.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI.pm (original)
+++ Prophet/trunk/lib/Prophet/CLI.pm Sat Aug 9 12:17:49 2008
@@ -26,6 +26,7 @@
is => 'rw',
isa => 'Prophet::App',
lazy => 1,
+ handles => [qw/handle resdb_handle config/],
default => sub {
$_[0]->app_class->require;
return $_[0]->app_class->new;
@@ -121,7 +122,7 @@
sub _get_cmd_obj {
my $self = shift;
- my $aliases = $self->app_handle->config->aliases;
+ my $aliases = $self->config->aliases;
my $tmp = $self->primary_commands;
if (@$tmp && $aliases->{$tmp->[0]}) {
@ARGV = split ' ', $aliases->{$tmp->[0]};
@@ -307,7 +308,7 @@
$self->uuid($uuid);
}
elsif ( my $luid = $self->delete_arg('luid')) {
- my $uuid = $self->app_handle->handle->find_uuid_by_luid(luid => $luid);
+ my $uuid = $self->handle->find_uuid_by_luid(luid => $luid);
die "I have no UUID mapped to the local id '$luid'\n" if !defined($uuid);
$self->uuid($uuid);
}
Modified: Prophet/trunk/lib/Prophet/CLI/CollectionCommand.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/CollectionCommand.pm (original)
+++ Prophet/trunk/lib/Prophet/CLI/CollectionCommand.pm Sat Aug 9 12:17:49 2008
@@ -16,7 +16,7 @@
my $records = $class->new(
app_handle => $self->app_handle,
- handle => $self->app_handle->handle,
+ handle => $self->handle,
type => $args{type} || $self->type,
);
Modified: Prophet/trunk/lib/Prophet/CLI/Command.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command.pm (original)
+++ Prophet/trunk/lib/Prophet/CLI/Command.pm Sat Aug 9 12:17:49 2008
@@ -8,7 +8,8 @@
handles => [
qw/args set_arg arg has_arg delete_arg arg_names/,
qw/props set_prop prop has_prop delete_prop prop_names/,
- 'prop_set', 'app_handle', 'run_one_command', 'run_another_command',
+ qw/app_handle handle resdb_handle config/,
+ 'prop_set', 'run_one_command', 'run_another_command',
],
);
Modified: Prophet/trunk/lib/Prophet/CLI/Command/Config.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command/Config.pm (original)
+++ Prophet/trunk/lib/Prophet/CLI/Command/Config.pm Sat Aug 9 12:17:49 2008
@@ -6,13 +6,13 @@
my $self = shift;
- my $config = $self->app_handle->config;
+ my $config = $self->config;
print "Configuration:\n\n";
my @files =@{$config->config_files};
if (!scalar @files) {
print "No configuration files found. ".
- " Either create a file called 'prophetrc' inside of ". $self->app_handle->handle->fs_root ." or set the PROPHET_APP_CONFIG environement variable.\n\n";
+ " Either create a file called 'prophetrc' inside of ". $self->handle->fs_root ." or set the PROPHET_APP_CONFIG environement variable.\n\n";
return;
}
for my $file (@files) {
Modified: Prophet/trunk/lib/Prophet/CLI/Command/Export.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command/Export.pm (original)
+++ Prophet/trunk/lib/Prophet/CLI/Command/Export.pm Sat Aug 9 12:17:49 2008
@@ -5,7 +5,7 @@
sub run {
my $self = shift;
- $self->app_handle->handle->export_to( path => $self->arg('path') );
+ $self->handle->export_to( path => $self->arg('path') );
}
__PACKAGE__->meta->make_immutable;
Modified: Prophet/trunk/lib/Prophet/CLI/Command/Merge.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command/Merge.pm (original)
+++ Prophet/trunk/lib/Prophet/CLI/Command/Merge.pm Sat Aug 9 12:17:49 2008
@@ -75,7 +75,7 @@
my %import_args = (
from => $source,
- resdb => $self->app_handle->resdb_handle,
+ resdb => $self->resdb_handle,
force => $self->has_arg('force'),
);
Modified: Prophet/trunk/lib/Prophet/CLI/Command/Publish.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command/Publish.pm (original)
+++ Prophet/trunk/lib/Prophet/CLI/Command/Publish.pm Sat Aug 9 12:17:49 2008
@@ -103,7 +103,7 @@
my $self = shift;
return grep { !$self->should_skip_type($_) }
- @{ $self->app_handle->handle->list_types };
+ @{ $self->handle->list_types };
}
__PACKAGE__->meta->make_immutable;
Modified: Prophet/trunk/lib/Prophet/CLI/Command/Pull.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command/Pull.pm (original)
+++ Prophet/trunk/lib/Prophet/CLI/Command/Pull.pm Sat Aug 9 12:17:49 2008
@@ -6,7 +6,7 @@
my $self = shift;
my @from;
- $self->set_arg( db_uuid => $self->app_handle->handle->db_uuid )
+ $self->set_arg( db_uuid => $self->handle->db_uuid )
unless ($self->arg('db_uuid'));
my %previous_sources = $self->_read_cached_upstream_replicas;
@@ -23,7 +23,7 @@
$self->set_arg( to => $self->cli->app_handle->default_replica_type
. ":file://"
- . $self->cli->app_handle->handle->fs_root );
+ . $self->handle->fs_root );
for my $from ( @from, @bonjour_replicas ) {
print "Pulling from $from\n";
@@ -81,7 +81,7 @@
sub _read_cached_upstream_replicas {
my $self = shift;
- return map { $_ => 1 } $self->cli->app_handle->handle->_read_cached_upstream_replicas;
+ return map { $_ => 1 } $self->handle->_read_cached_upstream_replicas;
}
=head2 _write_cached_upstream_replicas %replicas
@@ -95,7 +95,7 @@
sub _write_cached_upstream_replicas {
my $self = shift;
my %repos = @_;
- return $self->cli->app_handle->handle->_write_cached_upstream_replicas(keys %repos);
+ return $self->handle->_write_cached_upstream_replicas(keys %repos);
}
__PACKAGE__->meta->make_immutable;
Modified: Prophet/trunk/lib/Prophet/CLI/Command/Push.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command/Push.pm (original)
+++ Prophet/trunk/lib/Prophet/CLI/Command/Push.pm Sat Aug 9 12:17:49 2008
@@ -7,8 +7,8 @@
die "Please specify a --to.\n" if !$self->has_arg('to');
- $self->set_arg(from => $self->app_handle->default_replica_type.":file://".$self->app_handle->handle->fs_root);
- $self->set_arg(db_uuid => $self->app_handle->handle->db_uuid);
+ $self->set_arg(from => $self->app_handle->default_replica_type.":file://".$self->handle->fs_root);
+ $self->set_arg(db_uuid => $self->handle->db_uuid);
};
__PACKAGE__->meta->make_immutable;
Modified: Prophet/trunk/lib/Prophet/CLI/RecordCommand.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/RecordCommand.pm (original)
+++ Prophet/trunk/lib/Prophet/CLI/RecordCommand.pm Sat Aug 9 12:17:49 2008
@@ -37,7 +37,7 @@
my $constructor_args = {
app_handle => $self->cli->app_handle,
- handle => $self->cli->app_handle->handle,
+ handle => $self->cli->handle,
type => $args{type},
};
Modified: Prophet/trunk/lib/Prophet/ForeignReplica.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/ForeignReplica.pm (original)
+++ Prophet/trunk/lib/Prophet/ForeignReplica.pm Sat Aug 9 12:17:49 2008
@@ -16,7 +16,7 @@
my $cli = Prophet::CLI->new();
# XXX TODO this $cli object should be a Prophet::App object
- my $state_handle_url = $cli->app_handle->default_replica_type . ":" . $cli->app_handle->handle->url;
+ my $state_handle_url = $cli->app_handle->default_replica_type . ":" . $handle->url;
$self->log( "Connecting to state database ".$state_handle_url);
$self->state_handle(
Prophet::Replica->new(
Modified: Prophet/trunk/lib/Prophet/Server.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Server.pm (original)
+++ Prophet/trunk/lib/Prophet/Server.pm Sat Aug 9 12:17:49 2008
@@ -57,9 +57,9 @@
if ($p =~ qr{^/+replica/+(.*)$}) {
my $repo_file = $1;
my $file_obj = file($repo_file);
- return undef unless $self->app_handle->handle->can('read_file');
+ return undef unless $self->handle->can('read_file');
- my $content =$self->app_handle->handle->read_file($repo_file);
+ my $content = $self->handle->read_file($repo_file);
return unless length($content);
return $self->_send_content(
content_type => 'application/prophet-needs-a-better-type',
@@ -81,7 +81,7 @@
if ( $p =~ m|^/records\.json$| ) {
$self->_send_content(
content_type => 'text/x-json',
- content => to_json( $self->app_handle->handle->list_types )
+ content => to_json( $self->handle->list_types )
);
} elsif ( $p =~ m|^/records/(.*)/(.*)/(.*)| ) {
@@ -107,7 +107,7 @@
elsif ( $p =~ m|^/records/(.*).json| ) {
my $type = $1;
- my $col = Prophet::Collection->new( handle => $self->app_handle->handle, type => $type );
+ my $col = Prophet::Collection->new( handle => $self->handle, type => $type );
$col->matching( sub {1} );
warn "Query language not implemented yet.";
return $self->_send_content(
@@ -152,9 +152,9 @@
my $self = shift;
my %args = validate( @_, { type => 1, uuid => 0 } );
- my $record = Prophet::Record->new( handle => $self->app_handle->handle, type => $args{type} );
+ my $record = Prophet::Record->new( handle => $self->handle, type => $args{type} );
if ( $args{'uuid'} ) {
- return undef unless ( $self->app_handle->handle->record_exists( type => $args{'type'}, uuid => $args{'uuid'} ) );
+ return undef unless ( $self->handle->record_exists( type => $args{'type'}, uuid => $args{'uuid'} ) );
$record->load( uuid => $args{uuid} );
}
return $record;
Modified: Prophet/trunk/lib/Prophet/Test.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Test.pm (original)
+++ Prophet/trunk/lib/Prophet/Test.pm Sat Aug 9 12:17:49 2008
@@ -243,13 +243,13 @@
sub replica_uuid {
my $self = shift;
my $cli = Prophet::CLI->new();
- return $cli->app_handle->handle->uuid;
+ return $cli->handle->uuid;
}
sub database_uuid {
my $self = shift;
my $cli = Prophet::CLI->new();
- return $cli->app_handle->handle->db_uuid;
+ return $cli->handle->db_uuid;
}
=head2 replica_merge_tickets
@@ -265,7 +265,7 @@
sub replica_merge_tickets {
my $self = shift;
my $cli = Prophet::CLI->new();
- my $tickets = Prophet::Collection->new( handle => $cli->app_handle->handle, type => $Prophet::Replica::MERGETICKET_METATYPE );
+ 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 };
@@ -273,7 +273,7 @@
sub replica_last_rev {
my $cli = Prophet::CLI->new();
- return $cli->app_handle->handle->latest_sequence_no;
+ return $cli->handle->latest_sequence_no;
}
=head2 as_user USERNAME CODEREF
@@ -386,10 +386,7 @@
}
{
- my $connection = lazy {
- my $cli = Prophet::CLI->new();
- $cli->app_handle->handle;
- };
+ my $connection = lazy { Prophet::CLI->new->handle };
sub load_record {
my $type = shift;
Modified: Prophet/trunk/lib/Prophet/Test/Arena.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Test/Arena.pm (original)
+++ Prophet/trunk/lib/Prophet/Test/Arena.pm Sat Aug 9 12:17:49 2008
@@ -40,7 +40,7 @@
as_user($c->name => sub {
my $p = Prophet::CLI->new();
- diag($c => $p->app_handle->handle->uuid);
+ diag($c => $p->handle->uuid);
});
}
Modified: Prophet/trunk/lib/Prophet/Test/Participant.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Test/Participant.pm (original)
+++ Prophet/trunk/lib/Prophet/Test/Participant.pm Sat Aug 9 12:17:49 2008
@@ -137,9 +137,9 @@
my $state;
- my $records = Prophet::Collection->new( handle => $cli->app_handle->handle, type => 'Scratch' );
- my $merges = Prophet::Collection->new( handle => $cli->app_handle->handle, type => $Prophet::Replica::MERGETICKET_METATYPE );
- my $resolutions = Prophet::Collection->new( handle => $cli->app_handle->resdb_handle, type => '_prophet_resolution' );
+ my $records = Prophet::Collection->new( handle => $cli->handle, type => 'Scratch' );
+ my $merges = Prophet::Collection->new( handle => $cli->handle, type => $Prophet::Replica::MERGETICKET_METATYPE );
+ my $resolutions = Prophet::Collection->new( handle => $cli->resdb_handle, type => '_prophet_resolution' );
$records->matching( sub {1} );
$resolutions->matching( sub {1} );
Modified: Prophet/trunk/t/canonicalize.t
==============================================================================
--- Prophet/trunk/t/canonicalize.t (original)
+++ Prophet/trunk/t/canonicalize.t Sat Aug 9 12:17:49 2008
@@ -9,7 +9,7 @@
use_ok('Prophet::CLI');
$ENV{'PROPHET_REPO'} = tempdir( CLEANUP => 0 ) . '/repo-' . $$;
my $cli = Prophet::CLI->new();
-my $cxn = $cli->app_handle->handle;
+my $cxn = $cli->handle;
isa_ok($cxn, 'Prophet::Replica');
use_ok('TestApp::Bug');
Modified: Prophet/trunk/t/config.t
==============================================================================
--- Prophet/trunk/t/config.t (original)
+++ Prophet/trunk/t/config.t Sat Aug 9 12:17:49 2008
@@ -30,7 +30,7 @@
my $a = Prophet::CLI->new();
can_ok($a, 'app_handle');
can_ok($a->app_handle, 'config');
-my $c = $a->app_handle->config;
+my $c = $a->config;
# interrogate its config to see if we have any config options set
my @keys = $c->list;
Modified: Prophet/trunk/t/create.t
==============================================================================
--- Prophet/trunk/t/create.t (original)
+++ Prophet/trunk/t/create.t Sat Aug 9 12:17:49 2008
@@ -7,7 +7,7 @@
use_ok('Prophet::CLI');
$ENV{'PROPHET_REPO'} = tempdir( CLEANUP => 0 ) . '/repo-' . $$;
my $cli = Prophet::CLI->new();
-my $cxn = $cli->app_handle->handle;
+my $cxn = $cli->handle;
isa_ok( $cxn, 'Prophet::Replica', "Got the cxn" );
use_ok('Prophet::Record');
Modified: Prophet/trunk/t/default.t
==============================================================================
--- Prophet/trunk/t/default.t (original)
+++ Prophet/trunk/t/default.t Sat Aug 9 12:17:49 2008
@@ -7,7 +7,7 @@
use_ok('Prophet::CLI');
$ENV{'PROPHET_REPO'} = tempdir( CLEANUP => 0 ) . '/repo-' . $$;
my $cli = Prophet::CLI->new();
-my $cxn = $cli->app_handle->handle;
+my $cxn = $cli->handle;
isa_ok($cxn, 'Prophet::Replica');
use_ok('TestApp::Bug');
Modified: Prophet/trunk/t/export.t
==============================================================================
--- Prophet/trunk/t/export.t (original)
+++ Prophet/trunk/t/export.t Sat Aug 9 12:17:49 2008
@@ -58,7 +58,7 @@
ok( -e $path->file('changesets.idx'), 'found changesets index' );
my $latest = $path->file('latest-sequence-no')->slurp;
- is( $latest, $cli->app_handle->handle->latest_sequence_no );
+ is( $latest, $cli->handle->latest_sequence_no );
use_ok('Prophet::Replica::Native');
diag("Checking changesets in $path");
my $changesets = Prophet::Replica->new( { url => 'prophet:file://' . $path } )->fetch_changesets( after => 0 );
Modified: Prophet/trunk/t/generalized_sync_n_merge.t
==============================================================================
--- Prophet/trunk/t/generalized_sync_n_merge.t (original)
+++ Prophet/trunk/t/generalized_sync_n_merge.t Sat Aug 9 12:17:49 2008
@@ -54,7 +54,7 @@
sub {
warn "==> hi";
my $cli = Prophet::CLI->new();
- my $handle = $cli->app_handle->handle;
+ my $handle = $cli->handle;
my $records = Prophet::Collection->new(
handle => $handle,
type => 'Scratch'
Modified: Prophet/trunk/t/history.t
==============================================================================
--- Prophet/trunk/t/history.t (original)
+++ Prophet/trunk/t/history.t Sat Aug 9 12:17:49 2008
@@ -19,7 +19,7 @@
use Test::Exception;
my $cli = Prophet::CLI->new();
- my $rec = App::Record::Thingy->new( handle => $cli->app_handle->handle, type => 'foo' );
+ my $rec = App::Record::Thingy->new( handle => $cli->handle, type => 'foo' );
ok( $rec->create( props => { foo => 'bar', point => '123' } ) );
is($rec->prop('foo'), 'bar');
Modified: Prophet/trunk/t/luid.t
==============================================================================
--- Prophet/trunk/t/luid.t (original)
+++ Prophet/trunk/t/luid.t Sat Aug 9 12:17:49 2008
@@ -9,7 +9,7 @@
$ENV{'PROPHET_METADATA_DIRECTORY'} = tempdir( CLEANUP => 0 ) . '/repo-' . $$;
my $cli = Prophet::CLI->new();
-my $cxn = $cli->app_handle->handle;
+my $cxn = $cli->handle;
my $record = Prophet::Record->new(handle => $cxn, type => 'Empty');
my $uuid = $record->create(props => {});
Modified: Prophet/trunk/t/publish-pull.t
==============================================================================
--- Prophet/trunk/t/publish-pull.t (original)
+++ Prophet/trunk/t/publish-pull.t Sat Aug 9 12:17:49 2008
@@ -50,7 +50,7 @@
# that you really want http://sartak.org/misc/sd/DATABASE-UUID
as_charlie {
my $cli = Prophet::CLI->new();
- $cli->app_handle->handle->set_db_uuid($alice_uuid);
+ $cli->handle->set_db_uuid($alice_uuid);
run_ok( 'prophet', ['pull', '--from', "file:$alice_published", '--force'] );
run_output_matches( 'prophet', [qw(search --type Bug --regex .)], [qr/new/], "publish database uuid intuition works" );
Modified: Prophet/trunk/t/resty-server.t
==============================================================================
--- Prophet/trunk/t/resty-server.t (original)
+++ Prophet/trunk/t/resty-server.t Sat Aug 9 12:17:49 2008
@@ -27,7 +27,7 @@
$ua->get_ok( url('records.json') );
is( $ua->content, '[]' );
-my $car = Prophet::Record->new( handle => $cli->app_handle->handle, type => 'Cars' );
+my $car = Prophet::Record->new( handle => $cli->handle, type => 'Cars' );
my ($uuid) = $car->create( props => { wheels => 4, windshields => 1 } );
ok( $uuid, "Created record $uuid" );
@@ -58,7 +58,7 @@
ok( 0, "Failed to get the new record's uri" );
}
-my $car2 = Prophet::Record->new( handle => $cli->app_handle->handle, type => 'Cars' );
+my $car2 = Prophet::Record->new( handle => $cli->handle, type => 'Cars' );
$car2->load( uuid => $new_uuid );
is_deeply( $car2->get_props, { wheels => 3, seatbelts => 'sure!' }, "The thing we created remotely worked just great" );
Modified: Prophet/trunk/t/validate.t
==============================================================================
--- Prophet/trunk/t/validate.t (original)
+++ Prophet/trunk/t/validate.t Sat Aug 9 12:17:49 2008
@@ -10,7 +10,7 @@
use_ok('Prophet::CLI');
$ENV{'PROPHET_REPO'} = tempdir( CLEANUP => 0 ) . '/repo-' . $$;
my $cli = Prophet::CLI->new();
-my $cxn = $cli->app_handle->handle;
+my $cxn = $cli->handle;
isa_ok( $cxn, 'Prophet::Replica', "Got the cxn" );
use_ok('TestApp::Bug');
Modified: Prophet/trunk/t/validation.t
==============================================================================
--- Prophet/trunk/t/validation.t (original)
+++ Prophet/trunk/t/validation.t Sat Aug 9 12:17:49 2008
@@ -19,7 +19,7 @@
as_alice {
my $cli = Prophet::CLI->new();
- my $rec = App::Record->new( handle => $cli->app_handle->handle, type => 'foo' );
+ my $rec = App::Record->new( handle => $cli->handle, type => 'foo' );
ok( $rec->create( props => { foo => 'bar', point => '123' } ) );
More information about the Bps-public-commit
mailing list