cpm/Worker/Resolver.pm untested

filter: Statementstmt 0.0% 0 / 20 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 46 CC 4 SCAR 24.0
CC
4
Cov
0%
work
20.0
new
2.0
BEGIN
2.0
CRAP 11.0
1 package App::cpm::Worker::Resolver;
2 use v5.24;
3 use warnings;
4 use experimental qw(lexical_subs signatures);
5  
6 sub new ($class, $ctx, %argv) {
7 bless { impl => $argv{impl} }, $class;
8 }
9  
10 sub work ($self, $ctx, $task) {
11 local $ctx->{logger}{context} = $task->{package};
12 my $result = $self->{impl}->resolve($ctx, $task);
13 if ($result and !$result->{error}) {
14 $result->{ok} = 1;
15 my $msg = sprintf "Resolved %s (%s) -> %s", $task->{package}, $task->{version_range} || 0,
16 $result->{uri} . ($result->{from} ? " from $result->{from}" : "");
17 $ctx->log($msg);
18 return $result;
19 } else {
20 $ctx->log($result->{error}) if $result and $result->{error};
21 $ctx->log(sprintf "Failed to resolve %s", $task->{package});
22 return { ok => 0 };
23 }
24 }
25  
26 1;