blib/lib/PostScript/DecodeGlyphName.pm

filter: Statementstmt 62.5% 30 / 48 Branchbran 50.0% 6 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 8 / 14 Podpod 100% 2 / 2 totaltotal 60.5% 46 / 76 CC 7 SCAR 11.1
CC
7
Cov
60%
__ANON__
6.0
decode_glyph
5.1
parse_adobeglyphlist
4.6
CRAP 3.0
↑ Summary
1 2 ▶use 5.008001; use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package PostScript::DecodeGlyphName;
4  
5 2 our $VERSION = '0.002';
6  
7 2 ▶use Exporter::Tidy all => [qw( decode_glyph parse_adobeglyphlist )];
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 0 ▶sub _croak { require Carp; goto &Carp::croak }
Subroutine _croak: not called CC=1 SCAR=6.9
10  
11 2 ▶sub _utf8ify { no warnings 'utf8'; map { pack "U", hex } @_ }
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine _utf8ify: called CC=1 SCAR=0.0
12  
13 2 my $uni_notation = qr{
14 \A uni
15 (
16 (?:
17 [0-9ABCEF] [\dA-F] {3}
18 |
19 D [0-7] [\dA-F] {2}
20 )+
21 )
22 \z
23 }x;
24  
25 # this is a sexeger
26 2 my $u_notation = qr{
27 \A
28 (
29 [\dA-F] {2}
30 (?:
31 [0-7] D 0? 0?
32 |
33 [\dA-F] [\dABCEF] [\dA-F] {0,2}
34 )
35 )
36 u \z
37 }x;
38  
39 2 my %agl;
40  
41 32 ▶sub decode_glyph {
Subroutine decode_glyph: called CC=5 SCAR=16.2
Pod documented
42 32 my $digits;
43 return join '', map {
44 exists $agl{ $_ }
45 32 ▶ ? $agl{ $_ }
Branch: 3 branches
BranchTrueFalseTotal
exists $agl{$_} ? : 0 32 32
(($digits) = /$uni_notation/x) ? : 5 27 32
(($digits) = reverse() =~ /$u_notation/x) ? : 6 21 27
46 : ( ( $digits ) = m/$uni_notation/ ) ? _utf8ify $digits =~ /(....)/g
47 : ( ( $digits ) = reverse =~ m/$u_notation/ ) ? _utf8ify scalar reverse $digits
48 : '';
49 }
50 32 map { split /_/ }
51 32 ▶ map { /\A(.+?)\./ ? $1 : $_ }
Branch: 1 branch
BranchTrueFalseTotal
/\A(.+?)\./ ? : 0 32 32
52 32 map { split } @_;
53 }
54  
55 0 ▶sub parse_adobeglyphlist {
Subroutine parse_adobeglyphlist: not called CC=2 SCAR=15.3
Pod documented
56 0 my ( $input_method, $data ) = @_;
57  
58 my %reader = (
59 0 ▶ array => sub { $_[0] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
60 0 ▶ data => sub { [ split /^/m, shift ] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
61 0 ▶ fh => sub { [ <$_[0]> ] },
Subroutine BEGIN: called CC=1 SCAR=0.2
Subroutine __ANON__: not called CC=1 SCAR=0.2
62 0 ▶ file => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
63 0 ▶ open my $fh, '<', $_[0]
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $_[0] or _croak("Error opening $_[0]: $!") 0 0 0
64 or _croak( "Error opening $_[0]: $!" );
65 0 [ <$fh> ];
66 },
67 0 );
68  
69 _croak( "No such input type '$input_method'" )
70 0 ▶ unless exists $reader{ $input_method };
Branch: 1 branch
BranchTrueFalseTotal
unless exists $reader{$input_method} 0 0 0
71  
72 0 my $lines = $reader{ $input_method }->( $data );
73  
74 0 @$lines = grep !/\A \s* (?: \# | \z)/x, @$lines;
75  
76 0 chomp @$lines;
77  
78 %agl = map {
79 0 my ( $code_pt, $glyph ) = split /;/;
80 0 ( $glyph => _utf8ify $code_pt );
81 } @$lines;
82  
83 0 delete $agl{ '.notdef' };
84  
85 0 return 1;
86 }
87  
88 2 1;
89  
90 __END__
↑ Summary