| 1 | package Inferno::RegMgr::Utils; | ||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use 5.010001; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use utf8; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||
| 8 | 1 | our $VERSION = 'v1.0.0'; | |||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Export::Attrs; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | sub quote :Export { | ||||||||||||||||||||||||||||||
|
Subroutine
quote: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 14 | 0 | my ($s) = @_; | |||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | if ($s =~ / \s | ' | \A\z /xms) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 16 | 0 | $s =~ s/'/''/xmsg; | |||||||||||||||||||||||||||||||
| 17 | 0 | $s = "'$s'"; | |||||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||||||
| 19 | 0 | return $s; | |||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | } | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub unquote :Export { | ||||||||||||||||||||||||||||||
|
Subroutine
unquote: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 23 | 0 | my ($s) = @_; | |||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | if ($s =~ s/\A'(.*)'\z/$1/xms) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 25 | 0 | $s =~ s/''/'/xmsg; | |||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||
| 27 | 0 | return $s; | |||||||||||||||||||||||||||||||
| 28 | 1 | ▶ | } | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | sub attr :Export { | ||||||||||||||||||||||||||||||
|
Subroutine
attr: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 31 | 0 | my ($attr) = @_; | |||||||||||||||||||||||||||||||
| 32 | 0 | my @s; | |||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | while (my ($k, $v) = each %{ $attr || {} }) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$attr || {}
MC/DC0%0/1
$attr || {}
$attr
Truth table0%0/2
A
A= $attr
| |||||||||||||||||||||||||||||||||
| 34 | 0 | push @s, sprintf '%s %s', quote($k), quote($v); | |||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||
| 36 | 0 | return join q{ }, @s; | |||||||||||||||||||||||||||||||
| 37 | 1 | ▶ | } | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub parse_svc :Export { | ||||||||||||||||||||||||||||||
|
Subroutine
parse_svc: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 40 | 0 | my ($s) = @_; | |||||||||||||||||||||||||||||||
| 41 | 0 | state $qword = qr{( [^'\s]+ | '[^']*(?:''[^']*)*' )}xms; | |||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | return ({}, undef) if $s eq q{}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | return (undef, 'no \\n at end') if $s !~ /\n\z/xms; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 44 | 0 | my %svc; | |||||||||||||||||||||||||||||||
| 45 | 0 | for my $line (split /\n/xms, $s) { | |||||||||||||||||||||||||||||||
| 46 | 0 | my $errmsg = "can't parse service: $line"; | |||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | return (undef, $errmsg) if $line !~ s/\A$qword//xms; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 48 | 0 | my $name = unquote($1); ## no critic (ProhibitCaptureWithoutTest) | |||||||||||||||||||||||||||||||
| 49 | 0 | my %attr; | |||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | while (length $line) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | return (undef, $errmsg) if $line !~ s/\s$qword\s$qword//xms; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 52 | 0 | my ($attr, $value) = ($1, $2); ## no critic (ProhibitCaptureWithoutTest) | |||||||||||||||||||||||||||||||
| 53 | 0 | $attr{ unquote($attr) } = unquote($value); | |||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||
| 55 | 0 | $svc{$name} = \%attr; | |||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||
| 57 | 0 | return (\%svc, undef); | |||||||||||||||||||||||||||||||
| 58 | 1 | ▶ | } | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | 1 | my $STDREF = qr{SCALAR|ARRAY|HASH|CODE|REF|GLOB|LVALUE}xms; | |||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | sub run_callback :Export { | ||||||||||||||||||||||||||||||
|
Subroutine
run_callback: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | croak 'usage: run_callback( CB [, METHOD [, @ARGS]] )' if @_ < 1; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 63 | 0 | my ($cb, $method) = (shift, shift); | |||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | my $cb_type | ||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||
| 65 | = !ref($cb) ? 'CLASS' | ||||||||||||||||||||||||||||||||
| 66 | : ref($cb) eq 'CODE' ? 'CODE' | ||||||||||||||||||||||||||||||||
| 67 | : ref($cb) !~ m{\A$STDREF\z}xmso ? 'OBJECT' | ||||||||||||||||||||||||||||||||
| 68 | : undef | ||||||||||||||||||||||||||||||||
| 69 | ; | ||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if ($cb_type eq 'CLASS' || $cb_type eq 'OBJECT') { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$cb_type eq "CLASS" or $cb_type eq "OBJECT"
MC/DC0%0/2
$cb_type eq "CLASS" or $cb_type eq "OBJECT"
$cb_type eq "CLASS"
$cb_type eq "OBJECT"
Truth table0%0/3
A or B
A= $cb_type eq "CLASS"B= $cb_type eq "OBJECT"
| |||||||||||||||||||||||||||||||||
| 71 | 0 | $cb->$method(@_); | |||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||
| 73 | elsif ($cb_type eq 'CODE') { | ||||||||||||||||||||||||||||||||
| 74 | 0 | $cb->(@_); | |||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||
| 76 | else { | ||||||||||||||||||||||||||||||||
| 77 | 0 | croak qq{run_callback: wrong CB $cb}; | |||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||
| 79 | 0 | return; | |||||||||||||||||||||||||||||||
| 80 | 1 | ▶ | } | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||
| 84 | 1 | 1; # Magic true value required at end of module | |||||||||||||||||||||||||||||||
| 85 | __END__ | ||||||||||||||||||||||||||||||||