lib/Serge/Engine/Plugin/parse_rrc.pm

filter: Statementstmt 22.5% 7 / 31 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 2 / 4 Podpod 0.0% 0 / 2 totaltotal 20.0% 9 / 45 SCAR 32.5
CC
6
Cov
18%
parse
42.0
name
2.0
BEGIN
1.0
CRAP 25.9
« lib/Serge/Util/WordStats.pm ↑ Summary lib/Serge/Plugin/Base/Callback.pm »
1 package Serge::Engine::Plugin::parse_rrc;
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 # TODO:
7 # - Decode \\Uxxxx in strings
8 # - Support "key" = "value" pairs that span multiple lines
9 # - Better handling of comments
10  
11 sub name {
12 0 ▶ return 'Blackberry .rrc parser plugin';
Subroutine name: not called CC=1 SCAR=6.9
Pod undocumented
13 }
14  
15 sub parse {
16 0 ▶ my ($self, $textref, $callbackref, $lang) = @_;
Subroutine parse: not called CC=6 SCAR=37.4
Pod undocumented
17  
18 0 ▶ die 'callbackref not specified' unless $callbackref;
Branch: 1 branch
BranchTrueFalseTotal
unless $callbackref 0 0 0
19  
20 0 my $translated_text;
21  
22 # Finding translatable strings in file
23  
24 # Format is: key = "value"
25  
26 0 foreach my $line (split(/\n/, $$textref)) {
27  
28 0 my $hint;
29 my $context;
30 0 my $orig_str;
31 0 my $translated_str;
32  
33 0 ▶ if ($line =~ m/^[\t ]*(.*?)#0[\t ]*=[\t ]*"(.*)";$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^[\t ]*(.*?)#0[\t ]*=[\t ]*"(.*)";$/) 0 0 0
34 0 $hint = $1;
35 0 $orig_str = $2;
36 }
37  
38 0 ▶ if ($orig_str) {
Branch: 1 branch
BranchTrueFalseTotal
if ($orig_str) 0 0 0
39 0 my $str = $orig_str;
40 0 $str =~ s/\\"/"/g;
41 0 $str =~ s/\\n/\n/g;
42 0 $str =~ s/\\\\/\\/g;
43 0 $translated_str = &$callbackref($str, $context, $hint, undef, $lang);
44 }
45  
46 0 ▶ if ($lang) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lang) 0 0 0
47 0 $translated_str =~ s/\\/\\\\/g;
48 0 $translated_str =~ s/\n/\\n/g;
49 0 $translated_str =~ s/"/\\"/g;
50 0 $line =~ s/\Q"$orig_str";\E/"$translated_str";/;
51 0 $translated_text .= $line."\n";
52 }
53 }
54  
55 0 return $translated_text;
56 }
57  
58 1 1;
« lib/Serge/Util/WordStats.pm ↑ Summary lib/Serge/Plugin/Base/Callback.pm »