1use strict; 2use warnings; 3package MetaCPAN::Client::Author; 4# ABSTRACT: An Author data object 5$MetaCPAN::Client::Author::VERSION = '2.029000'; 6use Moo; 7use Ref::Util qw< is_arrayref >; 8 9with 'MetaCPAN::Client::Role::Entity'; 10 11my %known_fields = ( 12 scalar => [qw< 13 city 14 country 15 gravatar_url 16 name 17 ascii_name 18 pauseid 19 region 20 updated 21 user 22 >], 23 24 arrayref => [qw< 25 donation 26 email 27 perlmongers 28 profile 29 website 30 >], 31 32 hashref => [qw< 33 blog 34 extra 35 links 36 release_count 37 >], 38); 39 40sub BUILDARGS { 41 my ( $class, %args ) = @_; 42 43 my $email = $args{'email'} || []; 44 $args{'email'} = [ $email ] 45 unless is_arrayref($email); 46 47 return \%args; 48} 49 50my @known_fields = 51 map { @{ $known_fields{$_} } } qw< scalar arrayref hashref >; 52 53foreach my $field ( @known_fields ) { 54 has $field => ( 55 is => 'ro', 56 lazy => 1, 57 default => sub { 58 my $self = shift; 59 return $self->data->{$field}; 60 }, 61 ); 62} 63 64sub _known_fields { \%known_fields } 65 66sub releases { 67 my $self = shift; 68 my $id = $self->pauseid; 69 70 return $self->client->release({ 71 all => [ 72 { author => $id }, 73 { status => 'latest' }, 74 ] 75 }); 76} 77 78sub dir { $_[0]->links->{cpan_directory} } 79 80sub metacpan_url { "https://metacpan.org/author/" . $_[0]->pauseid } 81 821; 83 84__END__ 85 86=pod 87 88=encoding UTF-8 89 90=head1 NAME 91 92MetaCPAN::Client::Author - An Author data object 93 94=head1 VERSION 95 96version 2.029000 97 98=head1 SYNOPSIS 99 100 my $author = $mcpan->author('MICKEY'); 101 102=head1 DESCRIPTION 103 104a MetaCPAN author entity object. 105 106=head1 ATTRIBUTES 107 108=head2 pauseid 109 110The author's pause id, which is a string like C<MICKEY> or C<XSAWYERX>. 111 112=head2 name 113 114The author's full name, if they've provided this in their MetaCPAN 115profile. This may contain Unicode characters. 116 117=head2 ascii_name 118 119An ASCII-only version of the author's full name, if they've provided this in 120their MetaCPAN profile. 121 122=head2 city 123 124The author's city, if they've provided this in their MetaCPAN profile. 125 126=head2 region 127 128The author's region, if they've provided this in their MetaCPAN profile. 129 130=head2 country 131 132The author's country, if they've provided this in their MetaCPAN profile. 133 134=head2 updated 135 136An ISO8601 datetime string like C<2016-11-19T12:41:46> indicating when the 137author last updated their MetaCPAN profile. This is always provided in UTC. 138 139=head2 dir 140 141The author's CPAN directory, which is something like C<id/P/PE/PERLER>. 142 143=head2 gravatar_url 144 145The author's gravatar.com user URL, if they have one. This URL is generated 146using PAUSEID@cpan.org. 147 148=head2 user 149 150The user's internal MetaCPAN id. 151 152=head2 donation 153 154This is an arrayref containing zero or more hashrefs. Each hashref contains 155two keys, C<name> and C<id>. The known names are currently C<paypal>, 156C<wishlist>, and C<flattr>. The id will be an appropriate id or URL for the 157thing in question. 158 159This may be empty if the author has not provided this information in their 160MetaCPAN profile. 161 162For example: 163 164 [ 165 { "name" => "paypal", "id" => "brian.d.foy@gmail.com" }, 166 { "name" => "wishlist", "id" => "http://amzn.com/w/4O7IX9ZNQJR" }, 167 ], 168 169=head2 email 170 171This is an arrayref containing zero or more email addresses that the author 172has added to their MetaCPAN profile. Note that this does I<not> include the 173C<AUTHOR@cpan.org> email address that all CPAN authors have. 174 175=head2 website 176 177This is an arrayref of website URLs provided by the author in their MetaCPAN 178profile. 179 180=head2 profile 181 182This is an arrayref containing zero or more hashrefs. Each hashref contains 183two keys, C<name> and C<id>. The names are things like C<github> or 184C<stackoverflow>. The id will be an appropriate id for the site in question. 185 186For example: 187 188 [ 189 { name => "amazon", id => "B002MRC39U" }, 190 { name => "stackoverflow", id => "brian-d-foy" }, 191 ] 192 193This may be empty if the author has not provided this information in their 194MetaCPAN profile. 195 196=head2 perlmongers 197 198This is an arrayref containing zero or more hashrefs. Each hashref contains 199two keys, C<name> and C<url>. The names are things like C<Minneapolis.pm>. 200 201This may be empty if the author has not provided this information in their 202MetaCPAN profile. 203 204=head2 links 205 206This is a hashref where the keys are a link type, and the values are URLs. The 207currently known keys are: 208 209=over 4 210 211=item * cpan_directory 212 213The author's CPAN directory. 214 215=item * backpan_directory 216 217The author's BackCPAN directory. 218 219=item * cpantesters_reports 220 221The author's CPAN Testers Reports page. 222 223=item * cpantesters_matrix 224 225The author's CPAN Testers matrix page. 226 227=item * cpants 228 229The author's CPANTS page. 230 231=item * metacpan_explorer 232 233A link to the MetaCPAN explorer site pre-populated with a request for the 234author's profile. 235 236=back 237 238=head2 blog 239 240This is an arrayref containing zer or more hashrefs. Each hashref contains two 241keys, C<url> and C<feed>. For example: 242 243 { 244 url => "http://blogs.perl.org/users/brian_d_foy/", 245 feed => "http://blogs.perl.org/users/brian_d_foy/atom.xml", 246 } 247 248=head2 release_count 249 250This is a hashref containing counts for various types of releases. The known 251keys are: 252 253=over 4 254 255=item * cpan 256 257The total number of distribution uplaods the author currently has on CPAN. 258 259=item * latest 260 261The total number of unique distributions the author currently has on CPAN. 262 263=item * backpan-only 264 265The number of distribution uploads currently only available via BackPAN. 266 267=back 268 269=head2 extra 270 271Returns a hashref. The contents of this are entirely arbitrary and will vary 272by author. 273 274=head1 METHODS 275 276=head2 BUILDARGS 277 278Ensures format of the input. 279 280=head2 releases 281 282 my $releases = $author->releases(); 283 284This method returns a L<MetaCPAN::Client::ResultSet> of 285L<MetaCPAN::Client::Release> objects. It includes all of the author's releases 286with the C<latest> status. 287 288=head2 metacpan_url 289 290Returns a link to the author's page on MetaCPAN. 291 292=head1 AUTHORS 293 294=over 4 295 296=item * 297 298Sawyer X <xsawyerx@cpan.org> 299 300=item * 301 302Mickey Nasriachi <mickey@cpan.org> 303 304=back 305 306=head1 COPYRIGHT AND LICENSE 307 308This software is copyright (c) 2016 by Sawyer X. 309 310This is free software; you can redistribute it and/or modify it under 311the same terms as the Perl 5 programming language system itself. 312 313=cut 314