| 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 |  | 1687 | use strict; | 
|  | 2 |  |  |  |  | 5 |  | 
|  | 2 |  |  |  |  | 48 |  | 
| 10 | 2 |  |  | 2 |  | 8 | use warnings; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 37 |  | 
| 11 | 2 |  |  | 2 |  | 315 | use version; | 
|  | 2 |  |  |  |  | 1468 |  | 
|  | 2 |  |  |  |  | 9 |  | 
| 12 | 2 |  |  | 2 |  | 106 | use Carp; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 89 |  | 
| 13 | 2 |  |  | 2 |  | 460 | use List::MoreUtils qw/uniq/; | 
|  | 2 |  |  |  |  | 10451 |  | 
|  | 2 |  |  |  |  | 12 |  | 
| 14 | 2 |  |  | 2 |  | 1915 | use Data::Dumper qw/Dumper/; | 
|  | 2 |  |  |  |  | 5514 |  | 
|  | 2 |  |  |  |  | 94 |  | 
| 15 | 2 |  |  | 2 |  | 382 | use English qw/ -no_match_vars /; | 
|  | 2 |  |  |  |  | 1229 |  | 
|  | 2 |  |  |  |  | 10 |  | 
| 16 | 2 |  |  | 2 |  | 595 | use base qw/App::TemplateCMD::Command/; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 890 |  | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | our $VERSION     = version->new('0.6.12'); | 
| 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__ |