AnyPAN/Index/Merged.pm

filter: Statementstmt 76.3% 29 / 38 Branchbran 37.5% 3 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 71.1% 37 / 52 CC 7 SCAR 19.7
CC
7
Cov
70%
save_with_included_packages
10.7
BEGIN
1.0
BEGIN
1.0
CRAP 7.2
« AnyPAN/Agent.pm ↑ Summary AnyPAN/Index.pm »
1 package AnyPAN::Index::Merged;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use parent qw/AnyPAN::Index/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 use Class::Accessor::Lite
8 2 ▶ ro => [qw/multiplex_index sources source_cache logger/];
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶sub save_with_included_packages {
Subroutine save_with_included_packages: called CC=7 SCAR=23.7
Pod undocumented
11 1 my ($self, $storage) = @_;
12  
13 1 for my $source (@{ $self->sources }) {
14 3 my $index = $self->source_cache->get_or_fetch_index($source);
15  
16 3 my $previous_package_path = '';
17 3 for my $package_info (@{ $index->packages }) {
18 # skip contiguous packages for performance
19 3 ▶ next if $previous_package_path eq $package_info->canonicalized_path();
Branch: 1 branch
BranchTrueFalseTotal
if $previous_package_path eq $package_info->canonicalized_path 0 3 3
20 3 $previous_package_path = $package_info->canonicalized_path();
21  
22 # skip exists packages for performance
23 3 my $save_key = $source->package_path($package_info->canonicalized_path);
24 3 ▶ next if $storage->exists($save_key);
Branch: 1 branch
BranchTrueFalseTotal
if $storage->exists($save_key) 0 3 3
25  
26 3 my $package_path = eval {
27 3 $self->source_cache->get_or_fetch_package($source, $package_info);
28 };
29 3 ▶ if (my $e = $@) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $e = $@) 0 3 3
30 0 ▶ if (AnyPAN::Agent::Exception::NotFound->caught($e)) {
Branch: 1 branch
BranchTrueFalseTotal
if ("AnyPAN::Agent::Exception::NotFound"->caught($e)) 0 0 0
31 0 $self->logger->warn("skip package @{[ $package_info->path ]} on @{[ $source->name ]}");
32 0 next; # skip it
33 }
34 0 $self->logger->error("failed to fetch package @{[ $package_info->path ]} on @{[ $source->name ]}");
35 0 die $e;
36 }
37  
38 3 $storage->copy($package_path, $save_key);
39 }
40 }
41 1 $self->save($storage);
42 }
43  
44 2 1;
45 __END__
« AnyPAN/Agent.pm ↑ Summary AnyPAN/Index.pm »