lib/Serge/Engine/Plugin/parse_dtd.pm

filter: Statementstmt 25.0% 7 / 28 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 40.0% 2 / 5 Podpod 0.0% 0 / 3 totaltotal 23.6% 9 / 38 SCAR 13.4
CC
2
Cov
23%
parse
6.0
name
2.0
parse_callback
2.0
CRAP 3.8
« lib/Serge/Plugin/Base.pm ↑ Summary lib/Serge/Engine/Plugin/parse_hash.pm »
1 package Serge::Engine::Plugin::parse_dtd;
2 1 ▶use parent Serge::Engine::Plugin::Base::Parser;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 sub name {
7 0 ▶ return '.dtd entities parser plugin';
Subroutine name: not called CC=1 SCAR=6.9
Pod undocumented
8 }
9  
10 sub parse {
11 0 ▶ my ($self, $textref, $callbackref, $lang) = @_;
Subroutine parse: not called CC=2 SCAR=17.9
Pod undocumented
12  
13 0 ▶ die 'callbackref not specified' unless $callbackref;
Branch: 1 branch
BranchTrueFalseTotal
unless $callbackref 0 0 0
14  
15 # Finding translatable strings in file
16  
17 # Format is:
18 # <!ENTITY hint "text">
19  
20 0 my $translated_text = $$textref;
21  
22 0 $translated_text =~ s|(<!ENTITY\s+)([\w\-\.]+)(\s*"\s*)(.*?)(\s*"\s*>)|$1.$2.$3.$self->parse_callback($callbackref, $4, undef, $2, undef, $lang, $2).$5|sgie;
23  
24 0 return $translated_text;
25 }
26  
27 sub parse_callback {
28 0 ▶ my ($self, $callbackref, $string, $context, $hint, $flagsref, $lang, $key) = @_;
Subroutine parse_callback: not called CC=1 SCAR=6.9
Pod undocumented
29  
30 0 $string =~ s/&apos;/'/g;
31 0 $string =~ s/&quot;/"/g;
32 0 $string =~ s/&#34;/"/g;
33 0 $string =~ s/&#35;/#/g;
34 0 $string =~ s/&#38;/&/g;
35  
36 0 my $translated_string = &$callbackref($string, $context, $hint, $flagsref, $lang, $key);
37  
38 0 $translated_string =~ s/\#/__HASH__/g;
39 0 $translated_string =~ s/\&/__AMP__/g;
40 0 $translated_string =~ s/\'/&apos;/g;
41 0 $translated_string =~ s/\"/&#34;/g;
42 0 $translated_string =~ s/__HASH__/&#35;/g;
43 0 $translated_string =~ s/__AMP__/&#38;/g;
44  
45 0 return $translated_string;
46 }
47  
48 1 1;
« lib/Serge/Plugin/Base.pm ↑ Summary lib/Serge/Engine/Plugin/parse_hash.pm »