line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
861
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
2
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
65
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package App::TaskBuilder; |
5
|
|
|
|
|
|
|
our $VERSION = '1.000'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
16
|
use File::Spec; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
8
|
1
|
|
|
1
|
|
5
|
use File::Path (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
9
|
1
|
|
|
1
|
|
6
|
use File::Basename (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
10
|
1
|
|
|
1
|
|
1352
|
use File::Temp (); |
|
1
|
|
|
|
|
23365
|
|
|
1
|
|
|
|
|
24
|
|
11
|
1
|
|
|
1
|
|
892
|
use File::Copy (); |
|
1
|
|
|
|
|
2933
|
|
|
1
|
|
|
|
|
26
|
|
12
|
1
|
|
|
1
|
|
7
|
use Cwd (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub _accessor { |
15
|
1
|
|
|
1
|
|
6
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
107
|
|
16
|
5
|
|
|
5
|
|
8
|
my $attr = shift; |
17
|
5
|
0
|
|
0
|
|
407
|
*$attr = sub { @_ > 1 ? ($_[0]->{$attr} = $_[1]) : $_[0]->{$attr} }; |
|
0
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
} |
19
|
1
|
|
|
1
|
|
16
|
BEGIN { _accessor($_) for qw(name require include version output) } |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new { |
22
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
23
|
0
|
|
|
|
|
|
my $self = bless {@_} => $class; |
24
|
0
|
|
0
|
|
|
|
$self->{output} ||= $self->vars->{dist_vname} . ".tar.gz"; |
25
|
0
|
0
|
|
|
|
|
%{ $self->require } = ( |
|
0
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
(map { |
27
|
0
|
|
|
|
|
|
my %r = %{ do($_) || die $@ }; |
|
0
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
( |
29
|
0
|
0
|
|
|
|
|
%{ $r{requires} || {} }, |
|
0
|
0
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
|
%{ $r{test_requires} || {} }, |
31
|
0
|
|
|
|
|
|
%{ $r{build_requires} || {} }, |
32
|
|
|
|
|
|
|
); |
33
|
0
|
|
|
|
|
|
} @{ $self->include }), |
34
|
0
|
|
|
|
|
|
%{ $self->require } |
35
|
|
|
|
|
|
|
); |
36
|
0
|
|
|
|
|
|
return $self; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _dist_name { |
40
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
41
|
0
|
|
|
|
|
|
(my $name = $self->name) =~ s/::/-/g; |
42
|
0
|
|
|
|
|
|
$name; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _file_name { |
46
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
47
|
0
|
|
|
|
|
|
my @parts = split /::/, ($self->name . '.pm'); |
48
|
0
|
|
|
|
|
|
File::Spec->catfile('lib', @parts); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub vars { |
52
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
53
|
1
|
|
|
1
|
|
1058
|
use Data::Dumper; |
|
1
|
|
|
|
|
7160
|
|
|
1
|
|
|
|
|
619
|
|
54
|
0
|
|
|
|
|
|
local $Data::Dumper::Terse = 1; |
55
|
0
|
|
|
|
|
|
my %v = ( |
56
|
|
|
|
|
|
|
mod_name => $self->name, |
57
|
|
|
|
|
|
|
dist_name => $self->_dist_name, |
58
|
|
|
|
|
|
|
mod_file => $self->_file_name, |
59
|
|
|
|
|
|
|
requires => Dumper($self->require), |
60
|
|
|
|
|
|
|
version => $self->version, |
61
|
|
|
|
|
|
|
); |
62
|
0
|
|
|
|
|
|
$v{dist_vname} = "$v{dist_name}-$v{version}"; |
63
|
0
|
0
|
|
|
|
|
return wantarray ? %v : \%v; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub run { |
67
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
68
|
0
|
|
|
|
|
|
my $old = Cwd::cwd; |
69
|
0
|
|
|
|
|
|
chdir(my $tmp = File::Temp::tempdir(CLEANUP => 1)); |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
my %v = $self->vars; |
72
|
0
|
0
|
|
|
|
|
mkdir $v{dist_vname}, 0755 or die "Can't mkdir $v{dist_vname}: $!"; |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
my $s = $self->templates(%v); |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
for my $path (keys %$s) { |
77
|
0
|
|
|
|
|
|
my $text = $s->{$path}; |
78
|
0
|
|
|
|
|
|
$path = "$v{dist_vname}/$path"; |
79
|
0
|
|
|
|
|
|
File::Path::mkpath(File::Basename::dirname($path)); |
80
|
0
|
0
|
|
|
|
|
open my $fh, '>', $path or die "Can't open $path: $!"; |
81
|
0
|
|
|
|
|
|
$text =~ s/\{\{(.+?)\}\}/$v{$1}/g; |
82
|
0
|
|
|
|
|
|
print $fh $text; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# XXX use Archive::Tar or something instead |
86
|
0
|
0
|
|
|
|
|
system("tar zcf $v{dist_vname}.tar.gz $v{dist_vname}") && exit($? >> 8); |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
chdir $old; |
89
|
0
|
0
|
|
|
|
|
File::Copy::copy "$tmp/$v{dist_vname}.tar.gz", $self->output |
90
|
|
|
|
|
|
|
or die "Can't copy to " . $self->output . ": $!"; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub _templates { |
94
|
0
|
|
|
0
|
|
|
my ($self, %v) = @_; |
95
|
|
|
|
|
|
|
return { |
96
|
0
|
|
|
|
|
|
'Makefile.PL' => <<'END', |
97
|
|
|
|
|
|
|
use strict; |
98
|
|
|
|
|
|
|
use warnings; |
99
|
|
|
|
|
|
|
use ExtUtils::MakeMaker; |
100
|
|
|
|
|
|
|
WriteMakefile( |
101
|
|
|
|
|
|
|
NAME => '{{mod_name}}', |
102
|
|
|
|
|
|
|
VERSION_FROM => '{{mod_file}}', |
103
|
|
|
|
|
|
|
ABSTRACT => 'install dependencies for {{mod_name}}', |
104
|
|
|
|
|
|
|
PREREQ_PM => {{requires}}, |
105
|
|
|
|
|
|
|
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, |
106
|
|
|
|
|
|
|
clean => { FILES => '{{dist_name}}-*' }, |
107
|
|
|
|
|
|
|
); |
108
|
|
|
|
|
|
|
END |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
'MANIFEST' => <<'END', |
111
|
|
|
|
|
|
|
Makefile.PL |
112
|
|
|
|
|
|
|
README |
113
|
|
|
|
|
|
|
{{mod_file}} |
114
|
|
|
|
|
|
|
END |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
'README' => <<'END', |
117
|
|
|
|
|
|
|
This is an automatically generated README for {{mod_name}}. |
118
|
|
|
|
|
|
|
END |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
$v{mod_file} => <<'END', |
121
|
|
|
|
|
|
|
package |
122
|
|
|
|
|
|
|
{{mod_name}}; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
${{mod_name}}::VERSION = |
125
|
|
|
|
|
|
|
{{version}}; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
1; |
128
|
|
|
|
|
|
|
END |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
}; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
1; |
134
|
|
|
|
|
|
|
__END__ |