Menlo/Index/Mirror.pm untested

filter: Statementstmt 0.0% 0 / 33 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 56 CC 3 SCAR 16.1
CC
3
Cov
0%
refresh_index
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 5.0
1 package Menlo::Index::Mirror;
2 use strict;
3 use parent qw(CPAN::Common::Index::Mirror);
4 use Class::Tiny qw(fetcher);
5  
6 use File::Basename ();
7 use File::Spec ();
8 use URI ();
9  
10 our $HAS_IO_UNCOMPRESS_GUNZIP = eval { require IO::Uncompress::Gunzip };
11  
12 my %INDICES = (
13 # mailrc => 'authors/01mailrc.txt.gz',
14 packages => 'modules/02packages.details.txt.gz',
15 );
16  
17 sub refresh_index {
18 my $self = shift;
19 for my $file ( values %INDICES ) {
20 my $remote = URI->new_abs( $file, $self->mirror );
21 $remote =~ s/\.gz$//
22 unless $HAS_IO_UNCOMPRESS_GUNZIP;
23 my $local = File::Spec->catfile( $self->cache, File::Basename::basename($file) );
24 $self->fetcher->($remote, $local)
25 or Carp::croak( "Cannot fetch $remote to $local");
26 if ($HAS_IO_UNCOMPRESS_GUNZIP) {
27 ( my $uncompressed = $local ) =~ s/\.gz$//;
28 IO::Uncompress::Gunzip::gunzip( $local, $uncompressed )
29 or Carp::croak "gunzip failed: $IO::Uncompress::Gunzip::GunzipError\n";
30 }
31 }
32 }
33  
34 1;