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   116 use strict;
  20         33  
  20         696  
2 20     20   77 use warnings;
  20         35  
  20         1292  
3             package MetaCPAN::Client::Author;
4             # ABSTRACT: An Author data object
5             $MetaCPAN::Client::Author::VERSION = '2.043000';
6 20     20   90 use Moo;
  20         28  
  20         104  
7 20     20   6525 use Ref::Util qw< is_arrayref >;
  20         49  
  20         7983  
8              
9             with 'MetaCPAN::Client::Role::Entity';
10              
11             my %known_fields = (
12             scalar => [qw<
13             city
14             country
15             gravatar_url
16             is_pause_custodial_account
17             name
18             asciiname
19             pauseid
20             region
21             updated
22             user
23             >],
24              
25             arrayref => [qw<
26             donation
27             email
28             perlmongers
29             profile
30             website
31             >],
32              
33             hashref => [qw<
34             blog
35             extra
36             links
37             release_count
38             >],
39             );
40              
41             sub BUILDARGS {
42 14     14 1 5338 my ( $class, %args ) = @_;
43              
44 14   50     71 my $email = $args{'email'} || [];
45 14 50       41 $args{'email'} = [ $email ]
46             unless is_arrayref($email);
47              
48 14         285 return \%args;
49             }
50              
51             my @known_fields =
52             map { @{ $known_fields{$_} } } qw< scalar arrayref hashref >;
53              
54             foreach my $field ( @known_fields ) {
55             has $field => (
56             is => 'ro',
57             lazy => 1,
58             default => sub {
59             my $self = shift;
60             return $self->data->{$field};
61             },
62             );
63             }
64              
65 14     14   32 sub _known_fields { \%known_fields }
66              
67             sub releases {
68 1     1 1 35 my $self = shift;
69 1         15 my $id = $self->pauseid;
70              
71 1         37 return $self->client->release({
72             all => [
73             { author => $id },
74             { status => 'latest' },
75             ]
76             });
77             }
78              
79 0     0 1   sub dir { $_[0]->links->{cpan_directory} }
80              
81 0     0 1   sub metacpan_url { "https://metacpan.org/author/" . $_[0]->pauseid }
82              
83             1;
84              
85             __END__