blib/lib/CPAN/Audit/Discover/CpanfileSnapshot.pm untested

filter: Statementstmt 0.0% 0 / 26 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 47 CC 4 SCAR 24.0
CC
4
Cov
0%
discover
20.0
new
2.0
BEGIN
2.0
CRAP 11.0
1 package CPAN::Audit::Discover::CpanfileSnapshot;
2 use strict;
3 use warnings;
4 use CPAN::DistnameInfo;
5  
6 our $VERSION = "1.001";
7  
8 sub new {
9 my $class = shift;
10  
11 my $self = {};
12 bless $self, $class;
13  
14 return $self;
15 }
16  
17 sub discover {
18 my $self = shift;
19 my ($cpanfile_snapshot_path) = @_;
20  
21 open my $fh, '<', $cpanfile_snapshot_path or die $!;
22  
23 my @deps;
24 while ( defined( my $line = <$fh> ) ) {
25 if ( $line =~ m/pathname: ([^\s]+)/ ) {
26 next unless my $d = CPAN::DistnameInfo->new($1);
27  
28 next unless $d->dist && $d->version;
29  
30 push @deps,
31 {
32 dist => $d->dist,
33 version => $d->version,
34 };
35 }
36 }
37  
38 close $fh;
39  
40 return @deps;
41 }
42  
43 1;