| 1 | #!/usr/bin/perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # llng-build-manager-files - Regenerate LemonLDAP::NG Manager with plugin extensions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # This script allows plugins to extend the Manager configuration by adding | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # new attributes, tree nodes, and portal constants. Extensions can be in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # Perl (.pm) or JSON (.json) format. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # Usage: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # llng-build-manager-files --plugins-dir=/etc/lemonldap-ng/manager-overrides.d --plugins-dir=/other/dir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # Paths are configured via placeholders replaced during installation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # All paths can be overridden via command line options. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use Getopt::Long; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use File::Basename qw(dirname basename); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use Cwd qw(getcwd); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use JSON; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use Storable qw(dclone); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # Pod::Usage is optional - provide fallback if not available | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | my $has_pod_usage = eval { require Pod::Usage; 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | sub show_help { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | my ( $exitcode, $verbose ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_help: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | if ($has_pod_usage) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | Pod::Usage::pod2usage( -exitcode => $exitcode, -verbose => $verbose ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | "Usage: llng-build-manager-files [--plugins-dir=<path> ...] [options]\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | print "Use 'perldoc $0' for full documentation.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | exit $exitcode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # Load the core Build modules to get their data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | require Lemonldap::NG::Manager::Build::Attributes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | require Lemonldap::NG::Manager::Build::Tree; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | require Lemonldap::NG::Manager::Build::CTrees; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | require Lemonldap::NG::Manager::Build::PortalConstants; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | my $VERSION = '2.23.0'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | ############################################################################# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # Default paths - placeholders replaced during installation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # These can all be overridden via command line options | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ############################################################################# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | my $DEFAULT_MANAGERSTATICDIR = '__MANAGERSTATICDIR__'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 1 | my $DEFAULT_PERLLIBDIR = '__INSTALLSITELIB__'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | my $DEFAULT_DOCDIR = '__DOCDIR__'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 1 | my $DEFAULT_LANGDIR = '__MANAGERSTATICDIR__/languages'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | # Command line options | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | my @plugins_dirs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | my ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | $struct_file, $conftree_file, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | $manager_constants_file, $manager_attributes_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | $default_values_file, $conf_constants_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | $first_lmconf_file, $reverse_tree_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | $portal_constants_file, $handler_status_constants_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | $doc_constants_file, $lang_dir, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | $help, $verbose, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | ▶ | GetOptions( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 'plugins-dir=s' => \@plugins_dirs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 'struct-file=s' => \$struct_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 'conftree-file=s' => \$conftree_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 'manager-constants-file=s' => \$manager_constants_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 'manager-attributes-file=s' => \$manager_attributes_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 'default-values-file=s' => \$default_values_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 'conf-constants-file=s' => \$conf_constants_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 'first-lmconf-file=s' => \$first_lmconf_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 'reverse-tree-file=s' => \$reverse_tree_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 'portal-constants-file=s' => \$portal_constants_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 'handler-status-constants-file=s' => \$handler_status_constants_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 'doc-constants-file=s' => \$doc_constants_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 'lang-dir=s' => \$lang_dir, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 'help|h' => \$help, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 'verbose|v' => \$verbose, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | ) or show_help( 1, 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | ▶ | show_help( 0, 2 ) if $help; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | sub verbose { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 13 | ▶ | print @_ if $verbose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verbose: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # plugins-dir is optional - if not specified or doesn't exist, run without extensions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | @plugins_dirs = grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | ▶ | if ( !-d $_ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | print STDERR | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | "Note: Plugins directory not found: $_ (continuing without extensions)\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 1 | else { 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } @plugins_dirs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # Set default paths from placeholders (can be overridden via options) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | ▶ | $struct_file //= "$DEFAULT_MANAGERSTATICDIR/struct.json"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$struct_file //= "$DEFAULT_MANAGERSTATICDIR/struct.json"
MC/DC0%0/1
$struct_file //= "$DEFAULT_MANAGERSTATICDIR/struct.json"
$struct_file
Truth table50%1/2
A
A= $struct_file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | ▶ | $conftree_file //= "$DEFAULT_MANAGERSTATICDIR/js/conftree.js"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$conftree_file //= "$DEFAULT_MANAGERSTATICDIR/js/conftree.js"
MC/DC0%0/1
$conftree_file //= "$DEFAULT_MANAGERSTATICDIR/js/conftree.js"
$conftree_file
Truth table50%1/2
A
A= $conftree_file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 1 | ▶ | $reverse_tree_file //= "$DEFAULT_MANAGERSTATICDIR/reverseTree.json"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$reverse_tree_file //= "$DEFAULT_MANAGERSTATICDIR/reverseTree.json"
MC/DC0%0/1
$reverse_tree_file //= "$DEFAULT_MANAGERSTATICDIR/reverseTree.json"
$reverse_tree_file
Truth table50%1/2
A
A= $reverse_tree_file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 1 | ▶ | $manager_constants_file //= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$manager_constants_file //= "$DEFAULT_PERLLIBDIR/Lemonldap/NG/Common/Conf/ReConstants.pm"
MC/DC0%0/1
$manager_constants_file //= "$DEFAULT_PERLLIBDIR/Lemonldap/NG/Common/Conf/ReConstants.pm"
$manager_constants_file
Truth table50%1/2
A
A= $manager_constants_file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | "$DEFAULT_PERLLIBDIR/Lemonldap/NG/Common/Conf/ReConstants.pm"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 1 | ▶ | $manager_attributes_file //= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$manager_attributes_file //= "$DEFAULT_PERLLIBDIR/Lemonldap/NG/Manager/Attributes.pm"
MC/DC0%0/1
$manager_attributes_file //= "$DEFAULT_PERLLIBDIR/Lemonldap/NG/Manager/Attributes.pm"
$manager_attributes_file
Truth table50%1/2
A
A= $manager_attributes_file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | "$DEFAULT_PERLLIBDIR/Lemonldap/NG/Manager/Attributes.pm"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 1 | ▶ | $default_values_file //= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$default_values_file //= "$DEFAULT_PERLLIBDIR/Lemonldap/NG/Common/Conf/DefaultValues.pm"
MC/DC0%0/1
$default_values_file //= "$DEFAULT_PERLLIBDIR/Lemonldap/NG/Common/Conf/DefaultValues.pm"
$default_values_file
Truth table50%1/2
A
A= $default_values_file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | "$DEFAULT_PERLLIBDIR/Lemonldap/NG/Common/Conf/DefaultValues.pm"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | ▶ | $conf_constants_file //= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$conf_constants_file //= "$DEFAULT_PERLLIBDIR/Lemonldap/NG/Common/Conf/Constants.pm"
MC/DC0%0/1
$conf_constants_file //= "$DEFAULT_PERLLIBDIR/Lemonldap/NG/Common/Conf/Constants.pm"
$conf_constants_file
Truth table50%1/2
A
A= $conf_constants_file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | "$DEFAULT_PERLLIBDIR/Lemonldap/NG/Common/Conf/Constants.pm"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 1 | ▶ | $portal_constants_file //= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$portal_constants_file //= "$DEFAULT_PERLLIBDIR/Lemonldap/NG/Portal/Main/Constants.pm"
MC/DC0%0/1
$portal_constants_file //= "$DEFAULT_PERLLIBDIR/Lemonldap/NG/Portal/Main/Constants.pm"
$portal_constants_file
Truth table50%1/2
A
A= $portal_constants_file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | "$DEFAULT_PERLLIBDIR/Lemonldap/NG/Portal/Main/Constants.pm"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 1 | ▶ | $handler_status_constants_file //= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$handler_status_constants_file //= "$DEFAULT_PERLLIBDIR/Lemonldap/NG/Handler/Lib/StatusConstants.pm"
MC/DC0%0/1
$handler_status_constants_file //= "$DEFAULT_PERLLIBDIR/Lemonldap/NG/Handler/Lib/StatusConstants.pm"
$handler_status_constants_file
Truth table50%1/2
A
A= $handler_status_constants_file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | "$DEFAULT_PERLLIBDIR/Lemonldap/NG/Handler/Lib/StatusConstants.pm"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | ▶ | $first_lmconf_file //= '/dev/null'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$first_lmconf_file //= "/dev/null"
MC/DC0%0/1
$first_lmconf_file //= "/dev/null"
$first_lmconf_file
Truth table50%1/2
A
A= $first_lmconf_file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | ▶ | $doc_constants_file //= '/dev/null'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$doc_constants_file //= "/dev/null"
MC/DC0%0/1
$doc_constants_file //= "/dev/null"
$doc_constants_file
Truth table50%1/2
A
A= $doc_constants_file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | ▶ | $lang_dir //= $DEFAULT_LANGDIR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$lang_dir //= $DEFAULT_LANGDIR
MC/DC0%0/2
$lang_dir //= $DEFAULT_LANGDIR
$lang_dir
$DEFAULT_LANGDIR
Truth table33%1/3
A //= B
A= $lang_dirB= $DEFAULT_LANGDIR
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | # Validate that placeholders were replaced (unless overridden) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 1 | ▶ | if ( $struct_file =~ /__(?:MANAGERSTATICDIR|INSTALLSITELIB)__/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | die "Error: placeholders not replaced during installation.\n" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | . "Please specify paths via command line options.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | ▶ | verbose "Configuration:\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | . " plugins-dir: " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | . ( @plugins_dirs ? join( ', ', @plugins_dirs ) : '(none)' ) . "\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | . " struct-file: $struct_file\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | . " conftree-file: $conftree_file\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | . " manager-constants-file: $manager_constants_file\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | . " manager-attributes-file: $manager_attributes_file\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | . " default-values-file: $default_values_file\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | . " conf-constants-file: $conf_constants_file\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | . " reverse-tree-file: $reverse_tree_file\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | . " portal-constants-file: $portal_constants_file\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | . " handler-status-constants-file: $handler_status_constants_file\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | . " lang-dir: $lang_dir\n" . "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | # 1. Load core data from Build modules | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 1 | verbose "Loading core configuration data...\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 1 | my $attributes = Lemonldap::NG::Manager::Build::Attributes::attributes(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 1 | my $tree = Lemonldap::NG::Manager::Build::Tree::tree(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 1 | my $ctrees = Lemonldap::NG::Manager::Build::CTrees::cTrees(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | my $constants = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | Lemonldap::NG::Manager::Build::PortalConstants::portalConstants(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | # 2. Load and merge extensions from plugins directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | my @ext_files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 1 | ▶ | if (@plugins_dirs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | for my $dir (@plugins_dirs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 1 | my @files = sort( glob("$dir/*.pm"), glob("$dir/*.json") ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | ▶ | verbose @files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | ? "Found " . scalar(@files) . " extension file(s) in $dir\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | : "No extension files found in $dir\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | push @ext_files, @files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | verbose "No plugins directory specified, running without extensions\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 1 | my @auth_plugins; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | for my $ext_file (@ext_files) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 1 | verbose "Loading extension: $ext_file\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 1 | my $ext = load_extension($ext_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 1 | merge_extension( $attributes, $tree, $ctrees, $constants, $ext, $ext_file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 1 | push @auth_plugins, collect_auth_plugins( $ext->{authPlugin}, $ext_file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | # Warn on conflicting authPlugin declarations (same k with a different v | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | # or a different role set across extension files). Dedup below keeps only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | # the first-seen label, so flag the conflict to the maintainer. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 1 | warn_auth_plugin_conflicts( \@auth_plugins ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | # Apply auth plugin declarations to the initial merged attributes so the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | # diff-based extraction below also picks up auth-plugin-driven additions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | # This initial pass also populates nested authChoiceModules; auth plugins | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | # are re-applied again at call time via @auth_plugins on fresh Build.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | # data so nested-select changes survive dclone(). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 1 | apply_auth_plugins( $attributes, \@auth_plugins ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | # 3. Store extension data for merging at call time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | # Build.pm modifies data in place, so we need fresh copies each time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 1 | verbose "Patching Build modules with merged data...\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | # Store only the EXTENSION data (not the full merged data) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 1 | my $ext_attributes = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 1 | my $ext_tree = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 1 | my $ext_ctrees = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 1 | my $ext_constants = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | my $ext_lang = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | # Extract extensions by comparing with original | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 1 | my $orig_attrs = Lemonldap::NG::Manager::Build::Attributes::attributes(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 1 | my $orig_attr_keys = { map { $_ => 1 } keys %$orig_attrs }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | # Store select append operations separately (for existing attributes with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | # new select options added by extensions) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 1 | my $ext_select_appends = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | for my $key ( keys %$attributes ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 1019 | ▶ | if ( $orig_attr_keys->{$key} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | # Check if select options were appended to an existing attribute | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 1017 | ▶ | if ( ref $orig_attrs->{$key} eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
ref $orig_attrs->{$key} eq "HASH" and ref $attributes->{$key} eq "HASH" and ref $orig_attrs->{$key}{"select"} eq "ARRAY" and ref $attributes->{$key}{"select"} eq "ARRAY"
ref $orig_attrs->{$key} eq "HASH" and ref $attributes->{$key} eq "HASH" and ref $orig_attrs->{$key}{"select"} eq "ARRAY"
ref $orig_attrs->{$key} eq "HASH" and ref $attributes->{$key} eq "HASH"
MC/DC0%0/4
ref $orig_attrs->{$key} eq "HASH" and ref $attributes->{$key} eq "HASH" and ref $orig_attrs->{$key}{"select"} eq "ARRAY" and ref $attributes->{$key}{"select"} eq "ARRAY"
ref $orig_attrs->{$key} eq "HASH"
ref $attributes->{$key} eq "HASH"
ref $orig_attrs->{$key}{"select"} eq "ARRAY"
ref $attributes->{$key}{"select"} eq "ARRAY"
Truth table0%0/5
A and B and C and D
A= ref $orig_attrs->{$key} eq "HASH"B= ref $attributes->{$key} eq "HASH"C= ref $orig_attrs->{$key}{"select"} eq "ARRAY"D= ref $attributes->{$key}{"select"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | && ref $attributes->{$key} eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | && ref $orig_attrs->{$key}{select} eq 'ARRAY' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | && ref $attributes->{$key}{select} eq 'ARRAY' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | my %orig_keys = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 418 | map { $_->{k} => 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 421 | ▶ | grep { ref $_ eq 'HASH' && exists $_->{k} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 69 | @{ $orig_attrs->{$key}{select} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | my @new_opts = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 422 | ▶ | grep { ref $_ eq 'HASH' && $_->{k} && !$orig_keys{ $_->{k} } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $_ eq "HASH" and $_->{"k"}
MC/DC100%2/2
ref $_ eq "HASH" and $_->{"k"}
ref $_ eq "HASH"
$_->{"k"}
Truth table100%3/3
A and B
A= ref $_ eq "HASH"B= $_->{"k"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 69 | @{ $attributes->{$key}{select} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 69 | ▶ | $ext_select_appends->{$key} = \@new_opts if @new_opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 2 | $ext_attributes->{$key} = $attributes->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | # For tree: store extension modifications to replay on each fresh copy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | # We need to re-apply extensions to fresh tree data because Build.pm modifies the tree in place | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | # (e.g., $leaf =~ s/^\*// removes * prefix on first scan) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 1 | my @tree_extensions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 1 | for my $ext_file (@ext_files) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 1 | my $ext = load_extension($ext_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 1 | ▶ | if ( $ext->{tree} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | my @trees = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 1 | ▶ | ref $ext->{tree} eq 'ARRAY' ? @{ $ext->{tree} } : ( $ext->{tree} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 1 | for my $t (@trees) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 1 | ▶ | push @tree_extensions, { ext => $t, file => $ext_file } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$t and %$t
MC/DC0%0/2
$t and %$t
$t
%$t
Truth table33%1/3
A and B
A= $tB= %$t
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | if $t && %$t; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 1 | ▶ | for my $ctree_name ( keys %{ $ext->{ctrees} || {} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 1 | my $spec = $ext->{ctrees}{$ctree_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 1 | ▶ | my @specs = ref $spec eq 'ARRAY' ? @$spec : ($spec); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 1 | for my $s (@specs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 1 | push @{ $ext_ctrees->{$ctree_name} }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | { ext => $s, file => $ext_file }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | # Collect translations | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 1 | ▶ | if ( $ext->{lang} && %{ $ext->{lang} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ext->{"lang"} and %{$ext->{"lang"};}
MC/DC0%0/2
$ext->{"lang"} and %{$ext->{"lang"};}
$ext->{"lang"}
%{$ext->{"lang"};}
Truth table33%1/3
A and B
A= $ext->{"lang"}B= %{$ext->{"lang"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 1 | for my $key ( keys %{ $ext->{lang} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 2 | ▶ | if ( exists $ext_lang->{$key} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | warn "Warning [$ext_file]: Overriding translation key '$key'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 2 | $ext_lang->{$key} = $ext->{lang}{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 2 | verbose " Added translation: $key\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | # Save original functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 1 | my $orig_attributes = \&Lemonldap::NG::Manager::Build::Attributes::attributes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 1 | my $orig_tree = \&Lemonldap::NG::Manager::Build::Tree::tree; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 1 | my $orig_ctrees = \&Lemonldap::NG::Manager::Build::CTrees::cTrees; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 1 | my $orig_constants = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | \&Lemonldap::NG::Manager::Build::PortalConstants::portalConstants; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 1 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | *Lemonldap::NG::Manager::Build::Attributes::attributes = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | my $fresh = $orig_attributes->(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | # Merge extension attributes (new attributes) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | for my $key ( keys %$ext_attributes ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | $fresh->{$key} = $ext_attributes->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | # Apply select appends (new options added to existing select attributes) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | for my $key ( keys %$ext_select_appends ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | if ( ref $fresh->{$key} eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $fresh->{$key} eq "HASH" and ref $fresh->{$key}{"select"} eq "ARRAY"
MC/DC0%0/2
ref $fresh->{$key} eq "HASH" and ref $fresh->{$key}{"select"} eq "ARRAY"
ref $fresh->{$key} eq "HASH"
ref $fresh->{$key}{"select"} eq "ARRAY"
Truth table0%0/3
A and B
A= ref $fresh->{$key} eq "HASH"B= ref $fresh->{$key}{"select"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | && ref $fresh->{$key}{select} eq 'ARRAY' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | my %existing = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | map { $_->{k} => 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | grep { ref $_ eq 'HASH' && exists $_->{k} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | @{ $fresh->{$key}{select} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | for my $opt ( @{ $ext_select_appends->{$key} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | push @{ $fresh->{$key}{select} }, $opt | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | unless $existing{ $opt->{k} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | # Apply authPlugin declarations (fills authentication / userDB / | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | # passwordDB / authChoiceModules / combModules selects based on | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | # declared roles). Safe to re-run: each append is deduplicated. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | apply_auth_plugins( $fresh, \@auth_plugins ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | return $fresh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | # For tree: return a fresh deep copy and re-apply extensions each time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | # This is necessary because Build.pm modifies the tree in place | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | # (e.g., scanTree does $leaf =~ s/^\*// which removes * prefix) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | *Lemonldap::NG::Manager::Build::Tree::tree = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | my $fresh = dclone( $orig_tree->() ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | for my $ext_info (@tree_extensions) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | merge_tree( $fresh, $ext_info->{ext}, $ext_info->{file} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | return $fresh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | # For ctrees: also return fresh deep copy since scanTree is called on each ctree node | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | *Lemonldap::NG::Manager::Build::CTrees::cTrees = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | my $fresh = dclone( $orig_ctrees->() ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | for my $ctree_name ( keys %$ext_ctrees ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | for my $ext_info ( @{ $ext_ctrees->{$ctree_name} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | apply_ctree_extension( $fresh, $ctree_name, $ext_info->{ext}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | $ext_info->{file} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | return $fresh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | *Lemonldap::NG::Manager::Build::PortalConstants::portalConstants = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 1 | ▶ | sub { $constants }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | # 4. Load Build.pm (modules are already loaded, functions are patched) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 1 | require Lemonldap::NG::Manager::Build; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | # 5a. Preserve DEFAULTCONFFILE and dirName from installed Constants.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | # These values may have been customized by Makefile.PL (via LMNGCONFFILE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | # and LMNGCONFDIR env vars). Build.pm regenerates Constants.pm with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | # hardcoded defaults, so we read the current values and restore them after. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | my ( $saved_conffile, $saved_dirname ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | if ( $conf_constants_file ne '/dev/null' && -r $conf_constants_file ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$conf_constants_file ne "/dev/null" and -r $conf_constants_file
MC/DC0%0/2
$conf_constants_file ne "/dev/null" and -r $conf_constants_file
$conf_constants_file ne "/dev/null"
-r $conf_constants_file
Truth table0%0/3
A and B
A= $conf_constants_file ne "/dev/null"B= -r $conf_constants_file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | open my $fh, '<', $conf_constants_file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | if (/^use constant DEFAULTCONFFILE\s*=>\s*"(.+)"\s*;/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | $saved_conffile = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | elsif (/^\s*dirName\s*=>\s*'(.+)'\s*,/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | $saved_dirname = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | verbose " Preserved DEFAULTCONFFILE=$saved_conffile\n" if $saved_conffile; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | verbose " Preserved dirName=$saved_dirname\n" if $saved_dirname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | # 5b. Redirect output files to /dev/null when their parent directory does not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | # exist (component not installed locally, e.g. portal or handler absent) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | for my $ref ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | \$struct_file, \$conftree_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | \$manager_constants_file, \$manager_attributes_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | \$default_values_file, \$conf_constants_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | \$reverse_tree_file, \$portal_constants_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | \$handler_status_constants_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | if ( $$ref ne '/dev/null' && !-d dirname($$ref) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$$ref ne "/dev/null" and not -d dirname($$ref)
MC/DC0%0/2
$$ref ne "/dev/null" and not -d dirname($$ref)
$$ref ne "/dev/null"
not -d dirname($$ref)
Truth table0%0/3
A and not(B)
A= $$ref ne "/dev/null"B= not -d dirname($$ref)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | verbose " Skipping $$ref (parent directory does not exist)\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | $$ref = '/dev/null'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | # 6. Call Build.pm::run() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | verbose "Running Build.pm to generate files...\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | Lemonldap::NG::Manager::Build->run( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | structFile => $struct_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | confTreeFile => $conftree_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | managerConstantsFile => $manager_constants_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | managerAttributesFile => $manager_attributes_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | defaultValuesFile => $default_values_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | confConstantsFile => $conf_constants_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | firstLmConfFile => $first_lmconf_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | reverseTreeFile => $reverse_tree_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | portalConstantsFile => $portal_constants_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | handlerStatusConstantsFile => $handler_status_constants_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | docConstantsFile => $doc_constants_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | # 6a. Restore preserved DEFAULTCONFFILE and dirName in Constants.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | if ( $conf_constants_file ne '/dev/null' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$conf_constants_file ne "/dev/null" and $saved_conffile || $saved_dirname
$saved_conffile or $saved_dirname
MC/DC0%0/3
$conf_constants_file ne "/dev/null" and $saved_conffile || $saved_dirname
$conf_constants_file ne "/dev/null"
$saved_conffile
$saved_dirname
Truth table0%0/4
A and B or C
A= $conf_constants_file ne "/dev/null"B= $saved_conffileC= $saved_dirname
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | && ( $saved_conffile || $saved_dirname ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | open my $fh, '<', $conf_constants_file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | or die "Cannot read $conf_constants_file: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | my $content = do { local $/; <$fh> }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | my $modified = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | if ( $saved_conffile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$saved_conffile and $content =~ s/^(use constant DEFAULTCONFFILE\s*=>\s*").*("\s*;)/$1$saved_conffile$2/m
MC/DC0%0/2
$saved_conffile and $content =~ s/^(use constant DEFAULTCONFFILE\s*=>\s*").*("\s*;)/$1$saved_conffile$2/m
$saved_conffile
$content =~ s/^(use constant DEFAULTCONFFILE\s*=>\s*").*("\s*;)/$1$saved_conffile$2/m
Truth table0%0/3
A and B
A= $saved_conffileB= $content =~ s/^(use constant DEFAULTCONFFILE\s*=>\s*").*("\s*;)/$1$saved_conffile$2/m
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | && $content =~ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | s{^(use constant DEFAULTCONFFILE\s*=>\s*").*("\s*;)}{$1$saved_conffile$2}m | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | $modified = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | verbose " Restored DEFAULTCONFFILE=$saved_conffile\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | if ( $saved_dirname | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$saved_dirname and $content =~ s/^(\s*dirName\s*=>\s*').*('\s*,)/$1$saved_dirname$2/m
MC/DC0%0/2
$saved_dirname and $content =~ s/^(\s*dirName\s*=>\s*').*('\s*,)/$1$saved_dirname$2/m
$saved_dirname
$content =~ s/^(\s*dirName\s*=>\s*').*('\s*,)/$1$saved_dirname$2/m
Truth table0%0/3
A and B
A= $saved_dirnameB= $content =~ s/^(\s*dirName\s*=>\s*').*('\s*,)/$1$saved_dirname$2/m
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | && $content =~ s{^(\s*dirName\s*=>\s*').*('\s*,)}{$1$saved_dirname$2}m ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | $modified = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | verbose " Restored dirName=$saved_dirname\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | if ($modified) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | open my $out, '>', $conf_constants_file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | or die "Cannot write $conf_constants_file: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | print $out $content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | close $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | # 6b. Minify conftree.js | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | if ( $conftree_file ne '/dev/null' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | minify_conftree($conftree_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | verbose "Skipping minification (conftree.js not generated)\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | # 7. Update language files with translations from extensions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | if ( %$ext_lang && -d $lang_dir ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
%$ext_lang and -d $lang_dir
MC/DC0%0/2
%$ext_lang and -d $lang_dir
%$ext_lang
-d $lang_dir
Truth table0%0/3
A and B
A= %$ext_langB= -d $lang_dir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | verbose "Updating language files in $lang_dir...\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | update_language_files( $lang_dir, $ext_lang ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | elsif (%$ext_lang) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | warn "Warning: Language directory not found: $lang_dir\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | warn " Translations from extensions will not be applied.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | verbose "Build completed successfully.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | exit 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | # Helper functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | sub load_extension { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 2 | ▶ | my ($file) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_extension: called CC=3 SCAR=16.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 2 | ▶ | if ( $file =~ /\.json$/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 2 | return load_json_extension($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | elsif ( $file =~ /\.pm$/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | return load_perl_extension($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | warn "Unknown extension file type: $file\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | return {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | sub load_json_extension { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 2 | ▶ | my ($file) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_json_extension: called CC=7 SCAR=21.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 2 | ▶ | open my $fh, '<', $file or die "Cannot open $file: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 2 | local $/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 2 | my $content = <$fh>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 2 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 2 | my $data = JSON->new->utf8->decode($content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | attributes => $data->{attributes} || {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | tree => $data->{tree} || {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | ctrees => $data->{ctrees} || {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | constants => $data->{constants} || {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | lang => $data->{lang} || {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | authPlugin => $data->{authPlugin}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 2 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%5/10
$data->{'attributes'} || {}
$data->{'tree'} || {}
$data->{'ctrees'} || {}
$data->{'constants'} || {}
$data->{'lang'} || {}
MC/DC0%0/1
$data->{'attributes'} || {}
$data->{'attributes'}
MC/DC0%0/1
$data->{'tree'} || {}
$data->{'tree'}
MC/DC0%0/1
$data->{'ctrees'} || {}
$data->{'ctrees'}
MC/DC0%0/1
$data->{'constants'} || {}
$data->{'constants'}
MC/DC0%0/1
$data->{'lang'} || {}
$data->{'lang'}
Truth table50%1/2
A
A= $data->{'attributes'}
Truth table50%1/2
A
A= $data->{'tree'}
Truth table50%1/2
A
A= $data->{'ctrees'}
Truth table50%1/2
A
A= $data->{'constants'}
Truth table50%1/2
A
A= $data->{'lang'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | sub load_perl_extension { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | my ($file) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_perl_extension: not called CC=10 SCAR=44.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | # Read the file content to find the package name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | my $content = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | open my $fh, '<', $file or die "Cannot open $file: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | local $/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | <$fh>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | # Extract package name from the file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | my ($pkg) = $content =~ /^\s*package\s+([\w:]+)\s*;/m; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | ▶ | unless ($pkg) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | # If no package declaration, create one with a unique name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | $pkg = $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | $pkg =~ s/[^a-zA-Z0-9]/_/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | $pkg = "LLNGExtension::$pkg"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | $content = "package $pkg;\n$content"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | # Eval the code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | eval $content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | ▶ | die "Error loading $file: $@" if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | # Extract data from the extension module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | my $ext = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | $ext->{attributes} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | ▶ | defined &{"${pkg}::attributes"} ? &{"${pkg}::attributes"}() : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | ▶ | $ext->{tree} = defined &{"${pkg}::tree"} ? &{"${pkg}::tree"}() : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | ▶ | $ext->{ctrees} = defined &{"${pkg}::ctrees"} ? &{"${pkg}::ctrees"}() : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | $ext->{constants} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | ▶ | defined &{"${pkg}::constants"} ? &{"${pkg}::constants"}() : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | ▶ | $ext->{lang} = defined &{"${pkg}::lang"} ? &{"${pkg}::lang"}() : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | $ext->{authPlugin} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | ▶ | defined &{"${pkg}::authPlugin"} ? &{"${pkg}::authPlugin"}() : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 1 | ▶ | use strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | return $ext; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | # Normalize an extension's `authPlugin` entry into a list of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | # { k, v, roles, file } hashes. Accepts a single hash or an array of hashes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | sub collect_auth_plugins { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 1 | ▶ | my ( $raw, $ext_file ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
collect_auth_plugins: called CC=11 SCAR=46.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 1 | ▶ | return () unless $raw; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | ▶ | my @entries = ref $raw eq 'ARRAY' ? @$raw : ($raw); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | my @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | for my $entry (@entries) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | unless ( ref $entry eq 'HASH' && $entry->{k} && $entry->{v} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $entry eq "HASH" and $entry->{"k"} and $entry->{"v"}
ref $entry eq "HASH" and $entry->{"k"}
MC/DC0%0/3
ref $entry eq "HASH" and $entry->{"k"} and $entry->{"v"}
ref $entry eq "HASH"
$entry->{"k"}
$entry->{"v"}
Truth table0%0/4
A and B and C
A= ref $entry eq "HASH"B= $entry->{"k"}C= $entry->{"v"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | warn | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | "Warning [$ext_file]: authPlugin entries must have 'k' and 'v' keys\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | my $roles = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | ref $entry->{roles} eq 'ARRAY' ? $entry->{roles} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | : $entry->{roles} ? [ $entry->{roles} ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | : []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | ▶ | unless (@$roles) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | warn | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | "Warning [$ext_file]: authPlugin '$entry->{k}' declares no roles\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | my %valid = map { $_ => 1 } qw(authentication userDB passwordDB); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | my @bad = grep { !$valid{$_} } @$roles; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | ▶ | if (@bad) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | warn "Warning [$ext_file]: authPlugin '$entry->{k}' has " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | . "unknown role(s): @bad (allowed: authentication, userDB, passwordDB)\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | push @out, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | k => $entry->{k}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | v => $entry->{v}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | roles => [ grep { $valid{$_} } @$roles ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | file => $ext_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | return @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | # Mutate $attrs so the given auth plugins appear in the right select lists: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | # authentication role -> authentication.select, authChoiceModules.select[0], combModules.select | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | # userDB role -> userDB.select, authChoiceModules.select[1], combModules.select | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | # passwordDB role -> passwordDB.select, authChoiceModules.select[2] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | # All appends dedupe on the `k` key so re-running is safe. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | sub apply_auth_plugins { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 1 | ▶ | my ( $attrs, $plugins ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply_auth_plugins: called CC=8 SCAR=37.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 1 | ▶ | return unless $attrs && $plugins && @$plugins; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$attrs and $plugins and @$plugins
$attrs and $plugins
MC/DC0%0/3
$attrs and $plugins and @$plugins
$attrs
$plugins
@$plugins
Truth table25%1/4
A and B and C
A= $attrsB= $pluginsC= @$plugins
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | my %role_to_flat = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | authentication => 'authentication', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | userDB => 'userDB', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | passwordDB => 'passwordDB', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | my %role_to_choice_idx = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | authentication => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | userDB => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | passwordDB => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | for my $plugin (@$plugins) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | my $opt = { k => $plugin->{k}, v => $plugin->{v} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | my %roles = map { $_ => 1 } @{ $plugin->{roles} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | for my $role ( keys %roles ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | _append_flat_select( $attrs, $role_to_flat{$role}, $opt ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | _append_nested_select( $attrs, 'authChoiceModules', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | $role_to_choice_idx{$role}, $opt ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | # combModules only covers authentication and userDB roles | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | ▶ | if ( $roles{authentication} || $roles{userDB} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$roles{"authentication"} or $roles{"userDB"}
MC/DC0%0/2
$roles{"authentication"} or $roles{"userDB"}
$roles{"authentication"}
$roles{"userDB"}
Truth table0%0/3
A or B
A= $roles{"authentication"}B= $roles{"userDB"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | _append_flat_select( $attrs, 'combModules', $opt ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | sub warn_auth_plugin_conflicts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 1 | ▶ | my ($plugins) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
warn_auth_plugin_conflicts: called CC=5 SCAR=30.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 1 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 1 | for my $p (@$plugins) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | my $prev = $seen{ $p->{k} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | ▶ | unless ($prev) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | $seen{ $p->{k} } = $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | ▶ | if ( $prev->{v} ne $p->{v} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | warn "Warning [$p->{file}]: authPlugin '$p->{k}' label differs " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | . "from earlier declaration in $prev->{file} " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | . "('$p->{v}' vs '$prev->{v}'); keeping '$prev->{v}'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | my $prev_roles = join ',', sort @{ $prev->{roles} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | my $curr_roles = join ',', sort @{ $p->{roles} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | ▶ | if ( $prev_roles ne $curr_roles ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | warn "Warning [$p->{file}]: authPlugin '$p->{k}' roles differ " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | . "from earlier declaration in $prev->{file} " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | . "($curr_roles vs $prev_roles); union will be applied\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | sub _append_flat_select { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | ▶ | my ( $attrs, $key, $opt ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_append_flat_select: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | ▶ | return unless ref $attrs->{$key} eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | ▶ | return unless ref $attrs->{$key}{select} eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | for my $existing ( @{ $attrs->{$key}{select} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | if ref $existing eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | && defined $existing->{k} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | ▶ | && $existing->{k} eq $opt->{k}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $existing eq "HASH" and defined $existing->{"k"} and $existing->{"k"} eq $opt->{"k"}
ref $existing eq "HASH" and defined $existing->{"k"}
MC/DC0%0/3
ref $existing eq "HASH" and defined $existing->{"k"} and $existing->{"k"} eq $opt->{"k"}
ref $existing eq "HASH"
defined $existing->{"k"}
$existing->{"k"} eq $opt->{"k"}
Truth table0%0/4
A and B and C
A= ref $existing eq "HASH"B= defined $existing->{"k"}C= $existing->{"k"} eq $opt->{"k"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | push @{ $attrs->{$key}{select} }, {%$opt}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | sub _append_nested_select { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | ▶ | my ( $attrs, $key, $idx, $opt ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_append_nested_select: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | ▶ | return unless ref $attrs->{$key} eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | ▶ | return unless ref $attrs->{$key}{select} eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | ▶ | return unless ref $attrs->{$key}{select}[$idx] eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | for my $existing ( @{ $attrs->{$key}{select}[$idx] } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | if ref $existing eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | && defined $existing->{k} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | ▶ | && $existing->{k} eq $opt->{k}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $existing eq "HASH" and defined $existing->{"k"} and $existing->{"k"} eq $opt->{"k"}
ref $existing eq "HASH" and defined $existing->{"k"}
MC/DC0%0/3
ref $existing eq "HASH" and defined $existing->{"k"} and $existing->{"k"} eq $opt->{"k"}
ref $existing eq "HASH"
defined $existing->{"k"}
$existing->{"k"} eq $opt->{"k"}
Truth table0%0/4
A and B and C
A= ref $existing eq "HASH"B= defined $existing->{"k"}C= $existing->{"k"} eq $opt->{"k"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | push @{ $attrs->{$key}{select}[$idx] }, {%$opt}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | sub merge_extension { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 1 | ▶ | my ( $core_attrs, $core_tree, $core_ctrees, $core_constants, $ext, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge_extension: called CC=9 SCAR=26.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | $ext_file ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | # Merge attributes (simple hash merge) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 1 | merge_attributes( $core_attrs, $ext->{attributes}, $ext_file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | # Merge tree (insert nodes at specified path) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | # Support both single hash and array of hashes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 1 | ▶ | if ( $ext->{tree} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | my @trees = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 1 | ▶ | ref $ext->{tree} eq 'ARRAY' ? @{ $ext->{tree} } : ( $ext->{tree} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 1 | for my $t (@trees) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 1 | ▶ | merge_tree( $core_tree, $t, $ext_file ) if $t && %$t; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$t and %$t
MC/DC0%0/2
$t and %$t
$t
%$t
Truth table33%1/3
A and B
A= $tB= %$t
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | # Merge ctrees (insert into specific node templates) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | merge_ctrees( $core_ctrees, $ext->{ctrees}, $ext_file ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 1 | ▶ | if $ext->{ctrees} && %{ $ext->{ctrees} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ext->{"ctrees"} and %{$ext->{"ctrees"};}
MC/DC0%0/2
$ext->{"ctrees"} and %{$ext->{"ctrees"};}
$ext->{"ctrees"}
%{$ext->{"ctrees"};}
Truth table33%1/3
A and B
A= $ext->{"ctrees"}B= %{$ext->{"ctrees"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | # Merge constants (with validation) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | merge_constants( $core_constants, $ext->{constants}, $ext_file ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 1 | ▶ | if $ext->{constants}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | sub merge_attributes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 1 | ▶ | my ( $core, $ext, $ext_file ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge_attributes: called CC=12 SCAR=28.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 1 | for my $key ( keys %$ext ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 3 | ▶ | if ( exists $core->{$key} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | # If both core and extension have a 'select' array, append new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | # options instead of replacing the entire attribute | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 1 | ▶ | if ( ref $core->{$key} eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
ref $core->{$key} eq "HASH" and ref $ext->{$key} eq "HASH" and ref $core->{$key}{"select"} eq "ARRAY" and ref $ext->{$key}{"select"} eq "ARRAY"
ref $core->{$key} eq "HASH" and ref $ext->{$key} eq "HASH" and ref $core->{$key}{"select"} eq "ARRAY"
ref $core->{$key} eq "HASH" and ref $ext->{$key} eq "HASH"
MC/DC0%0/4
ref $core->{$key} eq "HASH" and ref $ext->{$key} eq "HASH" and ref $core->{$key}{"select"} eq "ARRAY" and ref $ext->{$key}{"select"} eq "ARRAY"
ref $core->{$key} eq "HASH"
ref $ext->{$key} eq "HASH"
ref $core->{$key}{"select"} eq "ARRAY"
ref $ext->{$key}{"select"} eq "ARRAY"
Truth table20%1/5
A and B and C and D
A= ref $core->{$key} eq "HASH"B= ref $ext->{$key} eq "HASH"C= ref $core->{$key}{"select"} eq "ARRAY"D= ref $ext->{$key}{"select"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | && ref $ext->{$key} eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | && ref $core->{$key}{select} eq 'ARRAY' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | && ref $ext->{$key}{select} eq 'ARRAY' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | my %existing = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 28 | map { $_->{k} => 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 28 | ▶ | grep { ref $_ eq 'HASH' && exists $_->{k} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 1 | @{ $core->{$key}{select} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 1 | for my $opt ( @{ $ext->{$key}{select} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 1 | ▶ | next unless ref $opt eq 'HASH' && $opt->{k}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $opt eq "HASH" and $opt->{"k"}
MC/DC0%0/2
ref $opt eq "HASH" and $opt->{"k"}
ref $opt eq "HASH"
$opt->{"k"}
Truth table33%1/3
A and B
A= ref $opt eq "HASH"B= $opt->{"k"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 1 | ▶ | unless ( $existing{ $opt->{k} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 1 | push @{ $core->{$key}{select} }, $opt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 1 | verbose | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | " Appended select option '$opt->{k}' to attribute '$key'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | warn "Warning [$ext_file]: Overriding existing attribute '$key'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 2 | $core->{$key} = $ext->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 2 | verbose " Added attribute: $key\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | sub merge_tree { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 1 | ▶ | my ( $core_tree, $ext_tree, $ext_file ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge_tree: called CC=6 SCAR=22.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 1 | my $insert_into = $ext_tree->{insert_into}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 1 | my $nodes = $ext_tree->{nodes}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 1 | ▶ | unless ( $insert_into && $nodes ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$insert_into and $nodes
MC/DC0%0/2
$insert_into and $nodes
$insert_into
$nodes
Truth table33%1/3
A and B
A= $insert_intoB= $nodes
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | warn | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | "Warning [$ext_file]: tree extension requires 'insert_into' and 'nodes'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | # Find the target node by path (e.g., "generalParameters/plugins") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 1 | my @path_parts = split '/', $insert_into; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 1 | my $target = find_tree_node( $core_tree, \@path_parts ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 1 | ▶ | unless ($target) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | warn "Warning [$ext_file]: Could not find tree path: $insert_into\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | # Insert the new nodes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 1 | my $insert_after = $ext_tree->{insert_after}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 1 | my $insert_before = $ext_tree->{insert_before}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 1 | ▶ | if ($insert_after) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 1 | insert_nodes_after( $target->{nodes}, $insert_after, $nodes, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | $ext_file ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | elsif ($insert_before) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | insert_nodes_before( $target->{nodes}, $insert_before, $nodes, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | $ext_file ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | # Default: append at end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | push @{ $target->{nodes} }, @$nodes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 1 | verbose " Inserted tree nodes into: $insert_into\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | sub find_tree_node { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 4 | ▶ | my ( $tree, $path_parts ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_tree_node: called CC=8 SCAR=21.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 4 | ▶ | return undef unless @$path_parts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 4 | my $current_name = shift @$path_parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 4 | for my $node (@$tree) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 12 | ▶ | next unless ref($node) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 11 | ▶ | next unless ( $node->{title} // '' ) eq $current_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$node->{"title"} // ""
MC/DC0%0/1
$node->{"title"} // ""
$node->{"title"}
Truth table50%1/2
A
A= $node->{"title"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 4 | ▶ | if ( @$path_parts == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 2 | return $node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | elsif ( $node->{nodes} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 2 | return find_tree_node( $node->{nodes}, $path_parts ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | sub insert_nodes_after { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 2 | ▶ | my ( $nodes_array, $after_title, $new_nodes, $ext_file ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
insert_nodes_after: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 2 | for my $i ( 0 .. $#$nodes_array ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 36 | my $node = $nodes_array->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 36 | ▶ | my $title = ref($node) eq 'HASH' ? $node->{title} : $node; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 36 | ▶ | next unless defined $title; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 36 | ▶ | if ( $title eq $after_title ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 1 | splice @$nodes_array, $i + 1, 0, @$new_nodes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | # Reference not found in the target: append at end rather than failing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 1 | ▶ | warn "Warning" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | . ( $ext_file ? " [$ext_file]" : "" ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | . ": insert_after reference '$after_title' not found, appending at end\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 1 | push @$nodes_array, @$new_nodes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | sub insert_nodes_before { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | ▶ | my ( $nodes_array, $before_title, $new_nodes, $ext_file ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
insert_nodes_before: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | for my $i ( 0 .. $#$nodes_array ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | my $node = $nodes_array->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | ▶ | my $title = ref($node) eq 'HASH' ? $node->{title} : $node; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | ▶ | next unless defined $title; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 0 | ▶ | if ( $title eq $before_title ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | splice @$nodes_array, $i, 0, @$new_nodes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | # Reference not found in the target: append at end (consistent with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | # insert_nodes_after). Prepending at position 0 would reorder | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | # unrelated, unrelated nodes and is almost never what the admin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | # meant when the sibling is simply missing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 0 | ▶ | warn "Warning" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | . ( $ext_file ? " [$ext_file]" : "" ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | . ": insert_before reference '$before_title' not found, appending at end\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 0 | push @$nodes_array, @$new_nodes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | sub merge_ctrees { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 1 | ▶ | my ( $core_ctrees, $ext_ctrees, $ext_file ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge_ctrees: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 1 | for my $ctree_name ( keys %$ext_ctrees ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 1 | my $spec = $ext_ctrees->{$ctree_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 1 | ▶ | my @specs = ref $spec eq 'ARRAY' ? @$spec : ($spec); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 1 | for my $s (@specs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 1 | apply_ctree_extension( $core_ctrees, $ctree_name, $s, $ext_file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | # Apply a single ctree extension - used by both merge_ctrees and the redefined cTrees function | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | sub apply_ctree_extension { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 1 | ▶ | my ( $core_ctrees, $ctree_name, $ext_spec, $ext_file ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply_ctree_extension: called CC=9 SCAR=29.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 1 | ▶ | unless ( exists $core_ctrees->{$ctree_name} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | # Create new ctree entry | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | ▶ | $core_ctrees->{$ctree_name} = $ext_spec->{nodes} || []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ext_spec->{'nodes'} || []
MC/DC0%0/1
$ext_spec->{'nodes'} || []
$ext_spec->{'nodes'}
Truth table0%0/2
A
A= $ext_spec->{'nodes'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | verbose " Created new ctree: $ctree_name\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 1 | my $nodes = $ext_spec->{nodes}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 1 | ▶ | unless ($nodes) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | warn | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | "Warning [$ext_file]: ctree '$ctree_name' extension requires 'nodes'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 1 | my $insert_into = $ext_spec->{insert_into}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 1 | my $insert_after = $ext_spec->{insert_after}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 1 | my $insert_before = $ext_spec->{insert_before}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | # Determine target array for insertion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 1 | my $target_array; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 1 | ▶ | if ($insert_into) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | # Navigate to nested node using path (e.g., "oidcRPMetaDataOptions/oidcRPMetaDataOptionsAdvanced") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 1 | my @path_parts = split '/', $insert_into; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | my $target = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 1 | find_tree_node( $core_ctrees->{$ctree_name}, \@path_parts ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 1 | ▶ | unless ($target) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | warn | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | "Warning [$ext_file]: Could not find ctree path: $ctree_name/$insert_into\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 1 | $target_array = $target->{nodes}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 1 | ▶ | unless ($target_array) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | warn | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | "Warning [$ext_file]: Target node '$insert_into' has no 'nodes' array\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 0 | $target_array = $core_ctrees->{$ctree_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 1 | ▶ | if ($insert_after) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 1 | insert_nodes_after( $target_array, $insert_after, $nodes, $ext_file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | elsif ($insert_before) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | insert_nodes_before( $target_array, $insert_before, $nodes, $ext_file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 0 | push @$target_array, @$nodes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 1 | verbose " Extended ctree: $ctree_name\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | sub merge_constants { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 1 | ▶ | my ( $core, $ext, $ext_file ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge_constants: called CC=5 SCAR=18.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 1 | for my $key ( keys %$ext ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 1 | ▶ | if ( exists $core->{$key} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | die | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | "Error [$ext_file]: Portal constant '$key' already exists with value $core->{$key}\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 1 | my $value = $ext->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 1 | ▶ | if ( $value >= 0 && $value < 200 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$value >= 0 and $value < 200
MC/DC0%0/2
$value >= 0 and $value < 200
$value >= 0
$value < 200
Truth table33%1/3
A and B
A= $value >= 0B= $value < 200
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | warn | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | "Warning [$ext_file]: Plugin constants should use values >= 200 (got $key => $value)\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 1 | $core->{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 1 | verbose " Added constant: $key => $value\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | sub update_language_files { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | ▶ | my ( $dir, $translations ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_language_files: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | # List all language files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | ▶ | opendir my $dh, $dir or die "Cannot open language directory $dir: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 0 | my @lang_files = grep { /\.json$/ } readdir $dh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 0 | closedir $dh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 0 | my $json = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | JSON->new->utf8->pretty->canonical->space_before(0)->space_after(0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 0 | for my $lang_file (@lang_files) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 0 | my $lang_path = "$dir/$lang_file"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | # Extract language code from filename (e.g., "fr.json" -> "fr") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 0 | my ($lang_code) = $lang_file =~ /^(.+)\.json$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | # Load existing translations | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 0 | my $content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | ▶ | open my $fh, '<', $lang_path or die "Cannot read $lang_path: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 0 | local $/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 0 | $content = <$fh>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | my $lang_data = $json->decode($content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | # Add new translations | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 0 | my $modified = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 0 | for my $key ( keys %$translations ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | my $trans = $translations->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | # Determine the text to use: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | # 1. Use the specific language if available | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | # 2. Fall back to English | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | # 3. Fall back to the first available language | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 0 | my $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | ▶ | if ( ref($trans) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | $text = $trans->{$lang_code} // $trans->{en} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | ▶ | // ( values %$trans )[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
($trans->{$lang_code} // $trans->{"en"}) // (values %$trans)[0]
$trans->{$lang_code} // $trans->{"en"}
MC/DC0%0/3
($trans->{$lang_code} // $trans->{"en"}) // (values %$trans)[0]
$trans->{$lang_code}
$trans->{"en"}
(values %$trans)[0]
Truth table0%0/4
A // B // C
A= $trans->{$lang_code}B= $trans->{"en"}C= (values %$trans)[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | # If trans is a scalar, use it directly (same for all languages) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 0 | $text = $trans; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 0 | ▶ | if ( defined $text ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | ▶ | if ( exists $lang_data->{$key} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | verbose " [$lang_code] Overriding existing key '$key'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | $lang_data->{$key} = $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | $modified = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | # Write back if modified | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 0 | ▶ | if ($modified) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | $content = $json->encode($lang_data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | # Compact format like addTrEntry | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 0 | $content =~ s/\n\s+/\n/sg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 0 | $content =~ s/\n*$//s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 0 | ▶ | open my $fh, '>', $lang_path or die "Cannot write $lang_path: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 0 | print $fh $content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 0 | verbose " Updated $lang_file\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | sub minify_conftree { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 0 | ▶ | my ($conftree_file) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
minify_conftree: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | # Get directory and basename for proper source map paths | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 0 | my $dir = dirname($conftree_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 0 | my $basename = basename($conftree_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | my $min_basename = $basename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 0 | $min_basename =~ s/\.js$/.min.js/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | # If source and min are the same (shouldn't happen), skip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 0 | ▶ | if ( $min_basename eq $basename ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 0 | warn "Warning: Cannot determine minified filename for $conftree_file\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 0 | verbose "Minifying $conftree_file -> $dir/$min_basename\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | # Save current directory and change to target directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 0 | my $orig_dir = getcwd(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | ▶ | chdir $dir or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 0 | warn "Warning: Cannot chdir to $dir: $!\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 0 | my $success = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | # Prefer terser | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 0 | my $terser_version = `terser --version 2>/dev/null`; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 0 | ▶ | if ( $? == 0 && $terser_version ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$? == 0 and $terser_version
MC/DC0%0/2
$? == 0 and $terser_version
$? == 0
$terser_version
Truth table0%0/3
A and B
A= $? == 0B= $terser_version
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 0 | verbose " Using terser\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 0 | my @cmd = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 'terser', $basename, '--compress', '--mangle', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | '--comments', '/Copyr/i', '--source-map', '-o', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | $min_basename, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 0 | $success = ( system(@cmd) == 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | # Fall back to uglifyjs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | 0 | ▶ | if ( !$success ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | 0 | my $uglifyjs_version = `uglifyjs --version 2>/dev/null`; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 0 | ▶ | if ( $? == 0 && $uglifyjs_version ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$? == 0 and $uglifyjs_version
MC/DC0%0/2
$? == 0 and $uglifyjs_version
$? == 0
$uglifyjs_version
Truth table0%0/3
A and B
A= $? == 0B= $uglifyjs_version
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 0 | my ($major) = $uglifyjs_version =~ /^[^\d]*(\d)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 0 | ▶ | $major //= 3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$major //= 3
MC/DC0%0/1
$major //= 3
$major
Truth table0%0/2
A
A= $major
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | 0 | my @cmd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | 0 | ▶ | if ( $major == 2 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | 0 | @cmd = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 'uglifyjs', $basename, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | '--compress', '--mangle', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | '--comments', '/Copyr/i', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | '--source-map', "$min_basename.map", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | '-o', $min_basename, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 0 | @cmd = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | 'uglifyjs', $basename, '--compress', '--mangle', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | '--comments', '/Copyr/i', '--source-map', '-o', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | $min_basename, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 0 | verbose " Using uglifyjs (version $major)\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 0 | $success = ( system(@cmd) == 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | # No minifier available or all failed, just copy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 0 | ▶ | if ( !$success ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 0 | verbose " No minifier available, copying file\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | 0 | copy_file( $basename, $min_basename ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | # Restore original directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | 0 | ▶ | chdir $orig_dir or warn "Warning: Cannot chdir back to $orig_dir: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | sub copy_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 0 | ▶ | my ( $src, $dst ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
copy_file: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 0 | ▶ | open my $in, '<', $src or die "Cannot open $src: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | 0 | ▶ | open my $out, '>', $dst or die "Cannot open $dst: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 0 | ▶ | while (<$in>) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 0 | print $out $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 0 | close $in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 0 | close $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||