| 1 | # | ||||||||||||||||||||||||||||
| 2 | # This file is part of Config-Model | ||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||
| 4 | # This software is Copyright (c) 2005-2022 by Dominique Dumont. | ||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||
| 6 | # This is free software, licensed under: | ||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||
| 8 | # The GNU Lesser General Public License, Version 2.1, February 1999 | ||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||
| 10 | package Config::Model::Report 2.169; | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 59 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 59 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 59 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 59 | ▶ | use Config::Model::Exception; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 59 | ▶ | use Config::Model::ObjTreeScanner; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 59 | ▶ | use Text::Wrap; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 59 | ▶ | use feature qw/postderef signatures/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 59 | ▶ | no warnings qw/experimental::postderef experimental::signatures/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 24 | 2 | return bless {}, shift; | |||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 2 | ▶ | sub report ($self, %args) { | ||||||||||||||||||||||||||
|
Subroutine
report: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 28 | 2 | ▶ | my $audit = delete $args{audit} || 0; | ||||||||||||||||||||||||||
|
Condition100%2/2
delete $args{'audit'} || 0
MC/DC100%1/1
delete $args{'audit'} || 0
delete $args{'audit'}
Truth table100%2/2
A
A= delete $args{'audit'}
| |||||||||||||||||||||||||||||
| 29 | my $node = delete $args{node} | ||||||||||||||||||||||||||||
| 30 | 2 | ▶ | || croak "dump_tree: missing 'node' parameter"; | ||||||||||||||||||||||||||
|
Condition50%1/2
delete $args{'node'} || croak(q[dump_tree: missing 'node' parameter])
MC/DC0%0/1
delete $args{'node'} || croak(q[dump_tree: missing 'node' parameter])
delete $args{'node'}
Truth table50%1/2
A
A= delete $args{'node'}
| |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 142 | ▶ | my $std_cb = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=11 SCAR=24.0
| |||||||||||||||||||||||||||||
| 33 | 142 | my ( $scanner, $data_r, $obj, $element, $index, $value_obj ) = @_; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | # if element is a collection, get the value pointed by $index | ||||||||||||||||||||||||||||
| 36 | 142 | ▶ | $value_obj = $obj->fetch_element($element)->fetch_with_id($index) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | if defined $index; | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | # get value or only customized value | ||||||||||||||||||||||||||||
| 40 | 142 | ▶ | my $value = $audit ? $value_obj->fetch_custom : $value_obj->fetch; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 142 | ▶ | $value = '"' . $value . '"' if defined $value and $value =~ /\s/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $value and $value =~ /\s/
MC/DC100%2/2
defined $value and $value =~ /\s/
defined $value
$value =~ /\s/
Truth table100%3/3
A and B
A= defined $valueB= $value =~ /\s/
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 142 | ▶ | if ( defined $value ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 41 | ▶ | my $name = defined $index ? " $element:$index" : $element; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | 41 | push @$data_r, $obj->location . " $name = $value"; | |||||||||||||||||||||||||||
| 47 | 41 | my $desc = $obj->get_help_as_text($element); | |||||||||||||||||||||||||||
| 48 | 41 | ▶ | if ( defined $desc and $desc ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $desc and $desc
MC/DC50%1/2
defined $desc and $desc
defined $desc
$desc
Truth table66%2/3
A and B
A= defined $descB= $desc
| |||||||||||||||||||||||||||||
| 49 | 2 | push @$data_r, wrap( "\t", "\t\t", "DESCRIPTION: $desc" ); | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | 41 | my $effect = $value_obj->get_help_as_text($value); | |||||||||||||||||||||||||||
| 52 | 41 | ▶ | if ( defined $effect and $effect ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $effect and $effect
MC/DC50%1/2
defined $effect and $effect
defined $effect
$effect
Truth table66%2/3
A and B
A= defined $effectB= $effect
| |||||||||||||||||||||||||||||
| 53 | 2 | push @$data_r, wrap( "\t", "\t\t", "SELECTED: $effect" ); | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | 41 | push @$data_r, ''; # to get empty line in report | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | 142 | return; | |||||||||||||||||||||||||||
| 58 | 2 | }; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 2 | my @scan_args = ( | |||||||||||||||||||||||||||
| 61 | auto_vivify => 0, | ||||||||||||||||||||||||||||
| 62 | leaf_cb => $std_cb, | ||||||||||||||||||||||||||||
| 63 | ); | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 2 | my @left = keys %args; | |||||||||||||||||||||||||||
| 66 | 2 | ▶ | croak "Report: unknown parameter:@left" if @left; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | # perform the scan | ||||||||||||||||||||||||||||
| 69 | 2 | my $view_scanner = Config::Model::ObjTreeScanner->new(@scan_args); | |||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 2 | my @ret; | |||||||||||||||||||||||||||
| 72 | 2 | $view_scanner->scan_node( \@ret, $node ); | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 2 | return join( "\n", @ret ); | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 59 | 1; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | # ABSTRACT: Reports data from config tree | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | __END__ | ||||||||||||||||||||||||||||