Conveyor/Charset/ViaHash.pm

filter: Statementstmt 39.5% 17 / 43 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 54.5% 6 / 11 Podpod 100% 5 / 5 totaltotal 38.3% 28 / 73 CC 9 SCAR 24.4
CC
9
Cov
30%
get_characters
30.0
is_valid_string
12.0
get_character_names
6.0
CRAP 11.5
« Conveyor/Monitor.pm ↑ Summary Conveyor/Ticket/Payload.pm »
1 6 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Data::Conveyor::Charset::ViaHash;
6 6 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 $Data::Conveyor::Charset::ViaHash::VERSION = '1.103130';
8 }
9 # ABSTRACT: Stage-based conveyor-belt-like ticket handling system
10  
11 6 ▶use charnames ':full';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 6 ▶use parent 'Data::Conveyor::Charset';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 6 __PACKAGE__->mk_constructor(qw(new))->mk_hash_accessors(qw(character_cache))
14 ->mk_scalar_accessors(qw(valid_string_re_cache));
15 0 ▶sub CHARACTERS { () }
Subroutine CHARACTERS: not called CC=1 SCAR=6.9
Pod documented
16  
17 0 ▶sub get_characters {
Subroutine get_characters: not called CC=5 SCAR=34.0
Pod documented
18 0 my $self = shift;
19 0 ▶ unless ($self->character_cache_keys) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->character_cache_keys) 0 0 0
20 0 my $characters = $self->every_hash('CHARACTERS');
21  
22 # Convert the hash values to their actual Unicode character
23 # equivalent. For defining a character, we accept Unicode character
24 # names (the "..." part of the "\N{...}" notation) or hex code points
25 # (indicated by a leading "0x"; useful for characters that don't have
26 # a name).
27 0 for (values %$characters) {
28 0 ▶ next if utf8::is_utf8($_); # don't convert the already converted
Branch: 1 branch
BranchTrueFalseTotal
if utf8::is_utf8($_) 0 0 0
29 0 ▶ if (/^0x(.*)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^0x(.*)$/) { } 0 0 0
30 0 $_ = sprintf '%c' => hex($1);
31 } else {
32 0 $_ = sprintf '%c' => charnames::vianame($_);
33 }
34 0 utf8::upgrade($_);
35 }
36 0 $self->character_cache(%$characters);
37 }
38 0 return $self->character_cache;
39 }
40  
41 0 ▶sub get_character_names {
Subroutine get_character_names: not called CC=2 SCAR=17.9
Pod documented
42 0 my $self = shift;
43 0 my %characters = $self->get_characters;
44 0 my @names = keys %characters;
45 0 ▶ wantarray ? @names : \@names;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
46 }
47  
48 0 ▶sub get_character_values {
Subroutine get_character_values: not called CC=2 SCAR=17.9
Pod documented
49 0 my $self = shift;
50 0 my %characters = $self->get_characters;
51 0 my @values = values %characters;
52 0 ▶ wantarray ? @values : \@values;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
53 }
54  
55 0 ▶sub is_valid_string {
Subroutine is_valid_string: not called CC=3 SCAR=24.8
Pod documented
56 0 my ($self, $string) = @_;
57 0 ▶ unless (defined $self->valid_string_re_cache) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->valid_string_re_cache) 0 0 0
58  
59 # escape critical characters so they're not interpreted as special
60 # characters in the regex.
61 my $chars = join '',
62 0 ▶ map { m{^[\-.+*?()\[\]/\\]$} ? sprintf("\\%s", $_) : $_; }
Branch: 1 branch
BranchTrueFalseTotal
m(^[\-.+*?()\[\]/\\]$) ? : 0 0 0
63 $self->get_character_values;
64 0 $self->valid_string_re_cache(qr/^[$chars]+$/);
65 }
66 0 $string =~ $self->valid_string_re_cache;
67 }
68 6 1;
69  
70  
71 __END__
« Conveyor/Monitor.pm ↑ Summary Conveyor/Ticket/Payload.pm »