Contacts/Group.pm

filter: Statementstmt 60.8% 28 / 46 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 41.6% 5 / 12 Podpod 0.0% 0 / 1 totaltotal 52.3% 33 / 63 CC 4 SCAR 18.7
CC
4
Cov
56%
_set_link
20.0
create_url
2.0
__ANON__
2.0
CRAP 6.5
« Contacts/Contact.pm ↑ Summary Contacts/Server.pm »
1 package WWW::Google::Contacts::Group;
2 {
3 17 $WWW::Google::Contacts::Group::VERSION = '0.38';
4 }
5  
6 17 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 17 ▶use MooseX::Types::Moose qw( Str );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 17 use WWW::Google::Contacts::Types qw(
9 Category
10 17 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 17 ▶use WWW::Google::Contacts::Meta::Attribute::Trait::XmlField;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 sub create_url {
15 0 ▶ my $self = shift;
Subroutine create_url: not called CC=1 SCAR=6.9
Pod undocumented
16 0 return sprintf( "%s://www.google.com/m8/feeds/groups/default/full",
17 $self->server->protocol );
18 }
19  
20 17 extends 'WWW::Google::Contacts::Base';
21  
22 17 with 'WWW::Google::Contacts::Roles::CRUD';
23  
24 17 has id => (
25 isa => Str,
26 is => 'ro',
27 writer => '_set_id',
28 predicate => 'has_id',
29 traits => ['XmlField'],
30 xml_key => 'id',
31 );
32  
33 has etag => (
34 isa => Str,
35 is => 'ro',
36 writer => '_set_etag',
37 predicate => 'has_etag',
38 traits => ['XmlField'],
39 xml_key => 'gd:etag',
40 0 ▶ include_in_xml => sub { 0 }, # This is set in HTTP headers
Subroutine __ANON__: not called CC=1 SCAR=6.9
41 17 );
42  
43 has category => (
44 isa => Category,
45 is => 'rw',
46 predicate => 'has_category',
47 traits => ['XmlField'],
48 xml_key => 'category',
49 0 ▶ default => sub { undef },
Subroutine __ANON__: not called CC=1 SCAR=6.9
50 17 coerce => 1,
51 );
52  
53 17 has title => (
54 isa => Str,
55 is => 'rw',
56 predicate => 'has_title',
57 traits => ['XmlField'],
58 xml_key => 'title',
59 is_element => 1,
60 );
61  
62 17 has member => (
63 is => 'ro',
64 lazy_build => 1,
65 );
66  
67 has link => (
68 is => 'rw',
69 trigger => \&_set_link,
70 traits => ['XmlField'],
71 xml_key => 'link',
72 0 ▶ include_in_xml => sub { 0 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
73 17 );
74  
75 # What to do with different link types
76 my $link_map =
77 0 ▶ { 'self' => sub { my ( $self, $link ) = @_; $self->_set_id( $link->{href} ) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
78 17 };
79  
80 sub _set_link {
81 0 ▶ my ( $self, $links ) = @_;
Subroutine _set_link: not called CC=4 SCAR=30.0
82 0 ▶ $links = ref($links) eq 'ARRAY' ? $links : [$links];
Branch: 1 branch
BranchTrueFalseTotal
ref $links eq 'ARRAY' ? : 0 0 0
83 0 foreach my $link ( @{$links} ) {
84 0 ▶ next unless ( defined $link_map->{ $link->{rel} } );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $$link_map{$link->{"rel"}} 0 0 0
85 0 my $code = $link_map->{ $link->{rel} };
86 0 $link->{href} =~ s{/full/}{/base/};
87 0 $self->$code($link);
88 }
89 }
90  
91 sub _build_member {
92 0 ▶ my $self = shift;
Subroutine _build_member: not called CC=1 SCAR=6.9
93 0 my $list =
94 WWW::Google::Contacts::ContactList->new( server => $self->server );
95 0 return $list->search( { group_membership => $self->id } );
96 }
97  
98 17 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
99 17 __PACKAGE__->meta->make_immutable;
100 17 1;
101 __END__
102  
103 =head1 SYNOPSIS
104  
105 use WWW::Google::Contacts;
106  
107 my $google = WWW::Google::Contacts->new( username => "your.username", password => "your.password" );
108  
109 my $group = $google->new_group;
110 $group->title("Lovers");
111  
112 =head1 METHODS
113  
114 =head2 $group->create
115  
116 Writes the group to your Google account.
117  
118 =head2 $group->retrieve
119  
120 Fetches group details from Google account.
121  
122 =head2 $group->update
123  
124 Updates existing group in your Google account.
125  
126 =head2 $group->delete
127  
128 Deletes group from your Google account.
129  
130 =head2 $group->create_or_update
131  
132 Creates or updates group, depending on if it already exists
133  
134 =head1 ATTRIBUTES
135  
136 All these attributes are gettable and settable on Group objects.
137  
138 =over 4
139  
140 =item title
141  
142 The title of the group
143  
144 $group->title("People I'm only 'friends' with because of the damn Facebook");
145  
146 =item member
147  
148 An array of members of the group
149  
150 foreach my $member (@{ $group->member }) {
151 print $member->full_name . " is a member of the group.\n";
152 }
153  
154 =back
155  
156 =head1 AUTHOR
157  
158 Magnus Erixzon <magnus@erixzon.com>
159  
160 =head1 COPYRIGHT AND LICENSE
161  
162 This software is copyright (c) 2010 by Magnus Erixzon / Fayland Lam.
163  
164 This is free software; you can redistribute it and/or modify it under
165 the same terms as perl itself.
166  
167 =cut
« Contacts/Contact.pm ↑ Summary Contacts/Server.pm »