[Bps-public-commit] r14508 - in Prophet/trunk: . lib/Prophet/CLI/Command

sartak at bestpractical.com sartak at bestpractical.com
Fri Jul 25 05:38:35 EDT 2008


Author: sartak
Date: Fri Jul 25 05:38:34 2008
New Revision: 14508

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

Log:
 r65184 at onn:  sartak | 2008-07-25 05:37:44 -0400
 Use the expanded prop relationships in search (though something's broken here)


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	Fri Jul 25 05:38:34 2008
@@ -19,14 +19,14 @@
                 return 0;
             }
     } elsif (scalar $self->prop_names > 0) {
-        my $expected_props = $self->props;
+        my @expected = $self->prop_set;
         return sub {
             my $item = shift;
             my $props = $item->get_props;
 
-            for (keys %$expected_props) {
-                return 0 if not defined $props->{$_};
-                return 0 unless $props->{$_} eq $expected_props->{$_};
+            for (@expected) {
+                my $got = $props->{ $_->{name} };
+                return 0 unless $self->cmp_ok($_->{value}, $_->{cmp}, $got);
             }
 
             return 1;
@@ -36,6 +36,28 @@
     }
 }
 
+sub cmp_ok {
+    my $self = shift;
+    my ($expected, $cmp, $got) = @_;
+
+    if ($cmp eq '=') {
+        return 0 if not defined $got;
+        return 0 unless $got eq $expected;
+    }
+    elsif ($cmp eq '=~') {
+        return 0 if not defined $got;
+        return 0 unless $got =~ $expected;
+    }
+    elsif ($cmp eq '!=' || $cmp eq '<>') {
+        return 0 if $got eq $expected;
+    }
+    elsif ($cmp eq '!~') {
+        return 0 if $got =~ $expected;
+    }
+
+    return 1;
+}
+
 sub run {
     my $self = shift;
 

Modified: Prophet/trunk/t/search.t
==============================================================================
--- Prophet/trunk/t/search.t	(original)
+++ Prophet/trunk/t/search.t	Fri Jul 25 05:38:34 2008
@@ -46,13 +46,10 @@
         );
     };
 
-    TODO: {
-        local $TODO = "regex comparisons not implemented yet";
-        run_output_matches('prophet', [qw(search --type Bug -- status=~n)],
-            [qr/first ticket summary/, qr/other ticket summary/],
-            "found two tickets with status=~n",
-        );
-    };
+    run_output_matches('prophet', [qw(search --type Bug -- status=~n)],
+        [qr/first ticket summary/, qr/other ticket summary/],
+        "found two tickets with status=~n",
+    );
 
     TODO: {
         local $TODO = "regex comparisons not implemented yet";



More information about the Bps-public-commit mailing list