line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::TemplateCMD::Command::Describe; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Created on: 2008-03-26 13:43:56 |
4
|
|
|
|
|
|
|
# Create by: ivanw |
5
|
|
|
|
|
|
|
# $Id$ |
6
|
|
|
|
|
|
|
# $Revision$, $HeadURL$, $Date$ |
7
|
|
|
|
|
|
|
# $Revision$, $Source$, $Date$ |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
1542
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
48
|
|
10
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
41
|
|
11
|
2
|
|
|
2
|
|
415
|
use version; |
|
2
|
|
|
|
|
1535
|
|
|
2
|
|
|
|
|
10
|
|
12
|
2
|
|
|
2
|
|
110
|
use Carp; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
95
|
|
13
|
2
|
|
|
2
|
|
505
|
use List::MoreUtils qw/uniq/; |
|
2
|
|
|
|
|
10729
|
|
|
2
|
|
|
|
|
14
|
|
14
|
2
|
|
|
2
|
|
2041
|
use Data::Dumper qw/Dumper/; |
|
2
|
|
|
|
|
5730
|
|
|
2
|
|
|
|
|
100
|
|
15
|
2
|
|
|
2
|
|
422
|
use English qw/ -no_match_vars /; |
|
2
|
|
|
|
|
1394
|
|
|
2
|
|
|
|
|
11
|
|
16
|
2
|
|
|
2
|
|
636
|
use base qw/App::TemplateCMD::Command/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1116
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = version->new('0.6.11'); |
19
|
|
|
|
|
|
|
our @EXPORT_OK = qw//; |
20
|
|
|
|
|
|
|
our %EXPORT_TAGS = (); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub process { |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
0
|
1
|
|
my ( $self, $cmd, %option ) = @_; |
25
|
0
|
|
|
|
|
|
my $template = shift @{$option{files}}; |
|
0
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
my ($data, $provider, $error, $templates) = $self->get_template($template, $cmd); |
28
|
0
|
0
|
|
|
|
|
die "Could not find the template $template\n" if !$data->{text}; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my @vars = $data->{text} =~ /\[[%]-? (?!\#) \s* ([A-Z]+) \s* (.+?) \s* -?[%]\]/gxms; |
31
|
0
|
|
|
|
|
|
my %vars; |
32
|
0
|
|
|
|
|
|
for ( my $i = 0; $i < @vars; $i += 2 ) { |
33
|
0
|
|
|
|
|
|
$vars{$vars[$i]}{ $vars[$i+1] } = 1; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my $includes = join "\n ", sort keys %{ $vars{INCLUDE} }; |
|
0
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $vars = join "\n ", uniq sort grep {$_!~/^(?: END | CASE )$/xms} $data->{text} =~ /\[ [%] -? (?!\#) \s* (\w+?) \s* -?[%]\]/gxms; |
|
0
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my $description = join "\n", $data->{text} =~ /\[[%]\#= (.*?) -?[%]\]/gxms; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
0
|
|
|
|
$includes ||= '(none)'; |
41
|
0
|
|
0
|
|
|
|
$vars ||= '(none)'; |
42
|
0
|
|
0
|
|
|
|
$description &&= "\n$description\n"; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
return <<"DESCRIPTION"; |
45
|
|
|
|
|
|
|
Details for '$template' |
46
|
|
|
|
|
|
|
Location: |
47
|
|
|
|
|
|
|
$provider |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Included templates: |
50
|
|
|
|
|
|
|
$includes |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Variables used: |
53
|
|
|
|
|
|
|
$vars |
54
|
|
|
|
|
|
|
$description |
55
|
|
|
|
|
|
|
DESCRIPTION |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub help { |
59
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
return <<"HELP"; |
62
|
|
|
|
|
|
|
$0 describe template |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
This command gives full details of a template, the variables it uses and |
65
|
|
|
|
|
|
|
where the template is stored. |
66
|
|
|
|
|
|
|
HELP |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |