lib/Serge/Engine/Plugin/parse_key_space_value.pm

filter: Statementstmt 38.8% 7 / 18 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 40.0% 2 / 5 Podpod 0.0% 0 / 3 totaltotal 32.1% 9 / 28 SCAR 11.3
CC
2
Cov
35%
parse
6.0
name
2.0
parse_callback
2.0
CRAP 3.1
« lib/Serge/Engine/Plugin/parse_plist.pm ↑ Summary lib/Serge/Engine/Plugin/parse_resx.pm »
1 package Serge::Engine::Plugin::parse_key_space_value;
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 'Plain key<_space_>value string parser';
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 0 my $translated_text = $$textref;
16  
17 # Finding translatable strings in file
18  
19 # Format is:
20 # key value
21 # key\tvalue
22 # (leading and trailing whitespaces are preserved but are not extracted as a string or as a hint)
23  
24 # $1 $2 $3 $4 $5
25 0 $translated_text =~ s|^(\s*)(\S+)(\s+)(.+?)(\s*)$|$1.$2.$3.$self->parse_callback($callbackref, $4, undef, $2, undef, $lang).$5|mgie;
26  
27 0 return $translated_text;
28 }
29  
30 sub parse_callback {
31 0 ▶ my ($self, $callbackref, $string, $context, $hint, $flagsref, $lang) = @_;
Subroutine parse_callback: not called CC=1 SCAR=6.9
Pod undocumented
32  
33 0 my $translated_string = &$callbackref($string, $context, $hint, $flagsref, $lang);
34  
35 0 $translated_string =~ s/\n/\\n/sg;
36  
37 0 return $translated_string;
38 }
39  
40 1 1;
« lib/Serge/Engine/Plugin/parse_plist.pm ↑ Summary lib/Serge/Engine/Plugin/parse_resx.pm »