| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::TemplateCMD::Command::Build; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Created on: 2008-03-26 13:43:32 |
|
4
|
|
|
|
|
|
|
# Create by: ivanw |
|
5
|
|
|
|
|
|
|
# $Id$ |
|
6
|
|
|
|
|
|
|
# $Revision$, $HeadURL$, $Date$ |
|
7
|
|
|
|
|
|
|
# $Revision$, $Source$, $Date$ |
|
8
|
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
1521
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
50
|
|
|
10
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
40
|
|
|
11
|
2
|
|
|
2
|
|
315
|
use version; |
|
|
2
|
|
|
|
|
1430
|
|
|
|
2
|
|
|
|
|
10
|
|
|
12
|
2
|
|
|
2
|
|
108
|
use Carp; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
93
|
|
|
13
|
2
|
|
|
2
|
|
441
|
use List::MoreUtils qw/uniq/; |
|
|
2
|
|
|
|
|
10182
|
|
|
|
2
|
|
|
|
|
12
|
|
|
14
|
2
|
|
|
2
|
|
1914
|
use Data::Dumper qw/Dumper/; |
|
|
2
|
|
|
|
|
5381
|
|
|
|
2
|
|
|
|
|
95
|
|
|
15
|
2
|
|
|
2
|
|
384
|
use English qw/ -no_match_vars /; |
|
|
2
|
|
|
|
|
1237
|
|
|
|
2
|
|
|
|
|
11
|
|
|
16
|
2
|
|
|
2
|
|
1001
|
use Template; |
|
|
2
|
|
|
|
|
14905
|
|
|
|
2
|
|
|
|
|
46
|
|
|
17
|
2
|
|
|
2
|
|
10
|
use Template::Provider; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
46
|
|
|
18
|
2
|
|
|
2
|
|
336
|
use YAML qw/Load/; |
|
|
2
|
|
|
|
|
5717
|
|
|
|
2
|
|
|
|
|
82
|
|
|
19
|
2
|
|
|
2
|
|
1385
|
use Path::Tiny; |
|
|
2
|
|
|
|
|
19006
|
|
|
|
2
|
|
|
|
|
181
|
|
|
20
|
2
|
|
|
2
|
|
16
|
use base qw/App::TemplateCMD::Command/; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
778
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = version->new('0.6.12'); |
|
23
|
|
|
|
|
|
|
our @EXPORT_OK = qw//; |
|
24
|
|
|
|
|
|
|
our %EXPORT_TAGS = (); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub process { |
|
27
|
0
|
|
|
0
|
1
|
|
my ($self, $cmd, %option) = @_; |
|
28
|
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
my $template = 'build/' . shift @{$option{files}}; |
|
|
0
|
|
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
|
my $args = { %{ $cmd->config }, %{ $option{args} || {} } }; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
my $print = $cmd->load_cmd('print'); |
|
33
|
0
|
|
|
|
|
|
my $out = $print->process( $cmd, %{ $args }, files => [$template] ); |
|
|
0
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my $structure = Load($out); |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
for my $file (keys %{ $structure }) { |
|
|
0
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my $template = $structure->{$file}{template}; |
|
39
|
0
|
|
|
|
|
|
my $file = path($file); |
|
40
|
|
|
|
|
|
|
|
|
41
|
0
|
0
|
0
|
|
|
|
if ( !-e $file || $option{force} ) { |
|
42
|
0
|
|
|
|
|
|
$file->parent->mkpath(); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# process the template |
|
46
|
|
|
|
|
|
|
my $out = $print->process( |
|
47
|
|
|
|
|
|
|
$cmd, |
|
48
|
|
|
|
|
|
|
file => $file, |
|
49
|
0
|
|
|
|
|
|
%{ $args }, |
|
50
|
0
|
|
|
|
|
|
%{ $structure->{$file} }, |
|
|
0
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
files => [$template] |
|
52
|
|
|
|
|
|
|
); |
|
53
|
0
|
|
|
|
|
|
my $fh = $file->openw; |
|
54
|
0
|
|
|
|
|
|
print {$fh} $out; |
|
|
0
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
close $fh; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
return $out; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub args { |
|
62
|
|
|
|
|
|
|
return ( |
|
63
|
0
|
|
|
0
|
1
|
|
'force|f!', |
|
64
|
|
|
|
|
|
|
); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub help { |
|
68
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
69
|
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
return <<"HELP"; |
|
71
|
|
|
|
|
|
|
$0 build [options] build_template |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Options |
|
74
|
|
|
|
|
|
|
-a --args=str Arguments to the build template |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This builds a directory structure baised on the results of a build template |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
HELP |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |