ReplacePictogramMobileJp/Base.pm

filter: Statementstmt 98.2% 55 / 56 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 14 / 14 Podpod 0.0% 0 / 4 totaltotal 92.1% 70 / 76 CC 3 SCAR 3.3
CC
3
Cov
97%
_kddi_number2unicode_auto
3.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
↑ Summary ReplacePictogramMobileJp/EZweb.pm »
1 package HTML::ReplacePictogramMobileJp::Base;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 our @EXPORT = qw/unicode_property unicode_hex_cref filter img_localsrc/;
6 3 ▶use Params::Validate ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Encode::JP::Mobile ':props';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use File::ShareDir 'dist_file';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 my $property_for = +{
12 E => 'InKDDIPictograms',
13 I => 'InDoCoMoPictograms',
14 V => 'InSoftBankPictograms',
15 };
16 18 ▶sub unicode_property {
Subroutine unicode_property: called CC=1 SCAR=0.0
Pod undocumented
17 18 my $carrier = shift;
18 18 $_ =~ s/(\p{$property_for->{$carrier}})/callback(ord $1, $carrier)/ge;
19 }
20  
21 13 ▶sub unicode_hex_cref {
Subroutine unicode_hex_cref: called CC=1 SCAR=0.0
Pod undocumented
22 13 my $carrier = shift;
23 13 $_ =~ s/&#x([A-F0-9]{4});/callback(hex $1, $carrier)/ge;
24 }
25  
26 2 ▶sub _kddi_number2unicode_auto {
Subroutine _kddi_number2unicode_auto: called CC=3 SCAR=11.3
27 2 my $number = shift;
28  
29 2 my $fname =
30 File::ShareDir::dist_file( 'Encode-JP-Mobile', 'kddi-table.pl' );
31 2 my $dat = do $fname;
32 2 for my $row (@$dat) {
33 2 ▶ if ( $row->{number} == $number ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($row->{"number"} == $number) 2 0 2
34 2 return hex $row->{unicode_auto};
35 }
36 }
37 0 return; # invalid number
38 }
39  
40 7 ▶sub img_localsrc {
Subroutine img_localsrc: called CC=1 SCAR=0.0
Pod undocumented
41 7 $_ =~ s{<img[^<>]+localsrc=["'](\d+)[^<>]+>}{
42 2 callback(_kddi_number2unicode_auto($1), 'E');
43 }ge;
44 }
45  
46 24 ▶sub filter {
Subroutine filter: called CC=1 SCAR=0.0
Pod undocumented
47 24 my ($charset, $decode_by, $code) = @_;
48 24 my $pkg = caller(0);
49 3 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
50 24 ▶ *{"$pkg\::$charset"} = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
51 19 my $class = shift;
52 19 validate(
53 @_,
54 +{
55 callback => { type => CODEREF },
56 html => { type => SCALAR },
57 }
58 );
59 19 my %args = @_;
60  
61 19 local $_ = decode($decode_by, $args{html}, Encode::FB_XMLCREF);
62 19 local *HTML::ReplacePictogramMobileJp::Base::callback = $args{callback};
63 19 local *{"$pkg\::callback"} = $args{callback};
64  
65 19 $code->();
66  
67 19 $_ = encode($decode_by, $_);
68  
69 19 $_;
70 24 };
71 }
72  
73 3 1;
↑ Summary ReplacePictogramMobileJp/EZweb.pm »