File Coverage

blib/lib/MetaCPAN/API/Author.pm
Criterion Covered Total %
statement 21 30 70.0
branch 3 10 30.0
condition 0 3 0.0
subroutine 6 6 100.0
pod 1 1 100.0
total 31 50 62.0


line stmt bran cond sub pod time code
1 17     17   404146 use strict;
  17         38  
  17         788  
2 17     17   89 use warnings;
  17         72  
  17         1661  
3             package MetaCPAN::API::Author;
4              
5             our $VERSION = '0.52';
6              
7 17     17   132 use Carp;
  17         77  
  17         1674  
8 17     17   656 use Moo::Role;
  17         18748  
  17         153  
9 17     17   10994 use namespace::autoclean;
  17         23416  
  17         233  
10              
11             # /author/{author}
12             sub author {
13 2     2 1 1753 my $self = shift;
14 2         5 my ( $url, %extra_opts );
15              
16 2 100       8 if ( @_ == 1 ) {
    50          
17 1         3 $url = 'author/' . shift;
18             } elsif ( @_ == 2 ) {
19 0         0 my %opts = @_;
20              
21 0 0       0 if ( defined $opts{'pauseid'} ) {
    0          
22 0         0 $url = "author/" . $opts{'pauseid'};
23             } elsif ( defined $opts{'search'} ) {
24 0         0 my $search_opts = $opts{'search'};
25              
26 0 0 0     0 croak "'search' key must be hashref"
27             unless ref $search_opts && ref $search_opts eq 'HASH';
28              
29 0         0 %extra_opts = %{$search_opts};
  0         0  
30 0         0 $url = 'author/_search';
31             } else {
32 0         0 croak 'Unknown option given';
33             }
34             } else {
35 1         144 croak 'Please provide an author PAUSEID or a "search"';
36             }
37              
38 1         9 return $self->fetch( $url, %extra_opts );
39             }
40              
41             1;
42              
43             __END__