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