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 19     19   143 use strict;
  19         42  
  19         2009  
2 19     19   114 use warnings;
  19         42  
  19         2280  
3             package MetaCPAN::Client::Author;
4             # ABSTRACT: An Author data object
5             $MetaCPAN::Client::Author::VERSION = '2.029000';
6 19     19   108 use Moo;
  19         37  
  19         139  
7 19     19   7045 use Ref::Util qw< is_arrayref >;
  19         46  
  19         7376  
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 31     31 1 8182 my ( $class, %args ) = @_;
42              
43 31   50     147 my $email = $args{'email'} || [];
44 31 50       91 $args{'email'} = [ $email ]
45             unless is_arrayref($email);
46              
47 31         500 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 31     31   82 sub _known_fields { \%known_fields }
65              
66             sub releases {
67 1     1 1 32 my $self = shift;
68 1         17 my $id = $self->pauseid;
69              
70 1         15 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__