« lib/Serge/Engine/Plugin/parse_hash.pm
↑ Summary
lib/Serge/Engine/Plugin/parse_key_space_value.pm »
| 1 | package Serge::Engine::Plugin::parse_plist; | ||||||||||
| 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 | 1 | ▶ | use Serge::Util qw(xml_escape_strref xml_unescape_strref); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | sub name { | ||||||||||
| 9 | 0 | ▶ | return 'Mac OS .plist parser plugin'; | ||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 10 | } | ||||||||||
| 11 | |||||||||||
| 12 | sub parse { | ||||||||||
| 13 | 0 | ▶ | my ($self, $textref, $callbackref, $lang) = @_; | ||||||||
|
Subroutine
parse: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 14 | |||||||||||
| 15 | 0 | ▶ | die 'callbackref not specified' unless $callbackref; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | |||||||||||
| 17 | 0 | my $translated_text = $$textref; | |||||||||
| 18 | |||||||||||
| 19 | # Format: | ||||||||||
| 20 | # <key>...</key> | ||||||||||
| 21 | # <string>...</string> | ||||||||||
| 22 | |||||||||||
| 23 | 0 | $translated_text =~ s|(<key>([^<>]*?)</key>[\r\n\t ]*<string>)([^<>]*?)(</string>)|$1.$self->parse_callback($callbackref, $3, undef, $2, undef, $lang, $2).$4|sge; | |||||||||
| 24 | |||||||||||
| 25 | # Format: | ||||||||||
| 26 | # <key>...</key> | ||||||||||
| 27 | # <array> | ||||||||||
| 28 | # <string>...</string> | ||||||||||
| 29 | # <string>...</string> | ||||||||||
| 30 | # </array> | ||||||||||
| 31 | |||||||||||
| 32 | 0 | $translated_text =~ s|(<key>([^<>]*?)</key>[\r\n\t ]*<array>)(([\s]*<string>([^<>]*?)</string>[\s]*){1,})(</array>)|$1.$self->parse_array_callback($callbackref, $3, undef, $2, undef, $lang, $2).$6|sge; | |||||||||
| 33 | |||||||||||
| 34 | 0 | return $translated_text; | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | sub parse_array_callback { | ||||||||||
| 38 | 0 | ▶ | my ($self, $callbackref, $array_xml, $context, $hint, $flagsref, $lang, $key_prefix) = @_; | ||||||||
|
Subroutine
parse_array_callback: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 39 | 0 | my $n = 0; | |||||||||
| 40 | 0 | $array_xml =~ s|(<string>)([^<>]*?)(</string>)|$1.$self->parse_callback($callbackref, $2, $context, $hint, $flagsref, $lang, $key_prefix.'#'.$n++).$3|sge; | |||||||||
| 41 | 0 | return $array_xml; | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | sub parse_callback { | ||||||||||
| 45 | 0 | ▶ | my ($self, $callbackref, $string, $context, $hint, $flagsref, $lang, $key) = @_; | ||||||||
|
Subroutine
parse_callback: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 46 | |||||||||||
| 47 | 0 | xml_unescape_strref(\$string); | |||||||||
| 48 | |||||||||||
| 49 | 0 | my $translated_string = &$callbackref($string, $context, $hint, $flagsref, $lang, $key); | |||||||||
| 50 | |||||||||||
| 51 | 0 | $translated_string =~ s/\n/\\n/g; | |||||||||
| 52 | |||||||||||
| 53 | 0 | xml_escape_strref(\$translated_string); | |||||||||
| 54 | |||||||||||
| 55 | 0 | return $translated_string; | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | 1 | 1; | |||||||||