| 1 | package WWW::Deezer::Artist; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 5 | our $VERSION = '0.03'; | |||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use Moose::Util::TypeConstraints; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 5 | extends 'WWW::Deezer::Obj'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use WWW::Deezer; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 5 | ▶ | use WWW::Deezer::Album; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | # http://developers.deezer.com/api/artist | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 5 | has 'id', is => 'ro', isa => 'Int'; | |||||||||||||||||||||||||||
| 16 | 5 | has 'name', is => 'ro', isa => 'Str'; | |||||||||||||||||||||||||||
| 17 | 5 | has 'link', is => 'ro', isa => 'Str'; | |||||||||||||||||||||||||||
| 18 | 5 | has 'tracklist', is => 'ro', isa => 'Str'; | |||||||||||||||||||||||||||
| 19 | 5 | has 'share', is => 'ro', isa => 'Url'; | |||||||||||||||||||||||||||
| 20 | 5 | has 'picture', is => 'ro', isa => 'Url'; | |||||||||||||||||||||||||||
| 21 | 5 | has 'picture_small', is => 'ro', isa => 'Url'; | |||||||||||||||||||||||||||
| 22 | 5 | has 'picture_medium', is => 'ro', isa => 'Url'; | |||||||||||||||||||||||||||
| 23 | 5 | has 'picture_big', is => 'ro', isa => 'Url'; | |||||||||||||||||||||||||||
| 24 | 5 | has 'picture_xl', is => 'ro', isa => 'Url'; | |||||||||||||||||||||||||||
| 25 | 5 | has 'nb_album', is => 'rw', isa => 'Int'; | |||||||||||||||||||||||||||
| 26 | 5 | has 'nb_fan', is => 'rw', isa => 'Int'; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 5 | has 'radio' => ( | |||||||||||||||||||||||||||
| 29 | is => 'ro', | ||||||||||||||||||||||||||||
| 30 | isa => 'JSONBoolean', | ||||||||||||||||||||||||||||
| 31 | coerce => 1 | ||||||||||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 3 | ▶ | around BUILDARGS => sub { # allow create Artist object with single argument passed to constructor - deezer ID | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 35 | 3 | my ($orig, $class) = (shift, shift); | |||||||||||||||||||||||||||
| 36 | 3 | my $self = {}; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 3 | ▶ | if (@_ == 1 && !ref $_[0] ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@_ == 1 and not ref $_[0]
MC/DC100%2/2
@_ == 1 and not ref $_[0]
@_ == 1
not ref $_[0]
Truth table100%3/3
A and not(B)
A= @_ == 1B= not ref $_[0]
| |||||||||||||||||||||||||||||
| 39 | 1 | $self = $class->$orig( id => $_[0] ); | |||||||||||||||||||||||||||
| 40 | 1 | $self = WWW::Deezer->new->artist($_[0]); | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | else { | ||||||||||||||||||||||||||||
| 43 | # 2DO: deal with Bool and JSON::XS::Boolean=\1 in 'radio' argument | ||||||||||||||||||||||||||||
| 44 | 2 | $self = $class->$orig(@_); | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | 3 | return $self; | |||||||||||||||||||||||||||
| 47 | 5 | }; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | ▶ | around [qw/nb_fan nb_album/] => sub { # add here another attributes which need fetching from server | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 50 | 0 | my ($orig, $self) = (shift, shift); | |||||||||||||||||||||||||||
| 51 | 0 | my $attr = $self->$orig(@_); | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | unless (defined $attr) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | # fetch recreate artist. | ||||||||||||||||||||||||||||
| 55 | 0 | my $new_obj = $self->deezer_obj->artist($self->id); | |||||||||||||||||||||||||||
| 56 | 0 | $attr= $new_obj->$orig(@_); | |||||||||||||||||||||||||||
| 57 | 0 | $self->reinit_attr_values($new_obj); | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | return $attr; | |||||||||||||||||||||||||||
| 61 | 5 | }; | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 0 | ▶ | sub top { | ||||||||||||||||||||||||||
|
Subroutine
top: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 64 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 65 | 0 | return; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | ▶ | sub albums { | ||||||||||||||||||||||||||
|
Subroutine
albums: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 69 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 70 | 0 | return; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | sub comments { | ||||||||||||||||||||||||||
|
Subroutine
comments: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 74 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 75 | 0 | return; | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub fans { | ||||||||||||||||||||||||||
|
Subroutine
fans: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 79 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 80 | 0 | return; | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 0 | ▶ | sub related { | ||||||||||||||||||||||||||
|
Subroutine
related: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 84 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 85 | 0 | return; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 0 | ▶ | sub get_radio { | ||||||||||||||||||||||||||
|
Subroutine
get_radio: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 89 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 90 | 0 | return; | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 5 | 1; | |||||||||||||||||||||||||||