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
|
|
1645
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
58
|
|
10
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
46
|
|
11
|
2
|
|
|
2
|
|
427
|
use version; |
|
2
|
|
|
|
|
1810
|
|
|
2
|
|
|
|
|
10
|
|
12
|
2
|
|
|
2
|
|
128
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
104
|
|
13
|
2
|
|
|
2
|
|
626
|
use List::MoreUtils qw/uniq/; |
|
2
|
|
|
|
|
12143
|
|
|
2
|
|
|
|
|
15
|
|
14
|
2
|
|
|
2
|
|
2406
|
use Data::Dumper qw/Dumper/; |
|
2
|
|
|
|
|
6742
|
|
|
2
|
|
|
|
|
120
|
|
15
|
2
|
|
|
2
|
|
489
|
use English qw/ -no_match_vars /; |
|
2
|
|
|
|
|
1611
|
|
|
2
|
|
|
|
|
11
|
|
16
|
2
|
|
|
2
|
|
1316
|
use Template; |
|
2
|
|
|
|
|
19485
|
|
|
2
|
|
|
|
|
73
|
|
17
|
2
|
|
|
2
|
|
14
|
use Template::Provider; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
56
|
|
18
|
2
|
|
|
2
|
|
490
|
use YAML qw/Load/; |
|
2
|
|
|
|
|
6886
|
|
|
2
|
|
|
|
|
93
|
|
19
|
2
|
|
|
2
|
|
1624
|
use Path::Tiny; |
|
2
|
|
|
|
|
22242
|
|
|
2
|
|
|
|
|
127
|
|
20
|
2
|
|
|
2
|
|
35
|
use base qw/App::TemplateCMD::Command/; |
|
2
|
|
|
|
|
16
|
|
|
2
|
|
|
|
|
1011
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = version->new('0.6.10'); |
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__ |