Mapper/Persona/Myspace.pm

filter: Statementstmt 32.5% 13 / 40 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 13 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 50.0% 4 / 8 Podpod n/a totaltotal 23.9% 17 / 71 CC 9 SCAR 23.5
CC
9
Cov
23%
_fetch_id_from_google
20.0
_init
12.0
_fetch_id
12.0
CRAP 10.5
« Mapper/Persona/Flickr.pm ↑ Summary Mapper.pm »
1 package Net::Social::Mapper::Persona::Myspace;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use base qw(Net::Social::Mapper::Persona::Generic);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8  
9 =head1 NAME
10  
11 Net::Social::Mapper::Person::Myspace - the persona for a Myspace account
12  
13 =head2 SYNOPSIS
14  
15 See C<Net::Social::Mapper>
16  
17 =cut
18  
19 0 ▶sub _init {
Subroutine _init: not called CC=3 SCAR=24.8
20 0 my $self = shift;
21  
22 # Guess at a bunch of stuff
23 0 $self = $self->SUPER::_init;
24
25 0 ▶ my $id = ($self->{user} =~ m!^\d+$!) ? $self->{user} : $self->_fetch_id;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'user'} =~ /^\d+$/ ? : 0 0 0
26 0 $self->{id} = $id;
27 0 $self->{profile} = $self->{homepage} = "http://myspace.com/".$self->{user};
28 0 ▶ $self->{feeds} = defined $id? [ "http://blogs.myspace.com/Modules/BlogV2/Pages/RssFeed.aspx?friendID=".$self->{id} ] : [];
Branch: 1 branch
BranchTrueFalseTotal
defined $id ? : 0 0 0
29 0 return $self;
30 }
31  
32 0 ▶sub _fetch_id {
Subroutine _fetch_id: not called CC=3 SCAR=24.8
33 0 my $self = shift;
34 0 ▶ return $self->_fetch_id_from_google || $self->_fetch_id_from_page || undef;
Condition0%0/5
$self->_fetch_id_from_google || $self->_fetch_id_from_page || undef
l!l
00
$self->_fetch_id_from_google or $self->_fetch_id_from_page
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->_fetch_id_from_google || $self->_fetch_id_from_page || undef
$self->_fetch_id_from_google $self->_fetch_id_from_page
Truth table0%0/3
A or B
A= $self->_fetch_id_from_googleB= $self->_fetch_id_from_page
ABresult
1X1
011
000
35 }
36  
37 0 ▶sub _fetch_id_from_google {
Subroutine _fetch_id_from_google: not called CC=4 SCAR=30.0
38 0 my $self = shift;
39 0 my $page = $self->{homepage}; $page =~ s!/+$!!;
40 0 my %params = ( q => $page );
41 0 my $url = URI->new("http://socialgraph.apis.google.com/lookup");
42 0 $url->query_form(%params);
43 0 ▶ my $data = $self->mapper->get("$url") || return;
Condition0%0/2
$self->mapper->get("$url") || (return)
l!l
00
MC/DC0%0/1
$self->mapper->get("$url") || (return)
$self->mapper->get("$url")
Truth table0%0/2
A
A= $self->mapper->get("$url")
Aresult
11
00
44
45 0 my $res = eval { $self->_json->decode($data) };
46 0 ▶ my $node = $res->{nodes}->{$page} || {};
Condition0%0/2
$res->{'nodes'}{$page} || {}
l!l
00
MC/DC0%0/1
$res->{'nodes'}{$page} || {}
$res->{'nodes'}{$page}
Truth table0%0/2
A
A= $res->{'nodes'}{$page}
Aresult
11
00
47 0 ▶ my $rss = $node->{attributes}->{rss} || return;
Condition0%0/2
$node->{'attributes'}{'rss'} || (return)
l!l
00
MC/DC0%0/1
$node->{'attributes'}{'rss'} || (return)
$node->{'attributes'}{'rss'}
Truth table0%0/2
A
A= $node->{'attributes'}{'rss'}
Aresult
11
00
48 0 my ($id) = ($rss =~ m!friendID=(\d+)!i);
49 0 return $id;
50 }
51  
52 0 ▶sub _fetch_id_from_page {
Subroutine _fetch_id_from_page: not called CC=2 SCAR=17.9
53 0 my $self = shift;
54 0 my $page = $self->{homepage};
55 0 ▶ my $data = $self->mapper->get("$page") || return;
Condition0%0/2
$self->mapper->get("$page") || (return)
l!l
00
MC/DC0%0/1
$self->mapper->get("$page") || (return)
$self->mapper->get("$page")
Truth table0%0/2
A
A= $self->mapper->get("$page")
Aresult
11
00
56 0 my ($id) = ($data =~ m!"DisplayFriendId":(\d+)!);
57 0 return $id;
58 }
59  
60  
61 2 1;
62  
« Mapper/Persona/Flickr.pm ↑ Summary Mapper.pm »