| 1 | package App::lcpan::Cmd::nearest_dists; | ||||||||||
| 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 = '2022-03-27'; # DATE | |||||||||
| 11 | 1 | our $DIST = 'App-lcpan-CmdBundle-nearest'; # DIST | |||||||||
| 12 | 1 | our $VERSION = '0.003'; # VERSION | |||||||||
| 13 | |||||||||||
| 14 | 1 | our %SPEC; | |||||||||
| 15 | |||||||||||
| 16 | $SPEC{handle_cmd} = { | ||||||||||
| 17 | 1 | v => 1.1, | |||||||||
| 18 | summary => 'List dists with names nearest to a specified name', | ||||||||||
| 19 | args => { | ||||||||||
| 20 | %App::lcpan::dist_args, | ||||||||||
| 21 | }, | ||||||||||
| 22 | }; | ||||||||||
| 23 | |||||||||||
| 24 | 0 | ▶ | sub handle_cmd { | ||||||||
|
Subroutine
handle_cmd: not called CC=2 SCAR=17.9
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 $sth = $dbh->prepare("SELECT dist_name FROM file WHERE dist_name IS NOT NULL"); | |||||||||
| 31 | 0 | $sth->execute; | |||||||||
| 32 | 0 | my @names; | |||||||||
| 33 | 0 | ▶ | while (my ($name) = $sth->fetchrow_array) { push @names, $name } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | |||||||||||
| 35 | 0 | require Text::Fuzzy; | |||||||||
| 36 | 0 | my $tf = Text::Fuzzy->new($args{dist}); | |||||||||
| 37 | |||||||||||
| 38 | 0 | [200, "OK", [$tf->nearestv(\@names)]]; | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 1 | 1; | |||||||||
| 42 | # ABSTRACT: List dists with names nearest to a specified name | ||||||||||
| 43 | |||||||||||
| 44 | __END__ | ||||||||||