| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | $self->version( $self->just_version( $self->path ) ) unless $self->version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/6
$self->follow and $newer
$self->name || $self->just_name($self->path)
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
Truth table0%0/3
A || B
A= $self->nameB= $self->just_name($self->path)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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)
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)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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)
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)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | catdir( $self->directory, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | $self->name || $self->just_name( $self->path ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | return if -e $to; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | if ( -e catfile( $self->source, 'dist.ini' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
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")
-e catfile($self->source, "dist.ini") and not -e catfile($self->source, "configure") and not -e catfile($self->source, "Makefile.PL")
-e catfile($self->source, "dist.ini") and not -e catfile($self->source, "configure")
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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||