API/Todo.pm

filter: Statementstmt 23.4% 11 / 47 Branchbran 0.0% 0 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 25.0% 3 / 12 Podpod 100% 9 / 9 totaltotal 26.7% 23 / 86 CC 10 SCAR 18.9
CC
10
Cov
17%
get_tags
12.0
get_externalUID
12.0
new
6.0
CRAP 6.6
« API/Event.pm ↑ Summary API/Request.pm »
1 package WebService::30Boxes::API::Todo;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = '1.05';
8  
9 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
10 0 my ($class, $result, $success, $error_code, $error_message) = @_;
11 0 ▶ croak "The response from 30Boxes was not a success" unless $result->{'success'};
Branch: 1 branch
BranchTrueFalseTotal
unless $result->{"success"} 0 0 0
12  
13 #%{$result->{'_xml'}->{'todoList'}->{'todo'}} is a hash with todo ids as keys
14 my $self = { todo => $result->{'_xml'}->{'todoList'}->{'todo'},
15 0 todoIds => [sort keys %{$result->{'_xml'}->{'todoList'}->{'todo'}}],
16 todoIndex => -1,
17 success => $success,
18 error_code => $error_code,
19 error_message => $error_message,
20 };
21 0 bless $self, $class;
22 0 return $self;
23 }
24  
25 #return an array of todo ids
26 0 ▶sub get_todoIds {
Subroutine get_todoIds: not called CC=1 SCAR=6.9
Pod documented
27 0 my ($self) = @_;
28 0 return @{$self->{'todoIds'}};
29 }
30  
31 #return a reference to an array of todo ids
32 0 ▶sub get_ref_todoIds {
Subroutine get_ref_todoIds: not called CC=1 SCAR=6.9
Pod documented
33 0 my ($self) = @_;
34 0 return $self->{'todoIds'};
35 }
36  
37 #advance the todoIndex
38 0 ▶sub nextTodoId {
Subroutine nextTodoId: not called CC=2 SCAR=17.9
Pod documented
39 0 my ($self) = @_;
40 0 ▶ return 0 if $self->{'todoIndex'} == scalar(@{$self->{'todoIds'}}) - 1;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"todoIndex"} == scalar(@{$self->{"todoIds"};}) - 1 0 0 0
41 0 return $self->{'todoIds'}->[$self->{'todoIndex'}++];
42 }
43
44 #returns a list of tags
45 0 ▶sub get_tags {
Subroutine get_tags: not called CC=3 SCAR=24.8
Pod documented
46 0 my ($self, $todoId) = @_;
47 0 ▶ $todoId = $self->{'todoIds'}->[$self->{'todoIndex'}] if 0 == $#_;
Branch: 1 branch
BranchTrueFalseTotal
if 0 == $#_ 0 0 0
48 0 my $temp = $self->{'todo'}->{$todoId}->{'tags'};
49 0 ▶ return "" if ref($temp);#it's a hash if empty
Branch: 1 branch
BranchTrueFalseTotal
if ref $temp 0 0 0
50 0 $temp =~ s/\s+/ /;
51 0 return split(/ /, $temp);
52 }
53  
54 #gets the title for the todos
55 0 ▶sub get_title {
Subroutine get_title: not called CC=2 SCAR=17.9
Pod documented
56 0 my ($self, $todoId) = @_;
57 0 ▶ $todoId = $self->{'todoIds'}->[$self->{'todoIndex'}] if 0 == $#_;
Branch: 1 branch
BranchTrueFalseTotal
if 0 == $#_ 0 0 0
58 0 return $self->{'todo'}->{$todoId}->{'summary'};
59 }
60  
61 #get if the the todo is marked as done
62 #returns 1 if yes, 0 if not
63 0 ▶sub isDone {
Subroutine isDone: not called CC=2 SCAR=17.9
Pod documented
64 0 my ($self, $todoId) = @_;
65 0 ▶ $todoId = $self->{'todoIds'}->[$self->{'todoIndex'}] if 0 == $#_;
Branch: 1 branch
BranchTrueFalseTotal
if 0 == $#_ 0 0 0
66 0 return $self->{'todo'}->{$todoId}->{'done'};
67 }
68  
69 #returns the position of the todo in the list
70 0 ▶sub get_position {
Subroutine get_position: not called CC=2 SCAR=17.9
Pod documented
71 0 my ($self, $todoId) = @_;
72 0 ▶ $todoId = $self->{'todoIds'}->[$self->{'todoIndex'}] if 0 == $#_;
Branch: 1 branch
BranchTrueFalseTotal
if 0 == $#_ 0 0 0
73 0 return $self->{'todo'}->{$todoId}->{'position'};
74 }
75  
76 0 ▶sub get_externalUID {
Subroutine get_externalUID: not called CC=3 SCAR=24.8
Pod documented
77 0 my ($self, $todoId) = @_;
78 0 ▶ $todoId = $self->{'todoIds'}->[$self->{'todoIndex'}] if 0 == $#_;
Branch: 1 branch
BranchTrueFalseTotal
if 0 == $#_ 0 0 0
79 0 my $temp = $self->{'todo'}->{$todoId}->{'externalUID'};
80 0 ▶ return "" if ref($temp);#it's a hash if empty
Branch: 1 branch
BranchTrueFalseTotal
if ref $temp 0 0 0
81 0 $temp =~ s/\s+/ /;
82 0 return split(/ /, $temp);
83 }
84  
85  
86 1 1;
87 __END__
« API/Event.pm ↑ Summary API/Request.pm »