| 1 | package DBIx::Class::Helpers::Util; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 57 | $DBIx::Class::Helpers::Util::VERSION = '2.037000'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 57 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 57 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # ABSTRACT: Helper utilities for DBIx::Class components | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 57 | ▶ | use Sub::Exporter::Progressive -setup => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | exports => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | get_namespace_parts is_load_namespaces is_not_load_namespaces | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | assert_similar_namespaces order_by_visitor | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | normalize_connect_info | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 57 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 562 | ▶ | sub get_namespace_parts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_namespace_parts: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 562 | my $package = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 562 | ▶ | if ($package =~ m/(^[\w:]+::Result)::([\w:]+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 562 | return ($1, $2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | die "$package doesn't look like ".'$namespace::Result::$resultclass'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 683 | ▶ | sub is_load_namespaces { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_load_namespaces: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 683 | my $namespace = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 683 | $namespace =~ /^[\w:]+::Result::[\w:]+$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 7 | ▶ | sub is_not_load_namespaces { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_not_load_namespaces: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 7 | my $namespace = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 7 | ▶ | $namespace =~ /^([\w:]+)::[\w]+$/ and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | $1 !~ /::Result/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 341 | ▶ | sub assert_similar_namespaces { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assert_similar_namespaces: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 341 | my $ns1 = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 341 | my $ns2 = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 341 | ▶ | die "Namespaces $ns1 and $ns2 are dissimilar" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
is_load_namespaces($ns1) and is_load_namespaces($ns2) or is_not_load_namespaces($ns1) and is_not_load_namespaces($ns2)
is_load_namespaces($ns1) and is_load_namespaces($ns2)
is_not_load_namespaces($ns1) and is_not_load_namespaces($ns2)
MC/DC75%3/4
is_load_namespaces($ns1) and is_load_namespaces($ns2) or is_not_load_namespaces($ns1) and is_not_load_namespaces($ns2)
is_load_namespaces($ns1)
is_load_namespaces($ns2)
is_not_load_namespaces($ns1)
is_not_load_namespaces($ns2)
Truth table57%4/7
A and B or C and D
A= is_load_namespaces($ns1)B= is_load_namespaces($ns2)C= is_not_load_namespaces($ns1)D= is_not_load_namespaces($ns2)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | unless is_load_namespaces($ns1) and is_load_namespaces($ns2) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | is_not_load_namespaces($ns1) and is_not_load_namespaces($ns2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 4 | ▶ | sub _order_by_visitor_HASHREF { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_order_by_visitor_HASHREF: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 4 | my ($hash, $callback) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 4 | my %ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | # there should only be one k/v pair, but DBIC checks for that and I'm not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # going to reimplement said check here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 4 | for my $k (keys %$hash) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 4 | my $v = $hash->{$k}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 4 | ▶ | if (my $v_ref = ref $v) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | ▶ | if ($v_ref eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | $ret{$k} = [ map $callback->($_), @$v ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | die 'this should never happen' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 3 | $ret{$k} = ($callback->($v)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 4 | \%ret | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 4 | ▶ | sub order_by_visitor { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
order_by_visitor: called CC=6 SCAR=18.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 4 | my ($order, $callback) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 4 | ▶ | if (my $top_ref = ref $order) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 3 | ▶ | if ($top_ref eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | return _order_by_visitor_HASHREF($order, $callback) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } elsif ($top_ref eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 2 | ▶ | if (my $ref = ref $_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 3 | ▶ | if ($ref eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 3 | _order_by_visitor_HASHREF($_, $callback) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | die 'this should never happen' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 2 | $callback->($_) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } @$order | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 1 | return $callback->($order) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 67 | ▶ | sub normalize_connect_info { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
normalize_connect_info: called CC=11 SCAR=24.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 67 | my %all; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 67 | ▶ | if (!ref $_[0]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | %all = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | dsn => $_[0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | ( exists $_[1] ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | (user => $_[1], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | exists $_[2] ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | ( password => $_[2], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | ( exists $_[3] && ref $_[3] ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 2 | ▶ | %{$_[3]} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $_[4] and ref $_[4]
MC/DC50%1/2
exists $_[4] and ref $_[4]
exists $_[4]
ref $_[4]
Truth table66%2/3
A and B
A= exists $_[4]B= ref $_[4]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | : () | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | ( exists $_[4] && ref $_[4] ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 65 | ▶ | %{$_[4]} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%2/3
exists $_[3] and ref $_[3]
MC/DC50%1/2
exists $_[3] and ref $_[3]
exists $_[3]
ref $_[3]
Truth table66%2/3
A and B
A= exists $_[3]B= ref $_[3]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | : () | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | : () | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | : () | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } elsif (ref $_[0] eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | %all = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | dbh_maker => $_[0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | ( exists $_[1] && ref $_[1] ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 2 | ▶ | %{$_[1]} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $_[1] and ref $_[1]
MC/DC50%1/2
exists $_[1] and ref $_[1]
exists $_[1]
ref $_[1]
Truth table66%2/3
A and B
A= exists $_[1]B= ref $_[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | : () | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | %all = %{$_[0]} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 67 | return \%all; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 57 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||