[Bps-public-commit] Prophet branch, master, updated. 0.73-42-gaeb2f54

Ruslan Zakirov ruz at bestpractical.com
Wed Jan 27 03:46:27 EST 2010


The branch, master has been updated
       via  aeb2f54222a0f9734d3fa98f070b2427dcd46617 (commit)
      from  b94ebbbd29d20ae623819477eca3610ad47a1422 (commit)

Summary of changes:
 lib/Prophet/CLI/Command/Search.pm |   38 ++++++++++++++++++++++++------------
 1 files changed, 25 insertions(+), 13 deletions(-)

- Log -----------------------------------------------------------------
commit aeb2f54222a0f9734d3fa98f070b2427dcd46617
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Mon Jan 18 07:13:32 2010 +0300

    refactor inline code into methods

diff --git a/lib/Prophet/CLI/Command/Search.pm b/lib/Prophet/CLI/Command/Search.pm
index 4eff68c..b8b39c1 100644
--- a/lib/Prophet/CLI/Command/Search.pm
+++ b/lib/Prophet/CLI/Command/Search.pm
@@ -145,19 +145,8 @@ sub display_terminal {
     my $groups = $self->group_routine->( [$records->items] );
 
     foreach my $group ( @{$groups} ) {
-        next unless (exists $group->{records}->[0]); # skip headings with no records
-        $group->{label}  ||= 'none';
-        if ( $#{$groups} &&  $group->{label} ) {
-            print "\n"
-                . $group->{label} 
-                . "\n" 
-                . ("=" x ( length $group->{label} ))
-                . "\n\n";
-        }
-
-        for ( $self->sort_routine->( $group->{records} ) ) {
-            print $_->format_summary . "\n";
-        }
+        $self->out_group_heading( $group, $groups );
+        $self->out_record($_) for $self->sort_routine->( $group->{records} );
     }
 
 }
@@ -207,6 +196,29 @@ sub group_by_prop {
 
 }
 
+sub out_group_heading {
+    my $self = shift;
+    my $group = shift;
+    my $groups = shift;
+
+    # skip headings with no records
+    return unless exists $group->{records}->[0];
+
+    return unless @$groups > 1;
+
+    $group->{label} ||= 'none';
+    print "\n". $group->{label} ."\n" 
+        . ("=" x length $group->{label} )
+        . "\n\n";
+
+}
+
+sub out_record {
+    my $self = shift;
+    my $record = shift;
+    print $record->format_summary . "\n";
+}
+
 __PACKAGE__->meta->make_immutable;
 no Any::Moose;
 

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



More information about the Bps-public-commit mailing list