Skip to content

Commit

Permalink
Remove classbuilder stuff, it's now in the branch
Browse files Browse the repository at this point in the history
  • Loading branch information
sartak committed Aug 3, 2008
1 parent 4c5ab96 commit 7824ff0
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 117 deletions.
74 changes: 59 additions & 15 deletions lib/Net/Hiveminder.pm
Expand Up @@ -2,7 +2,6 @@
package Net::Hiveminder; package Net::Hiveminder;
use Moose; use Moose;
extends 'Net::Jifty'; extends 'Net::Jifty';
use Net::Hiveminder::Task;


use Number::RecordLocator; use Number::RecordLocator;
my $LOCATOR = Number::RecordLocator->new; my $LOCATOR = Number::RecordLocator->new;
Expand Down Expand Up @@ -80,25 +79,76 @@ The arguments currently respected are:
Make the record locator (C<#foo>) into an HTML link, pointing to the task on Make the record locator (C<#foo>) into an HTML link, pointing to the task on
C<site>. C<site>.
=item color
Use ANSI escape-sequence colors.
=back =back
=cut =cut


sub display_tasks { sub display_tasks {
my $self = shift; my $self = shift;
my @out;


my $now = DateTime->now;
my %email_of; my %email_of;


my %args; my %args;
if (ref($_[0]) eq 'ARRAY') { if (ref($_[0]) eq 'ARRAY') {
%args = @{ shift(@_) }; %args = @{ shift(@_) };
} }


my @out = map { $_->display } @_; for my $task (@_) {
my $locator = $self->id2loc($task->{id});
my $display;

if ($task->{complete}) {
$display .= '* ';
}

if ($args{linkify_locator}) {
$display .= sprintf '<a href="%s/task/%s">#%s</a>: %s',
$self->site,
$locator,
$locator,
$task->{summary};
}
else {
$display .= "#$locator: $task->{summary}";
}

# don't display start date if it's <= today
delete $task->{starts}
if $task->{starts}
&& $self->load_date($task->{starts}) < $now;

$display .= " [$task->{tags}]" if $task->{tags};
for my $field (qw/due starts group/) {
$display .= " [$field: $task->{$field}]"
if $task->{$field};
}

$display .= " [priority: " . $self->priority($task->{priority}) . "]"
if $task->{priority} != 3;

my $helper = sub {
my ($field, $name) = @_;

my $id = $task->{$field}
or return;

# this wants to be //=. oh well
my $email = $email_of{$id} ||= $self->email_of($id)
or return;

$self->is_me($email)
and return;

$display .= " [$name: $email]";
};

$helper->('requestor_id', 'for');
$helper->('owner_id', 'by');

push @out, $display;
}


return wantarray ? @out : join "\n", @out; return wantarray ? @out : join "\n", @out;
} }
Expand All @@ -118,10 +168,7 @@ sub get_tasks {
my @args = @_; my @args = @_;
unshift @args, "tokens" if @args == 1; unshift @args, "tokens" if @args == 1;


$self->create_model_class('Task'); return @{ $self->act('TaskSearch', @args)->{content}{tasks} };

return map { Net::Hiveminder::Task->new(_interface => $self, %$_) }
@{ $self->act('TaskSearch', @args)->{content}{tasks} };
} }


=head2 todo_tasks [ARGS] =head2 todo_tasks [ARGS]
Expand Down Expand Up @@ -206,8 +253,7 @@ sub read_task {
my $loc = shift; my $loc = shift;
my $id = $self->loc2id($loc); my $id = $self->loc2id($loc);


$self->create_model_class('Task'); return $self->read(Task => id => $id);
return Net::Hiveminder::Task->load($self, $id);
} }


=head2 update_task LOCATOR, ARGS =head2 update_task LOCATOR, ARGS
Expand Down Expand Up @@ -352,9 +398,7 @@ sub braindump {
return @{ $ret->{content}->{ids} || [] }; return @{ $ret->{content}->{ids} || [] };
} }
elsif ($args{returns} eq 'tasks') { elsif ($args{returns} eq 'tasks') {
$self->create_model_class('Task'); return @{ $ret->{content}->{created} || [] };
return map { Net::Hiveminder::Task->new(_interface => $self, %$_) }
@{ $ret->{content}->{created} || [] };
} }


return $ret->{message}; return $ret->{message};
Expand Down
102 changes: 0 additions & 102 deletions lib/Net/Hiveminder/Task.pm

This file was deleted.

0 comments on commit 7824ff0

Please sign in to comment.