[Bps-public-commit] r16301 - in Prophet/trunk/lib/Prophet: CLI CLI/Command Replica Test

jesse at bestpractical.com jesse at bestpractical.com
Wed Oct 15 02:24:56 EDT 2008


Author: jesse
Date: Wed Oct 15 02:24:53 2008
New Revision: 16301

Modified:
   Prophet/trunk/lib/Prophet/CLI/Command.pm
   Prophet/trunk/lib/Prophet/CLI/Command/Pull.pm
   Prophet/trunk/lib/Prophet/CLIContext.pm
   Prophet/trunk/lib/Prophet/Change.pm
   Prophet/trunk/lib/Prophet/ChangeSet.pm
   Prophet/trunk/lib/Prophet/Collection.pm
   Prophet/trunk/lib/Prophet/Record.pm
   Prophet/trunk/lib/Prophet/Replica.pm
   Prophet/trunk/lib/Prophet/Replica/prophet.pm
   Prophet/trunk/lib/Prophet/Replica/svn.pm
   Prophet/trunk/lib/Prophet/ReplicaExporter.pm
   Prophet/trunk/lib/Prophet/Test/Arena.pm

Log:
 * Banish foreach

Modified: Prophet/trunk/lib/Prophet/CLI/Command.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI/Command.pm	Wed Oct 15 02:24:53 2008
@@ -115,7 +115,7 @@
 
     # parse the output
     my $filtered = {};
-    foreach my $line (split "\n", $output) {
+    for my $line (split "\n", $output) {
         if ($line =~ m/^([^:]+):\s*(.*)$/) {
             my $prop = $1;
             my $val = $2;
@@ -126,7 +126,7 @@
     no warnings 'uninitialized';
 
     # if a key is deleted intentionally, set its value to ''
-    foreach my $prop (keys %$hash) {
+    for my $prop (keys %$hash) {
         if (!exists $filtered->{$prop} and $prop =~ !/$do_not_edit/) {
             $filtered->{$prop} = '';
         }

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	Wed Oct 15 02:24:53 2008
@@ -56,7 +56,7 @@
             print "Probing for local database replicas with Bonjour\n";
             my $res = Net::Bonjour->new('prophet');
             $res->discover;
-            foreach my $entry ( $res->entries ) {
+            for my $entry ( $res->entries ) {
                 if ( $entry->name eq $self->arg('db_uuid') ) {
                     print "Found a database replica on " . $entry->hostname."\n";
                     my $uri = URI->new();

Modified: Prophet/trunk/lib/Prophet/CLIContext.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLIContext.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLIContext.pm	Wed Oct 15 02:24:53 2008
@@ -99,7 +99,7 @@
     $self->clear_props();
 
     if ( my $cmd_args = $args{args} ) {
-        foreach my $arg ( keys %$cmd_args ) {
+        for my $arg ( keys %$cmd_args ) {
             if ( $arg eq 'uuid' ) {
                 $self->uuid( $cmd_args->{$arg} );
             }
@@ -107,7 +107,7 @@
         }
     }
     if ( my $props = $args{props} ) {
-        foreach my $prop (@$props) {
+        for my $prop (@$props) {
             my $key   = $prop->{prop};
             my $value = $prop->{value};
             $self->set_prop( $key => $value );

Modified: Prophet/trunk/lib/Prophet/Change.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Change.pm	(original)
+++ Prophet/trunk/lib/Prophet/Change.pm	Wed Oct 15 02:24:53 2008
@@ -183,7 +183,7 @@
     my $hashref = shift;
     my $self    = $class->new(
         { record_type => $hashref->{'record_type'}, record_uuid => $uuid, change_type => $hashref->{'change_type'} } );
-    foreach my $prop ( keys %{ $hashref->{'prop_changes'} } ) {
+    for my $prop ( keys %{ $hashref->{'prop_changes'} } ) {
         $self->add_prop_change(
             name => $prop,
             old  => $hashref->{'prop_changes'}->{$prop}->{'old_value'},

Modified: Prophet/trunk/lib/Prophet/ChangeSet.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/ChangeSet.pm	(original)
+++ Prophet/trunk/lib/Prophet/ChangeSet.pm	Wed Oct 15 02:24:53 2008
@@ -178,7 +178,7 @@
     my $hashref = shift;
     my $self    = $class->new( { map { $_ => $hashref->{$_} } @SERIALIZE_PROPS } );
 
-    foreach my $change ( keys %{ $hashref->{changes} } ) {
+    for my $change ( keys %{ $hashref->{changes} } ) {
         $self->add_change( change => Prophet::Change->new_from_hashref( $change => $hashref->{changes}->{$change} ) );
     }
     return $self;

Modified: Prophet/trunk/lib/Prophet/Collection.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Collection.pm	(original)
+++ Prophet/trunk/lib/Prophet/Collection.pm	Wed Oct 15 02:24:53 2008
@@ -80,7 +80,7 @@
 
     # run coderef against each item;
     # if it matches, add it to items
-    foreach my $key (@$records) {
+    for my $key (@$records) {
         my $record = $self->record_class->new( { app_handle => $self->app_handle,  handle => $self->handle, type => $self->type } );
         $record->load( uuid => $key );
         if ( $coderef->($record) ) {

Modified: Prophet/trunk/lib/Prophet/Record.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Record.pm	(original)
+++ Prophet/trunk/lib/Prophet/Record.pm	Wed Oct 15 02:24:53 2008
@@ -615,7 +615,7 @@
     my $props = $self->get_props;
 
     my @out;
-    foreach my $atom ($self->_atomize_summary_format) {
+    for my $atom ($self->_atomize_summary_format) {
         my %atom_data;
         my ($format, $prop, $value);
 

Modified: Prophet/trunk/lib/Prophet/Replica.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Replica.pm	(original)
+++ Prophet/trunk/lib/Prophet/Replica.pm	Wed Oct 15 02:24:53 2008
@@ -424,7 +424,7 @@
     my ( $self, $changeset ) = @_;
 
     my @new_changes;
-    foreach my $change ($changeset->changes) {
+    for my $change ($changeset->changes) {
             # when would we run into resolution records in a nonresdb? XXX
             next if ($change->record_type eq '_prophet_resolution' && !$self->is_resdb);
 

Modified: Prophet/trunk/lib/Prophet/Replica/prophet.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Replica/prophet.pm	(original)
+++ Prophet/trunk/lib/Prophet/Replica/prophet.pm	Wed Oct 15 02:24:53 2008
@@ -671,7 +671,7 @@
     my $changeset_index = $self->_read_changeset_index();
 
     my @changesets;
-    foreach my $item (@record_index) {
+    for my $item (@record_index) {
         my $sequence = $item->[0];
         push @changesets, $self->_get_changeset_index_entry( sequence_no => $sequence, index_file => $changeset_index);
     }
@@ -886,7 +886,7 @@
         }
     );
 
-    foreach my $name ( keys %{ $args{props} } ) {
+    for my $name ( keys %{ $args{props} } ) {
         $change->add_prop_change(
             name => $name,
             old  => undef,
@@ -933,7 +933,7 @@
         type => $args{'type'}
     );
     my %new_props = %$old_props;
-    foreach my $prop ( keys %{ $args{props} } ) {
+    for my $prop ( keys %{ $args{props} } ) {
         if ( !defined $args{props}->{$prop} ) {
             delete $new_props{$prop};
         } else {
@@ -953,7 +953,7 @@
         }
     );
 
-    foreach my $name ( keys %{ $args{props} } ) {
+    for my $name ( keys %{ $args{props} } ) {
         $change->add_prop_change(
             name => $name,
             old  => $old_props->{$name},

Modified: Prophet/trunk/lib/Prophet/Replica/svn.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Replica/svn.pm	(original)
+++ Prophet/trunk/lib/Prophet/Replica/svn.pm	Wed Oct 15 02:24:53 2008
@@ -342,7 +342,7 @@
     my %args = validate( @_, { uuid => 1, props => 1, type => 1 } );
 
     my $file = $self->_file_for( uuid => $args{uuid}, type => $args{type} );
-    foreach my $prop ( keys %{ $args{'props'} } ) {
+    for my $prop ( keys %{ $args{'props'} } ) {
         eval {
             local $SIG{__DIE__} = 'DEFAULT';
             $self->current_edit->root->change_node_prop( $file, $prop, $args{'props'}->{$prop}, undef )

Modified: Prophet/trunk/lib/Prophet/ReplicaExporter.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/ReplicaExporter.pm	(original)
+++ Prophet/trunk/lib/Prophet/ReplicaExporter.pm	Wed Oct 15 02:24:53 2008
@@ -99,7 +99,7 @@
     my $self = shift;
 
     my $cs_file = $self->target_replica->_get_changeset_index_handle();
-    foreach my $changeset (
+    for my $changeset (
         @{ $self->source_replica->fetch_changesets( after => 0 ) } )
     {
         $self->target_replica->_write_changeset(

Modified: Prophet/trunk/lib/Prophet/Test/Arena.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Test/Arena.pm	(original)
+++ Prophet/trunk/lib/Prophet/Test/Arena.pm	Wed Oct 15 02:24:53 2008
@@ -146,8 +146,8 @@
     my @chickens_a = shuffle $self->chickens;
     my @chickens_b = shuffle $self->chickens;
 
-    foreach my $a (@chickens_a) {
-        foreach my $b (@chickens_b) {
+    for my $a (@chickens_a) {
+        for my $b (@chickens_b) {
             next if $a->name eq $b->name;
             diag( $a->name, $b->name );
             as_user( $a->name, sub { $a->sync_from_peer( { from => $b->name } ) } );



More information about the Bps-public-commit mailing list