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

filter: Statementstmt 77.5% 38 / 49 Branchbran 41.6% 5 / 12 Conditioncond 40.0% 2 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 69.2% 54 / 78 CC 9 SCAR 18.9
CC
9
Cov
68%
__ANON__
12.9
init
5.6
BEGIN
1.0
CRAP 6.6
« blib/lib/Test/Alien/Run.pm ↑ Summary blib/lib/Alien/Build/Plugin/Test/Mock.pm »
1 package Alien::Build::Plugin::Fetch::LocalDir;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use 5.008004;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use Alien::Build::Plugin;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use File::chdir;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Path::Tiny ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # ABSTRACT: Plugin for fetching a local directory
11 4 our $VERSION = '2.88'; # VERSION
12  
13  
14 4 has root => undef;
15  
16  
17 4 has ssl => 0;
18  
19 sub init
20 4 ▶{
Subroutine init: called CC=4 SCAR=17.3
Pod documented
21 4 my($self, $meta) = @_;
22  
23 4 ▶ my $url = $meta->prop->{start_url} || 'patch';
Condition50%1/2
$meta->prop->{'start_url'} || 'patch'
l!l
40
MC/DC0%0/1
$meta->prop->{'start_url'} || 'patch'
$meta->prop->{'start_url'}
Truth table50%1/2
A
A= $meta->prop->{'start_url'}
Aresult
11
00
24  
25 4 $meta->add_requires('configure' => 'Alien::Build::Plugin::Fetch::LocalDir' => '0.72' );
26  
27 4 ▶ if($url =~ /^file:/)
Branch: 1 branch
BranchTrueFalseTotal
if ($url =~ /^file:/) 0 4 4
28 {
29 0 $meta->add_requires('share' => 'URI' => 0 );
30 0 $meta->add_requires('share' => 'URI::file' => 0 );
31 }
32  
33 {
34 4 my $root = $self->root;
35 4 ▶ if(defined $root)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $root) { } 0 4 4
36 {
37 0 $root = Path::Tiny->new($root)->absolute->stringify;
38 }
39 else
40 {
41 4 $root = "$CWD";
42 }
43 4 $self->root($root);
44 }
45  
46 $meta->register_hook(
47 4 ▶ fetch => sub {
Subroutine __ANON__: called CC=6 SCAR=25.6
48 4 my($build, $path, %options) = @_;
49  
50 4 ▶ $build->log("plugin Fetch::LocalDir does not support http_headers option") if $options{http_headers};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"http_headers"} 0 4 4
51  
52 4 ▶ $path ||= $url;
Condition33%1/3
$path ||= $url
l!l&&r!l&&!r
040
MC/DC0%0/2
$path ||= $url
$path $url
Truth table33%1/3
A ||= B
A= $pathB= $url
ABresult
1X1
011
000
53  
54 4 ▶ if($path =~ /^file:/)
Branch: 1 branch
BranchTrueFalseTotal
if ($path =~ /^file:/) 0 4 4
55 {
56 0 my $root = URI::file->new($self->root);
57 0 my $url = URI->new_abs($path, $root);
58 0 $path = $url->path;
59 0 ▶ $path =~ s{^/([a-z]:)}{$1}i if $^O eq 'MSWin32';
Branch: 1 branch
BranchTrueFalseTotal
if $^O eq "MSWin32" 0 0 0
60 }
61  
62 4 $path = Path::Tiny->new($path)->absolute($self->root);
63  
64 4 ▶ if(-d $path)
Branch: 1 branch
BranchTrueFalseTotal
if (-d $path) { } 4 0 4
65 {
66 return {
67 4 type => 'file',
68 filename => $path->basename,
69 path => $path->stringify,
70 tmp => 0,
71 protocol => 'file',
72 };
73 }
74 else
75 {
76 0 $build->log("path $path is not a directory");
77 0 $build->log("(you specified $url with root @{[ $self->root ]})");
78 0 die "$path is not a directory";
79 }
80 }
81 4 );
82 }
83  
84 4 1;
85  
86 __END__
« blib/lib/Test/Alien/Run.pm ↑ Summary blib/lib/Alien/Build/Plugin/Test/Mock.pm »