blib/lib/Alien/Build/Plugin/Fetch/Local.pm

filter: Statementstmt 98.0% 50 / 51 Branchbran 78.5% 11 / 14 Conditioncond 87.5% 7 / 8 MC/DCmcdc 60.0% 3 / 5 Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 91.9% 80 / 87 CC 11 SCAR 15.2
CC
11
Cov
93%
__ANON__
7.3
init
5.0
BEGIN
1.0
CRAP 4.6
« blib/lib/Alien/Build/Log/Abbreviate.pm ↑ Summary blib/lib/Alien/Build/Plugin/PkgConfig/MakeStatic.pm »
1 package Alien::Build::Plugin::Fetch::Local;
2  
3 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 ▶use 5.008004;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 9 ▶use Alien::Build::Plugin;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 9 ▶use File::chdir;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 9 ▶use Path::Tiny ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # ABSTRACT: Plugin for fetching a local file
11 9 our $VERSION = '2.88'; # VERSION
12  
13  
14 9 has '+url' => '';
15  
16  
17 9 has root => undef;
18  
19  
20 9 has ssl => 0;
21  
22 sub init
23 17 ▶{
Subroutine init: called CC=5 SCAR=16.1
Pod documented
24 17 my($self, $meta) = @_;
25  
26 17 ▶ $meta->prop->{start_url} ||= $self->url;
Condition100%3/3
$meta->prop->{"start_url"} ||= $self->url
l!l&&r!l&&!r
2123
MC/DC100%2/2
$meta->prop->{"start_url"} ||= $self->url
$meta->prop->{"start_url"} $self->url
Truth table100%3/3
A ||= B
A= $meta->prop->{"start_url"}B= $self->url
ABresult
1X1
011
000
27 17 ▶ $self->url($meta->prop->{start_url} || 'patch');
Condition100%2/2
$meta->prop->{'start_url'} || 'patch'
l!l
143
MC/DC100%1/1
$meta->prop->{'start_url'} || 'patch'
$meta->prop->{'start_url'}
Truth table100%2/2
A
A= $meta->prop->{'start_url'}
Aresult
11
00
28  
29 17 ▶ if($self->url =~ /^file:/)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->url =~ /^file:/) 1 16 17
30 {
31 1 $meta->add_requires('share' => 'URI' => 0 );
32 1 $meta->add_requires('share' => 'URI::file' => 0 );
33 1 $meta->add_requires('share' => 'URI::Escape' => 0 );
34 }
35  
36 {
37 17 my $root = $self->root;
38 17 ▶ if(defined $root)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $root) { } 1 16 17
39 {
40 1 $root = Path::Tiny->new($root)->absolute->stringify;
41 }
42 else
43 {
44 16 $root = "$CWD";
45 }
46 17 $self->root($root);
47 }
48  
49 20 ▶ $meta->register_hook( fetch => sub {
Subroutine __ANON__: called CC=7 SCAR=19.8
50 20 my($build, $path, %options) = @_;
51  
52 20 ▶ $build->log("plugin Fetch::Local does not support http_headers option") if $options{http_headers};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"http_headers"} 0 20 20
53  
54 20 ▶ $path ||= $self->url;
Condition66%2/3
$path ||= $self->url
l!l&&r!l&&!r
1280
MC/DC0%0/2
$path ||= $self->url
$path $self->url
Truth table66%2/3
A ||= B
A= $pathB= $self->url
ABresult
1X1
011
000
55  
56 20 ▶ if($path =~ /^file:/)
Branch: 1 branch
BranchTrueFalseTotal
if ($path =~ /^file:/) 2 18 20
57 {
58 2 my $root = URI::file->new($self->root);
59 2 my $url = URI->new_abs($path, $root);
60 2 $path = URI::Escape::uri_unescape($url->path);
61 2 ▶ $path =~ s{^/([a-z]:)}{$1}i if $^O eq 'MSWin32';
Branch: 1 branch
BranchTrueFalseTotal
if $^O eq "MSWin32" 0 2 2
62 }
63  
64 20 $path = Path::Tiny->new($path)->absolute($self->root);
65  
66 20 ▶ if(-d $path)
Branch: 2 branches
BranchTrueFalseTotal
if (-d $path) { } 4 16 20
elsif (-f $path) { } 16 0 16
67 {
68 return {
69 type => 'list',
70 protocol => 'file',
71 list => [
72 28 map { { filename => $_->basename, url => $_->stringify } }
73 4 sort { $a->basename cmp $b->basename } $path->children,
74 ],
75 };
76 }
77 elsif(-f $path)
78 {
79 return {
80 16 type => 'file',
81 filename => $path->basename,
82 path => $path->stringify,
83 tmp => 0,
84 protocol => 'file',
85 };
86 }
87 else
88 {
89 0 die "no such file or directory $path";
90 }
91  
92  
93 17 });
94 }
95  
96 9 1;
97  
98 __END__
« blib/lib/Alien/Build/Log/Abbreviate.pm ↑ Summary blib/lib/Alien/Build/Plugin/PkgConfig/MakeStatic.pm »