line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Install::MicroTemplate; |
2
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
5
|
1
|
|
|
1
|
|
18
|
use 5.008_001; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
43
|
|
6
|
1
|
|
|
1
|
|
5
|
use base qw(Module::Install::Base); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
693
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub render_mt { |
9
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
10
|
0
|
0
|
|
|
|
|
return unless $Module::Install::AUTHOR; |
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
|
|
|
my ($src, $dst) = @_; |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
$self->postamble(<<"..."); |
15
|
|
|
|
|
|
|
$dst: $src |
16
|
|
|
|
|
|
|
$^X -Iinc -e 'use Module::Install::MicroTemplate; Module::Install::MicroTemplate->_render()' "$src" "$dst" |
17
|
|
|
|
|
|
|
... |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
$self->build_requires( 'Text::MicroTemplate' => '0.05' ); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub _render { |
23
|
0
|
0
|
|
0
|
|
|
die "[BUG] The number of \@ARGV should be 2.but you gave @{[ scalar @ARGV ]}" unless @ARGV == 2; |
|
0
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
my ($src, $dst) = @ARGV; |
25
|
0
|
|
|
|
|
|
require Text::MicroTemplate; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $tmpl = sub { |
28
|
0
|
|
|
0
|
|
|
my $fname = shift; |
29
|
0
|
0
|
|
|
|
|
open my $fh, '<', $fname or die $!; |
30
|
0
|
|
|
|
|
|
my $out = do { local $/; <$fh> }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
close $fh; |
32
|
0
|
|
|
|
|
|
return $out; |
33
|
0
|
|
|
|
|
|
}->($src); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $content = sub { |
36
|
0
|
|
|
0
|
|
|
my $tmpl = shift; |
37
|
0
|
|
|
|
|
|
my $mt = Text::MicroTemplate->new( |
38
|
|
|
|
|
|
|
template => $tmpl, |
39
|
|
|
|
|
|
|
escape_func => undef, # do not escape! |
40
|
|
|
|
|
|
|
); |
41
|
0
|
|
|
|
|
|
my $code = $mt->code; |
42
|
0
|
|
|
|
|
|
$code = eval $code; ## no critic |
43
|
0
|
0
|
|
|
|
|
die $@ if $@; |
44
|
0
|
|
|
|
|
|
$code->(); |
45
|
0
|
|
|
|
|
|
}->($tmpl); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub { |
49
|
0
|
|
|
0
|
|
|
my ( $content, $ofname ) = @_; |
50
|
0
|
0
|
|
|
|
|
open my $fh, '>', $ofname or die "cannot open file: $ofname: $!"; |
51
|
0
|
|
|
|
|
|
print $fh $content; |
52
|
0
|
|
|
|
|
|
close $fh; |
53
|
0
|
|
|
|
|
|
}->($content, $dst); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
__END__ |