line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Shipwright::Source::Directory; |
2
|
2
|
|
|
2
|
|
1284
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
64
|
|
3
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
52
|
|
4
|
2
|
|
|
2
|
|
10
|
use Shipwright::Util; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
200
|
|
5
|
2
|
|
|
2
|
|
10
|
use File::Spec::Functions qw/catfile catdir rel2abs/; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
112
|
|
6
|
2
|
|
|
2
|
|
15
|
use File::Basename; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
123
|
|
7
|
2
|
|
|
2
|
|
10
|
use File::Copy::Recursive qw/rcopy/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
79
|
|
8
|
2
|
|
|
2
|
|
9
|
use Cwd qw/getcwd/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
78
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
8
|
use base qw/Shipwright::Source::Base/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
916
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head2 new |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
1
|
|
|
1
|
1
|
2
|
my $class = shift; |
18
|
1
|
|
|
|
|
7
|
my $self = $class->SUPER::new(@_); |
19
|
1
|
|
|
|
|
4
|
my $s = $self->source; |
20
|
1
|
|
|
|
|
3
|
$s =~ s{/$}{}; # trim the last / to let cp work as we like |
21
|
1
|
|
|
|
|
7
|
$self->source(rel2abs $s); |
22
|
1
|
|
|
|
|
29
|
return $self; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head2 run |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub run { |
30
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
|
$self->name( $self->just_name( $self->path ) ) unless $self->name; |
33
|
0
|
0
|
|
|
|
|
$self->version( $self->just_version( $self->path ) ) unless $self->version; |
34
|
0
|
|
|
|
|
|
$self->log->info( 'running source ' . $self->name . ': ' . $self->source ); |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
$self->_update_version( $self->name, $self->version ); |
37
|
|
|
|
|
|
|
|
38
|
0
|
0
|
|
|
|
|
$self->_update_url( $self->name, 'directory:' . $self->source ) |
39
|
|
|
|
|
|
|
unless $self->{_no_update_url}; |
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
|
0
|
0
|
|
|
|
$self->_follow( |
|
|
|
0
|
|
|
|
|
47
|
|
|
|
|
|
|
catdir( |
48
|
|
|
|
|
|
|
$self->directory, $self->name || $self->just_name( $self->path ) |
49
|
|
|
|
|
|
|
) |
50
|
|
|
|
|
|
|
) if $self->follow && $newer; |
51
|
0
|
|
0
|
|
|
|
return catdir( $self->directory, |
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
|
|
|
|
|
|
|
sub path { |
62
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
63
|
0
|
|
|
|
|
|
return basename $self->source; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub _cmd { |
67
|
0
|
|
|
0
|
|
|
my $self = shift; |
68
|
0
|
|
0
|
|
|
|
my $to = |
69
|
|
|
|
|
|
|
catdir( $self->directory, |
70
|
|
|
|
|
|
|
$self->name || $self->just_name( $self->path ) ); |
71
|
0
|
0
|
|
|
|
|
return if -e $to; |
72
|
|
|
|
|
|
|
|
73
|
0
|
0
|
0
|
|
|
|
if ( -e catfile( $self->source, 'dist.ini' ) |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
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
|
|
|
|
|
|
|
return sub { |
81
|
0
|
|
|
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
|
|
|
0
|
|
|
return sub { rcopy( $self->source, $to ) }; |
|
0
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |