| 1 | package Connector::Multi::Merge; | ||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use English; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Config::Merge; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||
| 11 | 1 | extends 'Connector::Builtin::Memory'; | |||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||
| 13 | 1 | has '+LOCATION' => ( required => 1 ); | |||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | sub _build_config { | ||||||||||||||||||||||||||||||||
|
Subroutine
_build_config: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||
| 17 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||
| 19 | # Skip the workflow directories | ||||||||||||||||||||||||||||||||||
| 20 | 1 | my $cm = Config::Merge->new( $self->LOCATION() ); | |||||||||||||||||||||||||||||||||
| 21 | 1 | my $cmref = $cm->(); | |||||||||||||||||||||||||||||||||
| 22 | 1 | my $tree = $self->cm2tree($cmref); | |||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||
| 24 | 1 | return $tree; | |||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||
| 28 | # Traverse the tree read from Config::Merge and replace the "@" keys by | ||||||||||||||||||||||||||||||||||
| 29 | # scalar references | ||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||
| 31 | 8 | ▶ | sub cm2tree { | ||||||||||||||||||||||||||||||||
|
Subroutine
cm2tree: called CC=8 SCAR=24.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 32 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 33 | 8 | my $cm = shift; | |||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||
| 35 | 8 | ▶ | if ( ref($cm) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 36 | 6 | my $ret = {}; | |||||||||||||||||||||||||||||||||
| 37 | 6 | foreach my $key ( keys %{$cm} ) { | |||||||||||||||||||||||||||||||||
| 38 | 8 | ▶ | if ( $key =~ m{ (?: \A @ (.*?) @ \z | \A @ (.*) | (.*?) @ \z ) }xms ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 39 | 1 | ▶ | my $match = $1 || $2 || $3; | ||||||||||||||||||||||||||||||||
|
Condition33%2/6
$1 || $2 || $3
$1 or $2
MC/DC0%0/3
$1 || $2 || $3
$1
$2
$3
Truth table25%1/4
A or B || C
A= $1B= $2C= $3
| |||||||||||||||||||||||||||||||||||
| 40 | # make it a ref to an anonymous scalar so we know it's a symlink | ||||||||||||||||||||||||||||||||||
| 41 | 1 | $ret->{$match} = \$cm->{$key}; | |||||||||||||||||||||||||||||||||
| 42 | } else { | ||||||||||||||||||||||||||||||||||
| 43 | 7 | $ret->{$key} = $self->cm2tree( $cm->{$key} ) | |||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||
| 46 | 6 | return $ret; | |||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||
| 48 | elsif ( ref($cm) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||
| 49 | 0 | my $ret = []; | |||||||||||||||||||||||||||||||||
| 50 | 0 | my $i = 0; | |||||||||||||||||||||||||||||||||
| 51 | 0 | foreach my $entry ( @{$cm} ) { | |||||||||||||||||||||||||||||||||
| 52 | 0 | $ret->[ $i++ ] = $self->cm2tree($entry); | |||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||
| 54 | 0 | return $ret; | |||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||
| 56 | else { | ||||||||||||||||||||||||||||||||||
| 57 | 2 | return $cm; | |||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||
| 61 | 1 | 1; | |||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||
| 63 | __DATA__ | ||||||||||||||||||||||||||||||||||