File Coverage

blib/lib/MetaCPAN/Client/Author.pm
Criterion Covered Total %
statement 20 22 90.9
branch 1 2 50.0
condition 1 2 50.0
subroutine 7 9 77.7
pod 4 4 100.0
total 33 39 84.6


line stmt bran cond sub pod time code
1 20     20   140 use strict;
  20         48  
  20         887  
2 20     20   112 use warnings;
  20         45  
  20         1778  
3             package MetaCPAN::Client::Author;
4             # ABSTRACT: An Author data object
5             $MetaCPAN::Client::Author::VERSION = '2.040000';
6 20     20   123 use Moo;
  20         36  
  20         160  
7 20     20   8548 use Ref::Util qw< is_arrayref >;
  20         46  
  20         10267  
8              
9             with 'MetaCPAN::Client::Role::Entity';
10              
11             my %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              
40             sub BUILDARGS {
41 13     13 1 7568 my ( $class, %args ) = @_;
42              
43 13   50     91 my $email = $args{'email'} || [];
44 13 50       60 $args{'email'} = [ $email ]
45             unless is_arrayref($email);
46              
47 13         273 return \%args;
48             }
49              
50             my @known_fields =
51             map { @{ $known_fields{$_} } } qw< scalar arrayref hashref >;
52              
53             foreach 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              
64 13     13   32 sub _known_fields { \%known_fields }
65              
66             sub releases {
67 1     1 1 62 my $self = shift;
68 1         35 my $id = $self->pauseid;
69              
70 1         26 return $self->client->release({
71             all => [
72             { author => $id },
73             { status => 'latest' },
74             ]
75             });
76             }
77              
78 0     0 1   sub dir { $_[0]->links->{cpan_directory} }
79              
80 0     0 1   sub metacpan_url { "https://metacpan.org/author/" . $_[0]->pauseid }
81              
82             1;
83              
84             __END__