[Bps-public-commit] r9721 - in Net-Hiveminder: lib/Net

sartak at bestpractical.com sartak at bestpractical.com
Wed Nov 21 16:36:46 EST 2007


Author: sartak
Date: Wed Nov 21 16:36:46 2007
New Revision: 9721

Modified:
   Net-Hiveminder/   (props changed)
   Net-Hiveminder/lib/Net/Hiveminder.pm

Log:
 r45506 at onn:  sartak | 2007-11-21 16:36:14 -0500
 braindump and canonicalize_priority


Modified: Net-Hiveminder/lib/Net/Hiveminder.pm
==============================================================================
--- Net-Hiveminder/lib/Net/Hiveminder.pm	(original)
+++ Net-Hiveminder/lib/Net/Hiveminder.pm	Wed Nov 21 16:36:46 2007
@@ -211,6 +211,22 @@
     return $self->delete(Task => id => $id);
 }
 
+=head2 braindump Text[, Tokens]
+
+Braindumps the given text. You may also pass a string of tokens to give
+defaults to each of the braindumped tasks.
+
+=cut
+
+sub braindump {
+    my $self = shift;
+    my $text = shift;
+    my $tokens = shift || '';
+
+    return $self->act('ParseTasksMagically', text => $text, tokens => $tokens)
+                ->{message};
+}
+
 =head2 email_of id
 
 Take a user ID and retrieve that user's email address.
@@ -225,6 +241,40 @@
     return $user->{email};
 }
 
+=head2 canonicalize_priority priority
+
+Attempts to understand a variety of different priority formats and change it
+to the standard 1-5. This will C<confess> if it doesn't understand the
+priority.
+
+=cut
+
+my %priority_map = (
+    lowest  => 1,
+    low     => 2,
+    normal  => 3,
+    high    => 4,
+    highest => 5,
+    e       => 1,
+    d       => 2,
+    c       => 3,
+    b       => 4,
+    a       => 5,
+    1       => 1,
+    2       => 2,
+    3       => 3,
+    4       => 4,
+    5       => 5,
+);
+
+sub canonicalize_priority {
+    my $self = shift;
+    my $priority = shift;
+
+    return $priority_map{lc $priority}
+        or confess "Unknown priority: '$priority'"
+}
+
 =head1 SEE ALSO
 
 L<Jifty>, L<Net::Jifty>



More information about the Bps-public-commit mailing list