[Bps-public-commit] r14954 - in Prophet/trunk: .

sartak at bestpractical.com sartak at bestpractical.com
Sat Aug 9 15:41:37 EDT 2008


Author: sartak
Date: Sat Aug  9 15:41:35 2008
New Revision: 14954

Modified:
   Prophet/trunk/   (props changed)
   Prophet/trunk/lib/Prophet/CLI/Command/Search.pm

Log:
 r69024 at onn:  sartak | 2008-08-09 15:41:26 -0400
 If none of the clauses are checked (props, regex) then call a default_match sub to do some limiting


Modified: Prophet/trunk/lib/Prophet/CLI/Command/Search.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command/Search.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI/Command/Search.pm	Sat Aug  9 15:41:35 2008
@@ -20,6 +20,8 @@
     documentation => 'A subroutine which takes a list of records and returns them sorted in some way.',
 );
 
+sub default_match { 1 }
+
 sub get_search_callback {
     my $self = shift;
 
@@ -33,8 +35,11 @@
     return sub {
         my $item = shift;
         my $props = $item->get_props;
+        my $did_limit = 0;
 
         if ($self->prop_names > 0) {
+            $did_limit = 1;
+
             for my $prop (keys %prop_checks) {
                 my $got = $props->{$prop};
                 my $ok = 0;
@@ -48,7 +53,9 @@
 
         # if they specify a regex, it must match
         if ($regex) {
+            $did_limit = 1;
             my $ok = 0;
+
             for (values %$props) {
                 if (/$regex/) {
                     $ok = 1;
@@ -58,6 +65,8 @@
             return 0 if !$ok;
         }
 
+        return $self->default_match($item) if !$did_limit;
+
         return 1;
     };
 }



More information about the Bps-public-commit mailing list