blib/lib/Alien/Build/Plugin/Decode/DirListing.pm

filter: Statementstmt 96.7% 30 / 31 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 95.1% 39 / 41 CC 2 SCAR 2.3
CC
2
Cov
94%
__ANON__
2.0
init
1.0
BEGIN
1.0
CRAP 1.3
« blib/lib/Alien/Build/Plugin/Core/Override.pm ↑ Summary blib/lib/Alien/Build/Plugin/Prefer/SortVersions.pm »
1 package Alien::Build::Plugin::Decode::DirListing;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use 5.008004;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Alien::Build::Plugin;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use File::Basename ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # ABSTRACT: Plugin to extract links from a directory listing
10 2 our $VERSION = '2.88'; # VERSION
11  
12  
13 sub init
14 2 ▶{
Subroutine init: called CC=1 SCAR=0.0
Pod documented
15 2 my($self, $meta) = @_;
16  
17 2 $meta->add_requires('share' => 'File::Listing' => 0);
18 2 $meta->add_requires('share' => 'URI' => 0);
19  
20 2 ▶ $meta->register_hook( decode => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
21 2 my(undef, $res) = @_;
22  
23 0 die "do not know how to decode @{[ $res->{type} ]}"
24 2 ▶ unless $res->{type} eq 'dir_listing';
Branch: 1 branch
BranchTrueFalseTotal
unless $res->{"type"} eq "dir_listing" 0 2 2
25  
26 2 my $base = URI->new($res->{base});
27  
28 return {
29 type => 'list',
30 list => [
31 map {
32 14 my($name) = @$_;
33 14 my $basename = $name;
34 14 $basename =~ s{/$}{};
35 14 my %h = (
36 filename => File::Basename::basename($basename),
37 url => URI->new_abs($name, $base)->as_string,
38 );
39 14 \%h;
40 } File::Listing::parse_dir($res->{content})
41 2 ],
42 };
43 2 });
44  
45 2 $self;
46 }
47  
48 2 1;
49  
50 __END__
« blib/lib/Alien/Build/Plugin/Core/Override.pm ↑ Summary blib/lib/Alien/Build/Plugin/Prefer/SortVersions.pm »