File: Author.pm

package info (click to toggle)
libmetacpan-client-perl 2.025000-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 560 kB
  • sloc: perl: 2,456; makefile: 6
file content (313 lines) | stat: -rw-r--r-- 6,409 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
use strict;
use warnings;
package MetaCPAN::Client::Author;
# ABSTRACT: An Author data object
$MetaCPAN::Client::Author::VERSION = '2.025000';
use Moo;
use Ref::Util qw< is_arrayref >;

with 'MetaCPAN::Client::Role::Entity';

my %known_fields = (
    scalar => [qw<
        city
        country
        gravatar_url
        name
        ascii_name
        pauseid
        region
        updated
        user
    >],

    arrayref => [qw<
        donation
        email
        perlmongers
        profile
        website
    >],

    hashref => [qw<
        blog
        extra
        links
        release_count
    >],
);

sub BUILDARGS {
    my ( $class, %args ) = @_;

    my $email = $args{'email'} || [];
    $args{'email'} = [ $email ]
        unless is_arrayref($email);

    return \%args;
}

my @known_fields =
    map { @{ $known_fields{$_} } } qw< scalar arrayref hashref >;

foreach my $field ( @known_fields ) {
    has $field => (
        is      => 'ro',
        lazy    => 1,
        default => sub {
            my $self = shift;
            return $self->data->{$field};
        },
    );
}

sub _known_fields { \%known_fields }

sub releases {
    my $self = shift;
    my $id   = $self->pauseid;

    return $self->client->release({
            all => [
                { author => $id      },
                { status => 'latest' },
            ]
        });
}

sub dir { $_[0]->links->{cpan_directory} }

sub metacpan_url { "https://metacpan.org/author/" . $_[0]->pauseid }

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

MetaCPAN::Client::Author - An Author data object

=head1 VERSION

version 2.025000

=head1 SYNOPSIS

    my $author = $mcpan->author('MICKEY');

=head1 DESCRIPTION

a MetaCPAN author entity object.

=head1 ATTRIBUTES

=head2 pauseid

The author's pause id, which is a string like C<MICKEY> or C<XSAWYERX>.

=head2 name

The author's full name, if they've provided this in their MetaCPAN
profile. This may contain Unicode characters.

=head2 ascii_name

An ASCII-only version of the author's full name, if they've provided this in
their MetaCPAN profile.

=head2 city

The author's city, if they've provided this in their MetaCPAN profile.

=head2 region

The author's region, if they've provided this in their MetaCPAN profile.

=head2 country

The author's country, if they've provided this in their MetaCPAN profile.

=head2 updated

An ISO8601 datetime string like C<2016-11-19T12:41:46> indicating when the
author last updated their MetaCPAN profile. This is always provided in UTC.

=head2 dir

The author's CPAN directory, which is something like C<id/P/PE/PERLER>.

=head2 gravatar_url

The author's gravatar.com user URL, if they have one. This URL is generated
using PAUSEID@cpan.org.

=head2 user

The user's internal MetaCPAN id.

=head2 donation

This is an arrayref containing zero or more hashrefs. Each hashref contains
two keys, C<name> and C<id>. The known names are currently C<paypal>,
C<wishlist>, and C<flattr>. The id will be an appropriate id or URL for the
thing in question.

This may be empty if the author has not provided this information in their
MetaCPAN profile.

For example:

    [
        { "name" => "paypal",   "id" => "brian.d.foy@gmail.com" },
        { "name" => "wishlist", "id" => "http://amzn.com/w/4O7IX9ZNQJR" },
    ],

=head2 email

This is an arrayref containing zero or more email addresses that the author
has added to their MetaCPAN profile. Note that this does I<not> include the
C<AUTHOR@cpan.org> email address that all CPAN authors have.

=head2 website

This is an arrayref of website URLs provided by the author in their MetaCPAN
profile.

=head2 profile

This is an arrayref containing zero or more hashrefs. Each hashref contains
two keys, C<name> and C<id>. The names are things like C<github> or
C<stackoverflow>. The id will be an appropriate id for the site in question.

For example:

    [
        { name => "amazon",        id => "B002MRC39U"  },
        { name => "stackoverflow", id => "brian-d-foy" },
    ]

This may be empty if the author has not provided this information in their
MetaCPAN profile.

=head2 perlmongers

This is an arrayref containing zero or more hashrefs. Each hashref contains
two keys, C<name> and C<url>. The names are things like C<Minneapolis.pm>.

This may be empty if the author has not provided this information in their
MetaCPAN profile.

=head2 links

This is a hashref where the keys are a link type, and the values are URLs. The
currently known keys are:

=over 4

=item * cpan_directory

The author's CPAN directory.

=item * backpan_directory

The author's BackCPAN directory.

=item * cpantesters_reports

The author's CPAN Testers Reports page.

=item * cpantesters_matrix

The author's CPAN Testers matrix page.

=item * cpants

The author's CPANTS page.

=item * metacpan_explorer

A link to the MetaCPAN explorer site pre-populated with a request for the
author's profile.

=back

=head2 blog

This is an arrayref containing zer or more hashrefs. Each hashref contains two
keys, C<url> and C<feed>. For example:

    {
        url  => "http://blogs.perl.org/users/brian_d_foy/",
        feed => "http://blogs.perl.org/users/brian_d_foy/atom.xml",
    }

=head2 release_count

This is a hashref containing counts for various types of releases. The known
keys are:

=over 4

=item * cpan

The total number of distribution uplaods the author currently has on CPAN.

=item * latest

The total number of unique distributions the author currently has on CPAN.

=item * backpan-only

The number of distribution uploads currently only available via BackPAN.

=back

=head2 extra

Returns a hashref. The contents of this are entirely arbitrary and will vary
by author.

=head1 METHODS

=head2 BUILDARGS

Ensures format of the input.

=head2 releases

    my $releases = $author->releases();

This method returns a L<MetaCPAN::Client::ResultSet> of
L<MetaCPAN::Client::Release> objects. It includes all of the author's releases
with the C<latest> status.

=head2 metacpan_url

Returns a link to the author's page on MetaCPAN.

=head1 AUTHORS

=over 4

=item *

Sawyer X <xsawyerx@cpan.org>

=item *

Mickey Nasriachi <mickey@cpan.org>

=back

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by Sawyer X.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut