Calendar/Person.pm

filter: Statementstmt 25.0% 13 / 52 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 30.0% 3 / 10 Podpod 100% 6 / 6 totaltotal 24.7% 22 / 89 CC 10 SCAR 37.8
CC
10
Cov
18%
_do
90.0
new
6.0
name
2.0
CRAP 43.9
↑ Summary Calendar.pm »
1 package Net::Google::Calendar::Person;
2 {
3 6 $Net::Google::Calendar::Person::VERSION = '1.05';
4 }
5  
6 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 ▶use XML::Atom::Person;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ▶use base qw(XML::Atom::Person Net::Google::Calendar::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 6 my %allowed = (
11 attendeeStatus => [qw(accepted declined invited tentative)],
12 attendeeType => [qw(optional required)],
13 rel => [qw(attendee organizer performer speaker)],
14  
15 );
16  
17 =head1 NAME
18  
19 Net::Google::Calendar::Person - a thin wrapper round XML::Atom::Person
20  
21 =head1 METHODS
22  
23 =head2 new
24  
25 =cut
26  
27 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
28 0 my $class = shift;
29 0 my %opts = @_;
30 0 ▶ $opts{Version} = '1.0' unless exists $opts{Version};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opts{"Version"} 0 0 0
31 0 my $self = $class->SUPER::new(%opts);
32 0 $self->_initialize();
33 0 return $self;
34 }
35  
36  
37 =head2 name [name]
38  
39 A simple string value that can be used as a representation of this person.
40  
41 =cut
42  
43 0 ▶sub name {
Subroutine name: not called CC=1 SCAR=6.9
Pod documented
44 0 my $self = shift;
45 0 return $self->_do('@valueString', @_);
46 }
47  
48 =head2 email [email]
49  
50 Get or set the email of the person
51  
52 =cut
53  
54 0 ▶sub email {
Subroutine email: not called CC=1 SCAR=6.9
Pod documented
55 0 my $self = shift;
56 0 $self->_do('@email', @_);
57 }
58  
59 =head2 attendee_status [status]
60  
61 Get or set the status of event attendee.
62  
63 See:
64  
65 http://code.google.com/apis/gdata/elements.html#gdAttendeeStatus
66  
67 Takes or returns any of the values C<accepted>, C<declined>, C<invited>, C<tentative>.
68  
69 =cut
70  
71 0 ▶sub attendee_status {
Subroutine attendee_status: not called CC=1 SCAR=6.9
Pod documented
72 0 my $self = shift;
73 0 $self->_do('attendeeStatus', @_);
74 }
75  
76 =head2 attendee_type [type]
77  
78 Get or set the type of event attendee.
79  
80 See:
81  
82 http://code.google.com/apis/gdata/elements.html#gdAttendeeType
83  
84 Takes or returns any of the values C<optional>, C<required>.
85  
86 =cut
87  
88 0 ▶sub attendee_type {
Subroutine attendee_type: not called CC=1 SCAR=6.9
Pod documented
89 0 my $self = shift;
90 0 $self->_do('attendeeType', @_);
91 }
92  
93  
94 =head2 rel [relationship]
95  
96 =cut
97  
98 0 ▶sub rel {
Subroutine rel: not called CC=1 SCAR=6.9
Pod documented
99 0 my $self = shift;
100 0 $self->_do('@rel', @_);
101 }
102  
103  
104 0 ▶sub _do {
Subroutine _do: not called CC=9 SCAR=45.0
105 0 my $self = shift;
106 0 my $name = shift;
107 0 my $attr = ($name =~ s!^@!!);
108 0 $name =~ s!^gd:!!;
109 0 my $vals = $allowed{$name};
110 0 my $gd_ns = ''; # $self->{_gd_ns};
111
112 0 ▶ my $ns = (defined $vals)? "http://schemas.google.com/g/2005#event." : "";
Branch: 1 branch
BranchTrueFalseTotal
defined $vals ? : 0 0 0
113 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
114 0 my $new = shift;
115 0 $new =~ s!^$ns!!;
116 die "$new is not one of the allowed values for $name (".join(",", @$vals).")"
117 0 ▶ unless !defined $vals || grep { $new eq $_ } @$vals;
Branch: 1 branch
BranchTrueFalseTotal
unless not defined $vals or grep {$new eq $_;} @$vals 0 0 0
Condition0%0/3
not defined $vals or grep {$new eq $_;} @$vals
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $vals or grep {$new eq $_;} @$vals
not defined $vals grep {$new eq $_;} @$vals
Truth table0%0/3
not(A) or B
A= not defined $valsB= grep {$new eq $_;} @$vals
ABresult
1X1
011
000
118 0 ▶ if ($attr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attr) { } 0 0 0
119 #print "Setting attr $name to ${ns}${new}\n";
120 0 $self->set_attr($name, "${ns}${new}");
121 } else {
122 #print "Setting child gd:$name to ${ns}${new}\n";
123 0 $self->set($gd_ns, "gd:${name}", '', { value => "${ns}${new}" });
124 }
125 }
126 0 my $val;
127 0 ▶ if ($attr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attr) { } 0 0 0
128 0 $val = $self->get_attr($name);
129 } else {
130 0 my $tmp = $self->_my_get($gd_ns, "gd:${name}");
131 0 ▶ if (defined $tmp) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tmp) 0 0 0
132 0 $val = $tmp->getAttribute('value');
133 }
134 # else { print "Failed to get gd:${name}\n"; }
135 }
136 0 ▶ $val =~ s!^$ns!! if defined $val;
Branch: 1 branch
BranchTrueFalseTotal
if defined $val 0 0 0
137 0 return $val;
138 }
139 6 1;
↑ Summary Calendar.pm »