| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package WebService::Audioscrobbler::Tag; | 
| 2 | 1 |  |  | 1 |  | 5 | use warnings; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 22 |  | 
| 3 | 1 |  |  | 1 |  | 4 | use strict; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 21 |  | 
| 4 | 1 |  |  | 1 |  | 5 | use CLASS; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 4 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 1 |  |  | 1 |  | 27 | use base 'WebService::Audioscrobbler::Base'; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 293 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | =head1 NAME | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | WebService::Audioscrobbler::Tag - An object-oriented interface to the Audioscrobbler WebService API | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | =cut | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | our $VERSION = '0.07'; | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | # postfix related accessors | 
| 17 |  |  |  |  |  |  | CLASS->mk_classaccessor("base_resource_path"  => "tag"); | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | # requering stuff | 
| 20 |  |  |  |  |  |  | CLASS->tracks_class->require or die($@); | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | # object accessors | 
| 23 |  |  |  |  |  |  | CLASS->mk_accessors(qw/name url/); | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | *title = \&name; | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | This module implements an object oriented abstraction of a tag within the | 
| 30 |  |  |  |  |  |  | Audioscrobbler database. | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | use WebService::Audioscrobbler::Tag; | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | my $ws = WebService::Audioscrobbler->new; | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | # get an object for the tag named 'foo' | 
| 37 |  |  |  |  |  |  | my $tag = $ws->tag('foo'); | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | # retrieves tracks tagged with 'foo' | 
| 40 |  |  |  |  |  |  | my @tracks = $tag->tracks; | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | # prints url for viewing aditional tag info | 
| 43 |  |  |  |  |  |  | print $tag->url; | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | This module inherits from L. | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | =head1 FIELDS | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | =head2 C | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | =head2 C | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | The name (title) of a given tag. | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | =head2 C | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | URL for aditional info about the tag. | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | =cut | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | =head1 METHODS | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | =cut | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | =head2 C | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | =head2 C | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | Creates a new object using either the given C<$artist> and C<$title> or the | 
| 70 |  |  |  |  |  |  | C<\%fields> hashref. The data fetcher object is a mandatory parameter and must | 
| 71 |  |  |  |  |  |  | be provided either as the second parameter or inside the C<\%fields> hashref. | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | =cut | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | sub new { | 
| 76 | 0 |  |  | 0 | 1 |  | my $class = shift; | 
| 77 | 0 |  |  |  |  |  | my ($name_or_fields, $data_fetcher) = @_; | 
| 78 |  |  |  |  |  |  |  | 
| 79 | 0 | 0 |  |  |  |  | my $self = $class->SUPER::new( | 
| 80 |  |  |  |  |  |  | ref $name_or_fields eq 'HASH' ? | 
| 81 |  |  |  |  |  |  | $name_or_fields : { name => $name_or_fields, data_fetcher => $data_fetcher } | 
| 82 |  |  |  |  |  |  | ); | 
| 83 |  |  |  |  |  |  |  | 
| 84 | 0 | 0 |  |  |  |  | $self->croak("No data fetcher provided") | 
| 85 |  |  |  |  |  |  | unless $self->data_fetcher; | 
| 86 |  |  |  |  |  |  |  | 
| 87 | 0 |  |  |  |  |  | return $self; | 
| 88 |  |  |  |  |  |  | } | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | =head2 C | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | Retrieves the tags's top tracks as available on Audioscrobbler's database. | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | Returns either a list of tracks or a reference to an array of tracks when called | 
| 95 |  |  |  |  |  |  | in list context or scalar context, respectively. The tracks are returned as | 
| 96 |  |  |  |  |  |  | L objects by default. | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | =cut | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | =head2 C | 
| 101 |  |  |  |  |  |  |  | 
| 102 |  |  |  |  |  |  | Retrieves the tag's top artists as available on Audioscrobbler's database. | 
| 103 |  |  |  |  |  |  |  | 
| 104 |  |  |  |  |  |  | Returns either a list of artists or a reference to an array of artists when called | 
| 105 |  |  |  |  |  |  | in list context or scalar context, respectively. The tags are returned as | 
| 106 |  |  |  |  |  |  | L objects by default. | 
| 107 |  |  |  |  |  |  |  | 
| 108 |  |  |  |  |  |  | =cut | 
| 109 |  |  |  |  |  |  |  | 
| 110 |  |  |  |  |  |  | sub tags { | 
| 111 | 0 |  |  | 0 | 1 |  | shift->croak("Audioscrobbler doesn't provide data regarding tags which are related to other tags"); | 
| 112 |  |  |  |  |  |  | } | 
| 113 |  |  |  |  |  |  |  | 
| 114 |  |  |  |  |  |  | =head2 C | 
| 115 |  |  |  |  |  |  |  | 
| 116 |  |  |  |  |  |  | Returns the URL from which other URLs used for fetching tag info will be | 
| 117 |  |  |  |  |  |  | derived from. | 
| 118 |  |  |  |  |  |  |  | 
| 119 |  |  |  |  |  |  | =cut | 
| 120 |  |  |  |  |  |  |  | 
| 121 |  |  |  |  |  |  | sub resource_path { | 
| 122 | 0 |  |  | 0 | 1 |  | my $self = shift; | 
| 123 | 0 |  |  |  |  |  | $self->uri_builder( $self->name ); | 
| 124 |  |  |  |  |  |  | } | 
| 125 |  |  |  |  |  |  |  | 
| 126 |  |  |  |  |  |  | =head1 AUTHOR | 
| 127 |  |  |  |  |  |  |  | 
| 128 |  |  |  |  |  |  | Nilson Santos Figueiredo Júnior, C<<  >> | 
| 129 |  |  |  |  |  |  |  | 
| 130 |  |  |  |  |  |  | =head1 COPYRIGHT & LICENSE | 
| 131 |  |  |  |  |  |  |  | 
| 132 |  |  |  |  |  |  | Copyright 2006-2007 Nilson Santos Figueiredo Júnior, all rights reserved. | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | This program is free software; you can redistribute it and/or modify it | 
| 135 |  |  |  |  |  |  | under the same terms as Perl itself. | 
| 136 |  |  |  |  |  |  |  | 
| 137 |  |  |  |  |  |  | =cut | 
| 138 |  |  |  |  |  |  |  | 
| 139 |  |  |  |  |  |  | 1; # End of WebService::Audioscrobbler::Tag |