File Coverage

blib/lib/Locale/Maketext/Extract/Plugin/TextTemplate.pm
Criterion Covered Total %
statement 12 32 37.5
branch 1 4 25.0
condition 1 3 33.3
subroutine 4 5 80.0
pod 2 2 100.0
total 20 46 43.4


line stmt bran cond sub pod time code
1             package Locale::Maketext::Extract::Plugin::TextTemplate;
2             $Locale::Maketext::Extract::Plugin::TextTemplate::VERSION = '1.00';
3 4     4   25 use strict;
  4         25  
  4         177  
4 4     4   24 use base qw(Locale::Maketext::Extract::Plugin::Base);
  4         9  
  4         2495  
5              
6             # ABSTRACT: Text::Template format parser
7              
8              
9             sub file_types {
10 18     18 1 61 return qw( * );
11             }
12              
13             sub extract {
14 4     4 1 8 my $self = shift;
15 4         9 local $_ = shift;
16              
17 4         5 my $line = 1;
18 4         12 pos($_) = 0;
19              
20             # Text::Template
21 4 50 33     107 if ( $_ =~ /^STARTTEXT$/m and $_ =~ /^ENDTEXT$/m ) {
22 0           require HTML::Parser;
23 0           require Lingua::EN::Sentence;
24              
25             {
26              
27 0           package Locale::Maketext::Extract::Plugin::TextTemplate::Parser;
28 0           $Locale::Maketext::Extract::Plugin::TextTemplate::Parser::VERSION = '1.00';
29 0           our @ISA = 'HTML::Parser';
30 0           *{'text'} = sub {
31 0     0     my ( $self, $str, $is_cdata ) = @_;
32 0 0         my $sentences = Lingua::EN::Sentence::get_sentences($str)
33             or return;
34 0           $str =~ s/\n/ /g;
35 0           $str =~ s/^\s+//;
36 0           $str =~ s/\s+$//;
37 0           $self->add_entry( $str, $line );
38 0           };
39             }
40              
41 0           my $p = Locale::Maketext::Extract::Plugin::TextTemplate::Parser->new;
42 0           while (m/\G((.*?)^(?:START|END)[A-Z]+$)/smg) {
43 0           my ($str) = ($2);
44 0           $line += ( () = ( $1 =~ /\n/g ) ); # cryptocontext!
45 0           $p->parse($str);
46 0           $p->eof;
47             }
48 0           $_ = '';
49             }
50              
51             }
52              
53              
54             1;
55              
56             __END__