| 1 | package WWW::Deezer::Album; | ||||||||||||||||||||||||||||
| 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::Artist; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | # http://developers.deezer.com/api/album | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 5 | has 'id' => (is => 'ro', isa => 'Int'); | |||||||||||||||||||||||||||
| 16 | 5 | has 'title' => (is => 'ro', isa => 'Str'); | |||||||||||||||||||||||||||
| 17 | 5 | has 'link' => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||
| 18 | 5 | has 'cover' => (is => 'ro', isa => 'Str'); | |||||||||||||||||||||||||||
| 19 | 5 | has 'cover_small' => (is => 'ro', isa => 'Str'); | |||||||||||||||||||||||||||
| 20 | 5 | has 'cover_medium' => (is => 'ro', isa => 'Str'); | |||||||||||||||||||||||||||
| 21 | 5 | has 'cover_big' => (is => 'ro', isa => 'Str'); | |||||||||||||||||||||||||||
| 22 | 5 | has 'cover_xl' => (is => 'ro', isa => 'Str'); | |||||||||||||||||||||||||||
| 23 | 5 | has 'genre_id' => (is => 'rw', isa => 'Int'); | |||||||||||||||||||||||||||
| 24 | 5 | has 'label' => (is => 'ro', isa => 'Str'); | |||||||||||||||||||||||||||
| 25 | 5 | has 'duration' => (is => 'ro', isa => 'Int'); | |||||||||||||||||||||||||||
| 26 | 5 | has 'fans' => (is => 'ro', isa => 'Int'); | |||||||||||||||||||||||||||
| 27 | 5 | has 'rating' => (is => 'ro', isa => 'Int'); | |||||||||||||||||||||||||||
| 28 | 5 | has 'release_date' => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||
| 29 | 5 | has 'available' => (is => 'ro'); | |||||||||||||||||||||||||||
| 30 | 5 | has 'genres' => (is => 'ro'); | |||||||||||||||||||||||||||
| 31 | 5 | has 'nb_tracks' => (is => 'ro'); | |||||||||||||||||||||||||||
| 32 | 5 | has 'upc' => (is => 'ro', isa => 'Str'); | |||||||||||||||||||||||||||
| 33 | 5 | has 'record_type' => (is => 'ro', isa => 'Str'); | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 5 | has 'artist' => ( | |||||||||||||||||||||||||||
| 36 | is => 'ro', | ||||||||||||||||||||||||||||
| 37 | isa => 'Ref', | ||||||||||||||||||||||||||||
| 38 | weak_ref => 1 | ||||||||||||||||||||||||||||
| 39 | ); # 2do: change Ref to Object | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 5 | has 'tracks' => (is => 'ro'); | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 1 | ▶ | around BUILDARGS => sub { # allow create Album object with single argument passed to constructor - deezer ID | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=13.0
| |||||||||||||||||||||||||||||
| 44 | 1 | my ($orig, $class) = (shift, shift); | |||||||||||||||||||||||||||
| 45 | 1 | my $self = {}; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 1 | ▶ | if (@_ == 1 && !ref $_[0] ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ == 1 and not ref $_[0]
MC/DC0%0/2
@_ == 1 and not ref $_[0]
@_ == 1
not ref $_[0]
Truth table33%1/3
A and not(B)
A= @_ == 1B= not ref $_[0]
| |||||||||||||||||||||||||||||
| 48 | 0 | $self = $class->$orig( id => $_[0] ); | |||||||||||||||||||||||||||
| 49 | 0 | $self = WWW::Deezer->new->album($_[0]); | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | else { | ||||||||||||||||||||||||||||
| 52 | 1 | $self = $class->$orig(@_); | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | 1 | return $self; | |||||||||||||||||||||||||||
| 55 | 5 | }; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | around [qw/genre_id link release_date upc genres nb_tracks record_type/] => sub { # add here another attributes which need fetching from server | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 58 | 0 | my ($orig, $self) = (shift, shift); | |||||||||||||||||||||||||||
| 59 | 0 | my $attr = $self->$orig(@_); | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | unless (defined $attr) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | # fetch recreate album. | ||||||||||||||||||||||||||||
| 63 | 0 | my $new_obj = $self->deezer_obj->album($self->id); | |||||||||||||||||||||||||||
| 64 | 0 | $attr = $new_obj->$orig(@_); | |||||||||||||||||||||||||||
| 65 | 0 | $self->reinit_attr_values($new_obj); | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | return $attr; | |||||||||||||||||||||||||||
| 69 | 5 | }; | |||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub comments { | ||||||||||||||||||||||||||
|
Subroutine
comments: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 72 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 73 | 0 | return; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | ▶ | sub fans_list { | ||||||||||||||||||||||||||
|
Subroutine
fans_list: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 77 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 5 | 1; | |||||||||||||||||||||||||||