| 1 | package App::lcpan::Cmd::dist2author; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 1 | ▶ | use 5.010001; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | |||||||||||||||
| 7 | 1 | require App::lcpan; | |||||||||||||
| 8 | |||||||||||||||
| 9 | 1 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |||||||||||||
| 10 | 1 | our $DATE = '2023-09-26'; # DATE | |||||||||||||
| 11 | 1 | our $DIST = 'App-lcpan'; # DIST | |||||||||||||
| 12 | 1 | our $VERSION = '1.074'; # VERSION | |||||||||||||
| 13 | |||||||||||||||
| 14 | 1 | our %SPEC; | |||||||||||||
| 15 | |||||||||||||||
| 16 | 1 | $SPEC{'handle_cmd'} = { | |||||||||||||
| 17 | v => 1.1, | ||||||||||||||
| 18 | summary => 'Get author of distribution(s)', | ||||||||||||||
| 19 | args => { | ||||||||||||||
| 20 | %App::lcpan::common_args, | ||||||||||||||
| 21 | %App::lcpan::dists_args, | ||||||||||||||
| 22 | }, | ||||||||||||||
| 23 | }; | ||||||||||||||
| 24 | 0 | ▶ | sub handle_cmd { | ||||||||||||
|
Subroutine
handle_cmd: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||
| 25 | 0 | my %args = @_; | |||||||||||||
| 26 | |||||||||||||||
| 27 | 0 | my $state = App::lcpan::_init(\%args, 'ro'); | |||||||||||||
| 28 | 0 | my $dbh = $state->{dbh}; | |||||||||||||
| 29 | |||||||||||||||
| 30 | 0 | my $dists = $args{dists}; | |||||||||||||
| 31 | |||||||||||||||
| 32 | my $dists_s = join(",", map { | ||||||||||||||
| 33 | 0 | my $d=$_; $d =~ s/::/-/g; $dbh->quote($d); | |||||||||||||
| 34 | } @$dists); | ||||||||||||||
| 35 | |||||||||||||||
| 36 | 0 | my $sth = $dbh->prepare("SELECT | |||||||||||||
| 37 | f.dist_name dist, | ||||||||||||||
| 38 | f.cpanid author | ||||||||||||||
| 39 | FROM file f | ||||||||||||||
| 40 | WHERE f.dist_name IN ($dists_s)"); | ||||||||||||||
| 41 | |||||||||||||||
| 42 | 0 | my @res; | |||||||||||||
| 43 | 0 | $sth->execute; | |||||||||||||
| 44 | 0 | ▶ | while (my $row = $sth->fetchrow_hashref) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 45 | 0 | push @res, $row; | |||||||||||||
| 46 | } | ||||||||||||||
| 47 | |||||||||||||||
| 48 | 0 | ▶ | if (@$dists == 1) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 49 | 0 | @res = map { $_->{author} } @res; | |||||||||||||
| 50 | 0 | ▶ | if (!@res) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 51 | 0 | return [404, "No such dist"]; | |||||||||||||
| 52 | } elsif (@res == 1) { | ||||||||||||||
| 53 | 0 | return [200, "OK", $res[0]]; | |||||||||||||
| 54 | } else { | ||||||||||||||
| 55 | 0 | return [200, "OK", \@res]; | |||||||||||||
| 56 | } | ||||||||||||||
| 57 | } | ||||||||||||||
| 58 | |||||||||||||||
| 59 | 0 | [200, "OK", \@res, {'table.fields'=>[qw/dist author/]}]; | |||||||||||||
| 60 | } | ||||||||||||||
| 61 | |||||||||||||||
| 62 | 1 | 1; | |||||||||||||
| 63 | # ABSTRACT: Get author of distribution(s) | ||||||||||||||
| 64 | |||||||||||||||
| 65 | __END__ | ||||||||||||||