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

sartak at bestpractical.com sartak at bestpractical.com
Thu Feb 7 20:48:38 EST 2008


Author: sartak
Date: Thu Feb  7 20:48:38 2008
New Revision: 10766

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

Log:
 r51675 at onn:  sartak | 2008-02-07 20:48:09 -0500
 Add bulk_update and complete_tasks


Modified: Net-Hiveminder/Changes
==============================================================================
--- Net-Hiveminder/Changes	(original)
+++ Net-Hiveminder/Changes	Thu Feb  7 20:48:38 2008
@@ -6,6 +6,7 @@
         Move scripts to hm-* and install them automatically
         Fix comments_on to give all comments, not an arbitrary one
         Add * to completed tasks in display_tasks
+        Add bulk_update and complete_tasks
 
 0.03    Mon Jan 21 08 01:50:38
         Rename tasks2ids to loc2id

Modified: Net-Hiveminder/lib/Net/Hiveminder.pm
==============================================================================
--- Net-Hiveminder/lib/Net/Hiveminder.pm	(original)
+++ Net-Hiveminder/lib/Net/Hiveminder.pm	Thu Feb  7 20:48:38 2008
@@ -258,6 +258,71 @@
     return $self->delete(Task => id => $id);
 }
 
+=head2 bulk_update ARGS
+
+Bulk-updates the given tasks. You can pass tasks in with one or more of the
+following:
+
+=over 4
+
+=item tasks
+
+An array reference of task hashes or locators, or a space-delimited string of
+locators.
+
+=item ids
+
+An array reference or space-delimited string of task IDs.
+
+=back
+
+=cut
+
+sub bulk_update {
+    my $self = shift;
+    my %args = @_;
+
+    my @ids;
+    my $ids = delete $args{ids} || '';
+    my $tasks = delete $args{tasks} || '';
+
+    if (ref($ids) eq 'ARRAY') {
+        push @ids, @$ids;
+    }
+    else {
+        push @ids, split ' ', $ids;
+    }
+
+    if (ref($tasks) eq 'ARRAY') {
+        push @ids, $self->loc2id(@$tasks);
+    }
+    elsif (ref($tasks) eq 'HASH') {
+        push @ids, $self->loc2id($tasks);
+    }
+    else {
+        push @ids, $self->loc2id(split ' ', $tasks);
+    }
+
+    $self->act('BulkUpdateTasks',
+        ids => join(' ', @ids),
+        %args,
+    );
+}
+
+=head2 complete_tasks TASKS
+
+Marks the list of tasks or locators as complete.
+
+=cut
+
+sub complete_tasks {
+    my $self = shift;
+    $self->bulk_update(
+        tasks    => \@_,
+        complete => 1,
+    );
+}
+
 =head2 braindump TEXT[, ARGS]
 
 Braindumps C<TEXT>.



More information about the Bps-public-commit mailing list