line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::TemplateCMD::Command; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Created on: 2008-09-04 04:26:46 |
4
|
|
|
|
|
|
|
# Create by: ivan |
5
|
|
|
|
|
|
|
# $Id$ |
6
|
|
|
|
|
|
|
# $Revision$, $HeadURL$, $Date$ |
7
|
|
|
|
|
|
|
# $Revision$, $Source$, $Date$ |
8
|
|
|
|
|
|
|
|
9
|
9
|
|
|
9
|
|
1965
|
use strict; |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
242
|
|
10
|
9
|
|
|
9
|
|
39
|
use warnings; |
|
9
|
|
|
|
|
25
|
|
|
9
|
|
|
|
|
196
|
|
11
|
9
|
|
|
9
|
|
430
|
use version; |
|
9
|
|
|
|
|
1650
|
|
|
9
|
|
|
|
|
52
|
|
12
|
9
|
|
|
9
|
|
510
|
use Carp; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
463
|
|
13
|
9
|
|
|
9
|
|
591
|
use Data::Dumper qw/Dumper/; |
|
9
|
|
|
|
|
5818
|
|
|
9
|
|
|
|
|
408
|
|
14
|
9
|
|
|
9
|
|
473
|
use English qw/ -no_match_vars /; |
|
9
|
|
|
|
|
1519
|
|
|
9
|
|
|
|
|
52
|
|
15
|
9
|
|
|
9
|
|
2705
|
use base qw/Exporter/; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
4206
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = version->new('0.6.11'); |
18
|
|
|
|
|
|
|
our @EXPORT_OK = qw//; |
19
|
|
|
|
|
|
|
our %EXPORT_TAGS = (); |
20
|
|
|
|
|
|
|
#our @EXPORT = qw//; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub args { |
23
|
|
|
|
|
|
|
return ( |
24
|
0
|
|
|
0
|
1
|
|
'path|p=s', |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
0
|
1
|
|
sub default { |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub get_template { |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
0
|
1
|
|
my ($self, $template, $cmd) = @_; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# try to get the template directly by name |
36
|
0
|
|
|
|
|
|
for my $provider (@{ $cmd->{providers} }) { |
|
0
|
|
|
|
|
|
|
37
|
0
|
0
|
|
|
|
|
if ($provider->{INCLUDE_PATH}) { |
38
|
0
|
|
|
|
|
|
for my $path (@{ $provider->{INCLUDE_PATH} }) { |
|
0
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my ($data, $error) = $provider->_load( "$path/$template" ); |
40
|
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
if ($data->{text}) { |
42
|
|
|
|
|
|
|
# return the found template info |
43
|
0
|
|
|
|
|
|
return ($data, $provider, $error, [$template]); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
else { |
48
|
0
|
|
|
|
|
|
my ($data, $error) = $provider->_load( $template ); |
49
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
if ($data->{text}) { |
51
|
|
|
|
|
|
|
# return the found template info |
52
|
0
|
|
|
|
|
|
return ($data, $provider, $error, [$template]); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
0
|
0
|
|
|
|
|
if ($cmd->{verbose}) { |
57
|
0
|
|
|
|
|
|
print "$template was not found with provider " . ( ref $provider ) . "\n"; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# now try to get the template assumin it is missing its suffix |
62
|
0
|
|
|
|
|
|
my @files = map {$_->{file}} $cmd->list_templates(); |
|
0
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# get all templates that start with the template name provided |
65
|
0
|
|
|
|
|
|
my @templates = grep { m{^$template [.] .+ $}xms } @files; |
|
0
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
if (@templates) { |
68
|
0
|
|
|
|
|
|
for my $provider (@{ $cmd->{providers} }) { |
|
0
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
my ($data, $error) = $provider->_load( $templates[0] ); |
70
|
|
|
|
|
|
|
|
71
|
0
|
0
|
|
|
|
|
if ($data->{text}) { |
72
|
|
|
|
|
|
|
# return the found template info |
73
|
0
|
|
|
|
|
|
return ($data, $provider, $error, \@templates); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# no template found |
79
|
0
|
|
|
|
|
|
croak "The template $template was not found!"; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |