[Bps-public-commit] Prophet branch, master, updated. 0.743-36-gd8d439b

Christine Spang spang at bestpractical.com
Thu Jan 13 09:23:41 EST 2011


The branch, master has been updated
       via  d8d439b4c7325b47c2dcf1b6236729d8158a1e1e (commit)
      from  76afde8b9f17afd83273acdb7393c92a90442df9 (commit)

Summary of changes:
 lib/Prophet/Record.pm |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

- Log -----------------------------------------------------------------
commit d8d439b4c7325b47c2dcf1b6236729d8158a1e1e
Author: Christine Spang <christine at debian.org>
Date:   Mon Jan 10 13:21:03 2011 -0500

    add the ability to color format strings using Term::ANSIColor
    
    Closes RT #52377, thanks to Brett Nash for the suggestion

diff --git a/lib/Prophet/Record.pm b/lib/Prophet/Record.pm
index 82b76f7..b9fc86b 100644
--- a/lib/Prophet/Record.pm
+++ b/lib/Prophet/Record.pm
@@ -1,6 +1,7 @@
 package Prophet::Record;
 use Any::Moose;
 use Params::Validate;
+use Term::ANSIColor;
 use Prophet::App; # for require_module. Kinda hacky
 use constant collection_class => 'Prophet::Collection';
 
@@ -716,10 +717,10 @@ sub _parse_format_summary {
     my @out;
     for my $atom ($self->_atomize_summary_format) {
         my %atom_data;
-        my ($format, $prop, $value);
+        my ($format, $prop, $value, $color);
 
         if ($atom =~ /,/) {
-            ($format, $prop) = split /,/, $atom;
+            ($format, $prop, $color) = split /,/, $atom;
 
             $value = $prop;
 
@@ -738,8 +739,7 @@ sub _parse_format_summary {
             format    => $format,
             prop      => $prop,
             value     => $atom_value,
-            formatted => $self->format_atom( $format => $atom_value )
-
+            formatted => $self->format_atom( $format, $atom_value, $color ),
         };
     }
     return @out;
@@ -828,9 +828,7 @@ Dies with a message if there's an error in the format string that sprintf warn()
 =cut
 
 sub format_atom {
-    my $self = shift;
-    my $string = shift;
-    my $value = shift;
+    my ($self, $string, $value, $color) = @_;
 
     my $formatted_atom;
     eval {
@@ -846,7 +844,7 @@ sub format_atom {
             ."summary format for this ticket type.\n\n"
             ."The error encountered was:\n\n'" . $@ . "'\n";
     }
-    return $formatted_atom;
+    return $color ? colored($formatted_atom, $color) : $formatted_atom;
 }
 
 =head2 find_or_create_luid

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



More information about the Bps-public-commit mailing list