[Bps-public-commit] Prophet branch, master, updated. 10b171677245664d640ad60cce23c4678eced485

jesse jesse at bestpractical.com
Wed Apr 15 03:22:23 EDT 2009


The branch, master has been updated
       via  10b171677245664d640ad60cce23c4678eced485 (commit)
       via  0414dfd3c191f8bd3b0a276e66ea6c1a4511a9c4 (commit)
       via  f61704f9bf704a6d10074e08a31a85e956686d3d (commit)
       via  ed9d0693dbe1123214803112aee7988b9c92ceec (commit)
      from  ca04ce26e7e8e48232686c0d98242cac83625071 (commit)

Summary of changes:
 lib/Prophet/CLI/Command/Config.pm  |    2 +-
 lib/Prophet/Config.pm              |    6 +-
 lib/Prophet/ReplicaFeedExporter.pm |  114 +++++++++++++++++++----------------
 3 files changed, 67 insertions(+), 55 deletions(-)

- Log -----------------------------------------------------------------
commit ed9d0693dbe1123214803112aee7988b9c92ceec
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Wed Apr 15 15:00:29 2009 +0800

    /replica/prophetrc->/replica/config

diff --git a/lib/Prophet/CLI/Command/Config.pm b/lib/Prophet/CLI/Command/Config.pm
index 9eb2e40..ea61ad6 100644
--- a/lib/Prophet/CLI/Command/Config.pm
+++ b/lib/Prophet/CLI/Command/Config.pm
@@ -42,7 +42,7 @@ sub run {
 sub no_config_files {
     my $self = shift;
     return "No configuration files found. "
-         . " Either create a file called 'prophetrc' inside of "
+         . " Either create a file called 'config' inside of "
          . $self->handle->fs_root
          . " or set the PROPHET_APP_CONFIG environment variable.\n\n";
 }
diff --git a/lib/Prophet/Config.pm b/lib/Prophet/Config.pm
index ec8ed04..42203f1 100644
--- a/lib/Prophet/Config.pm
+++ b/lib/Prophet/Config.pm
@@ -48,7 +48,9 @@ sub app_config_file {
 
 sub replica_config_file {
     my $self = shift;
-    return File::Spec->catfile( $self->app_handle->handle->fs_root => 'prophetrc' )
+     return 
+     $self->file_if_exists( File::Spec->catfile( $self->app_handle->handle->fs_root => 'config' )) ||
+     $self->file_if_exists( File::Spec->catfile( $self->app_handle->handle->fs_root => 'prophetrc' ));
 }
 
 
@@ -187,7 +189,7 @@ Takes no arguments. Automatically loads the config for you.
 =head2 app_config_file
 
 The file which controls configuration for this application
-(the $PROPHET_APP_CONFIG environmental variable, C<$PROPHET_REPO/prophetrc>,
+(the $PROPHET_APP_CONFIG environmental variable, C<$PROPHET_REPO/config>,
 or C<$HOME/.prophetrc>, in that order).
 
 =head2 load_from_files [files]

commit f61704f9bf704a6d10074e08a31a85e956686d3d
Merge: ed9d069... 4244075...
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Wed Apr 15 15:02:58 2009 +0800

    Merge branch 'master' of fsck.com:/git/prophet


commit 0414dfd3c191f8bd3b0a276e66ea6c1a4511a9c4
Merge: f61704f... ca04ce2...
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Wed Apr 15 15:18:28 2009 +0800

    Merge branch 'master' of fsck.com:/git/prophet


commit 10b171677245664d640ad60cce23c4678eced485
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Wed Apr 15 15:22:09 2009 +0800

    start extracting methods in the replica feed exporter

diff --git a/lib/Prophet/ReplicaFeedExporter.pm b/lib/Prophet/ReplicaFeedExporter.pm
index 26f2b1e..80d7a49 100644
--- a/lib/Prophet/ReplicaFeedExporter.pm
+++ b/lib/Prophet/ReplicaFeedExporter.pm
@@ -6,14 +6,8 @@ my $feed_updated;
 
 sub export {
     my $self = shift;
-    print '<?xml version="1.0" encoding="utf-8"?>' . "\n";
-    print '<feed xmlns="http://www.w3.org/2005/Atom">';
 
-    print tag( 'id' => 'urn:uuid:' . $self->source_replica->uuid );
-    print tag(
-        'title' => 'Prophet feed of ' . $self->source_replica->db_uuid );
-
-    print tag('prophet:latest-sequence', $self->source_replica->latest_sequence_no);
+    print $self->feed_header();
     $self->source_replica->resolution_db_handle->traverse_changesets(
         after    => 0,
         callback => sub {
@@ -32,6 +26,21 @@ sub export {
     print "</feed>";
 }
 
+sub feed_header {
+    my $self = shift;
+
+    return join(
+        "\n", '<?xml version="1.0" encoding="utf-8"?>',
+        '<feed xmlns="http://www.w3.org/2005/Atom">',
+
+        tag( 'id' => 'urn:uuid:' . $self->source_replica->uuid ),
+        tag( 'title' => 'Prophet feed of ' . $self->source_replica->db_uuid
+        ),
+
+        tag( 'prophet:latest-sequence', $self->source_replica->latest_sequence_no )
+    );
+}
+
 sub output_resolution_changeset {
     my $self = shift;
     my $cs   = shift;
@@ -42,16 +51,20 @@ sub output_resolution_changeset {
         sub {
             my $output =
 
-              tag( author => undef, sub { tag( name => $cs->creator ) } )
-              . tag(title => 'Resolution ' . $cs->sequence_no . ' by ' . ( $cs->creator || 'nobody' ) . ' @ ' . $cs->original_source_uuid )
-              . tag(id => 'prophet:' . $cs->original_sequence_no . '@' . $cs->original_source_uuid )
-              . tag( published => $cs->created_as_rfc3339 )
-              . tag( updated   => $cs->created_as_rfc3339 )
-              . '<content type="text">' . "\n"
-              . tag( 'prophet:resolution')
-              . tag( 'prophet:sequence' => $cs->sequence_no )
-              . output_changes($cs)
-              . '</content>';
+                tag( author => undef, sub { tag( name => $cs->creator ) } )
+                . tag(title => 'Resolution '
+                    . $cs->sequence_no . ' by '
+                    . ( $cs->creator || 'nobody' ) . ' @ '
+                    . $cs->original_source_uuid )
+                . tag(
+                id => 'prophet:' . $cs->original_sequence_no . '@' . $cs->original_source_uuid )
+                . tag( published => $cs->created_as_rfc3339 )
+                . tag( updated   => $cs->created_as_rfc3339 )
+                . '<content type="text">' . "\n"
+                . tag('prophet:resolution')
+                . tag( 'prophet:sequence' => $cs->sequence_no )
+                . output_changes($cs)
+                . '</content>';
             return $output;
 
         }
@@ -68,26 +81,27 @@ sub output_changeset {
         sub {
             my $output =
 
-              tag( author => undef, sub { tag( name => $cs->creator ) } )
-              . tag(title => 'Change '
-                  . $cs->sequence_no . ' by '
-                  . ( $cs->creator || 'nobody' ) . ' @ '
-                  . $cs->original_source_uuid )
-              . tag(id => 'prophet:'
-                  . $cs->original_sequence_no . '@'
-                  . $cs->original_source_uuid )
-              . tag( published => $cs->created_as_rfc3339 )
-              . tag( updated   => $cs->created_as_rfc3339 )
-              . '<content type="text">' . "\n"
-              . tag( 'prophet:sequence' => $cs->sequence_no )
-              . ( $cs->is_nullification
-                ? tag( 'prophet:nullifcation' => $cs->is_nullification )
-                : '' )
-              . ( $cs->is_resolution
-                ? tag( 'prophet:resolution' => $cs->is_resolution )
-                : '' )
-              . output_changes($cs)
-              . '</content>';
+                tag( author => undef, sub { tag( name => $cs->creator ) } )
+                . tag(title => 'Change '
+                    . $cs->sequence_no . ' by '
+                    . ( $cs->creator || 'nobody' ) . ' @ '
+                    . $cs->original_source_uuid )
+                . tag(
+                id => 'prophet:' . $cs->original_sequence_no . '@' . $cs->original_source_uuid )
+                . tag( published => $cs->created_as_rfc3339 )
+                . tag( updated   => $cs->created_as_rfc3339 )
+                . '<content type="text">' . "\n"
+                . tag( 'prophet:sequence' => $cs->sequence_no )
+                . (
+                $cs->is_nullification ? tag( 'prophet:nullifcation' => $cs->is_nullification )
+                : ''
+                )
+                . (
+                $cs->is_resolution ? tag( 'prophet:resolution' => $cs->is_resolution )
+                : ''
+                )
+                . output_changes($cs)
+                . '</content>';
             return $output;
 
         }
@@ -102,17 +116,16 @@ sub output_changes {
             'prophet:change',
             undef,
             sub {
-                my $change_data =
-                    tag( 'prophet:type', $change->record_type )
-                  . tag( 'prophet:uuid',        $change->record_uuid )
-                  . tag( 'prophet:change-type', $change->change_type )
-                  . ( $change->is_resolution ? tag('prophet:resolution') : '' )
-                  . (
+                my $change_data
+                    = tag( 'prophet:type',        $change->record_type )
+                    . tag( 'prophet:uuid',        $change->record_uuid )
+                    . tag( 'prophet:change-type', $change->change_type )
+                    . ( $change->is_resolution ? tag('prophet:resolution') : '' )
+                    . (
                     $change->resolution_cas
-                    ? tag( 'prophet:resolution-fingerprint',
-                        $change->resolution_cas )
+                    ? tag( 'prophet:resolution-fingerprint', $change->resolution_cas )
                     : ''
-                  );
+                    );
 
                 foreach my $prop_change ( $change->prop_changes ) {
                     $change_data .= tag(
@@ -120,8 +133,8 @@ sub output_changes {
                         undef,
                         sub {
                             tag( 'prophet:name' => $prop_change->name )
-                              . tag( 'prophet:old' => $prop_change->old_value )
-                              . tag( 'prophet:new' => $prop_change->new_value );
+                                . tag( 'prophet:old' => $prop_change->old_value )
+                                . tag( 'prophet:new' => $prop_change->new_value );
                         }
                     );
 
@@ -147,8 +160,7 @@ sub tag ($$;&) {
     $output .= " " x $depth;
     if ( !$content && !defined $value ) {
         $output .= "<$tag/>\n";
-    }
-    else {
+    } else {
         $output .= "<$tag>";
         if ($value) {
             Prophet::Util::escape_utf8( \$value );
@@ -165,8 +177,6 @@ sub tag ($$;&) {
     return $output;
 }
 
-
-
 __PACKAGE__->meta->make_immutable;
 no Any::Moose;
 

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



More information about the Bps-public-commit mailing list