| 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
| |||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||
| 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
$self->_fetch_id_from_google or $self->_fetch_id_from_page
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
| |||||||||||||||||||||||||
| 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)
MC/DC0%0/1
$self->mapper->get("$url") || (return)
$self->mapper->get("$url")
Truth table0%0/2
A
A= $self->mapper->get("$url")
| |||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||
| 45 | 0 | my $res = eval { $self->_json->decode($data) }; | |||||||||||||||||||||||
| 46 | 0 | ▶ | my $node = $res->{nodes}->{$page} || {}; | ||||||||||||||||||||||
|
Condition0%0/2
$res->{'nodes'}{$page} || {}
MC/DC0%0/1
$res->{'nodes'}{$page} || {}
$res->{'nodes'}{$page}
Truth table0%0/2
A
A= $res->{'nodes'}{$page}
| |||||||||||||||||||||||||
| 47 | 0 | ▶ | my $rss = $node->{attributes}->{rss} || return; | ||||||||||||||||||||||
|
Condition0%0/2
$node->{'attributes'}{'rss'} || (return)
MC/DC0%0/1
$node->{'attributes'}{'rss'} || (return)
$node->{'attributes'}{'rss'}
Truth table0%0/2
A
A= $node->{'attributes'}{'rss'}
| |||||||||||||||||||||||||
| 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)
MC/DC0%0/1
$self->mapper->get("$page") || (return)
$self->mapper->get("$page")
Truth table0%0/2
A
A= $self->mapper->get("$page")
| |||||||||||||||||||||||||
| 56 | 0 | my ($id) = ($data =~ m!"DisplayFriendId":(\d+)!); | |||||||||||||||||||||||
| 57 | 0 | return $id; | |||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||
| 61 | 2 | 1; | |||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||