blib/lib/Shipwright/Source/Directory.pm

filter: Statementstmt 57.4% 31 / 54 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 21 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 64.2% 9 / 14 Podpod 100% 3 / 3 totaltotal 37.0% 43 / 116 CC 14 SCAR 35.9
CC
14
Cov
36%
run
72.0
_cmd
56.0
path
2.0
CRAP 36.4
« blib/lib/Shipwright/Backend/FS.pm ↑ Summary blib/lib/Shipwright/Source/Compressed.pm »
1 package Shipwright::Source::Directory;
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 2 ▶use Shipwright::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use File::Spec::Functions qw/catfile catdir rel2abs/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use File::Copy::Recursive qw/rcopy/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Cwd qw/getcwd/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use base qw/Shipwright::Source::Base/;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 =head2 new
13  
14 =cut
15  
16 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
17 1 my $class = shift;
18 1 my $self = $class->SUPER::new(@_);
19 1 my $s = $self->source;
20 1 $s =~ s{/$}{}; # trim the last / to let cp work as we like
21 1 $self->source(rel2abs $s);
22 1 return $self;
23 }
24  
25 =head2 run
26  
27 =cut
28  
29 0 ▶sub run {
Subroutine run: not called CC=8 SCAR=42.8
Pod documented
30 0 my $self = shift;
31  
32 0 ▶ $self->name( $self->just_name( $self->path ) ) unless $self->name;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->name 0 0 0
33 0 ▶ $self->version( $self->just_version( $self->path ) ) unless $self->version;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->version 0 0 0
34 0 $self->log->info( 'running source ' . $self->name . ': ' . $self->source );
35  
36 0 $self->_update_version( $self->name, $self->version );
37  
38 $self->_update_url( $self->name, 'directory:' . $self->source )
39 0 ▶ unless $self->{_no_update_url};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_no_update_url"} 0 0 0
40  
41 0 my $newer = $self->_cmd; # if we really get something new
42  
43 0 $self->SUPER::run(@_);
44  
45 # follow only if --follow and we really added new stuff.
46 0 ▶ $self->_follow(
Branch: 1 branch
BranchTrueFalseTotal
if $self->follow and $newer 0 0 0
Condition0%0/6
$self->follow and $newer
!ll&&!rl&&r
000
$self->name || $self->just_name($self->path)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->follow and $newer
$self->follow $newer
MC/DC0%0/2
$self->name || $self->just_name($self->path)
$self->name $self->just_name($self->path)
Truth table0%0/3
A and B
A= $self->followB= $newer
ABresult
0X0
100
111
Truth table0%0/3
A || B
A= $self->nameB= $self->just_name($self->path)
ABresult
1X1
011
000
47 catdir(
48 $self->directory, $self->name || $self->just_name( $self->path )
49 )
50 ) if $self->follow && $newer;
51 0 ▶ return catdir( $self->directory,
Condition0%0/3
$self->name || $self->just_name($self->path)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->name || $self->just_name($self->path)
$self->name $self->just_name($self->path)
Truth table0%0/3
A || B
A= $self->nameB= $self->just_name($self->path)
ABresult
1X1
011
000
52 $self->name || $self->just_name( $self->path ) );
53 }
54  
55 =head2 path
56  
57 return the basename of source
58  
59 =cut
60  
61 0 ▶sub path {
Subroutine path: not called CC=1 SCAR=6.9
Pod documented
62 0 my $self = shift;
63 0 return basename $self->source;
64 }
65  
66 0 ▶sub _cmd {
Subroutine _cmd: not called CC=7 SCAR=40.3
67 0 my $self = shift;
68 0 ▶ my $to =
Condition0%0/3
$self->name || $self->just_name($self->path)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->name || $self->just_name($self->path)
$self->name $self->just_name($self->path)
Truth table0%0/3
A || B
A= $self->nameB= $self->just_name($self->path)
ABresult
1X1
011
000
69 catdir( $self->directory,
70 $self->name || $self->just_name( $self->path ) );
71 0 ▶ return if -e $to;
Branch: 1 branch
BranchTrueFalseTotal
if -e $to 0 0 0
72  
73 0 ▶ if ( -e catfile( $self->source, 'dist.ini' )
Branch: 1 branch
BranchTrueFalseTotal
if (-e catfile($self->source, 'dist.ini') and not -e catfile($self->source, 'configure') and not -e catfile($self->source, 'Makefile.PL') and not -e catfile($self->source, 'Build.PL')) { } 0 0 0
Condition0%0/9
-e catfile($self->source, "dist.ini") and not -e catfile($self->source, "configure") and not -e catfile($self->source, "Makefile.PL") and not -e catfile($self->source, "Build.PL")
!ll&&!rl&&r
000
-e catfile($self->source, "dist.ini") and not -e catfile($self->source, "configure") and not -e catfile($self->source, "Makefile.PL")
!ll&&!rl&&r
000
-e catfile($self->source, "dist.ini") and not -e catfile($self->source, "configure")
!ll&&!rl&&r
000
MC/DC0%0/4
-e catfile($self->source, "dist.ini") and not -e catfile($self->source, "configure") and not -e catfile($self->source, "Makefile.PL") and not -e catfile($self->source, "Build.PL")
-e catfile($self->source, "dist.ini") not -e catfile($self->source, "configure") not -e catfile($self->source, "Makefile.PL") not -e catfile($self->source, "Build.PL")
Truth table0%0/5
A and not(B) and not(C) and not(D)
A= -e catfile($self->source, "dist.ini")B= not -e catfile($self->source, "configure")C= not -e catfile($self->source, "Makefile.PL")D= not -e catfile($self->source, "Build.PL")
ABCDresult
0XXX0
10XX0
110X0
11100
11111
74 && !-e catfile( $self->source, 'configure' )
75 && !-e catfile( $self->source, 'Makefile.PL' )
76 && !-e catfile( $self->source, 'Build.PL' ) )
77 {
78 0 my $old = getcwd();
79 # assume it's a Dist::Zilla dist
80 0 ▶ return sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
81 0 chdir $self->source;
82 0 run_cmd( [ $ENV{SHIPWRIGHT_DZIL}, 'build', '--in', $to ] );
83 0 chdir $old;
84 0 };
85 }
86 else {
87 0 ▶ return sub { rcopy( $self->source, $to ) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
88 }
89 }
90  
91 2 1;
92  
93 __END__
« blib/lib/Shipwright/Backend/FS.pm ↑ Summary blib/lib/Shipwright/Source/Compressed.pm »