| 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 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | package Config::Model::Describe 2.169; | ||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 59 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 59 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 59 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 59 | ▶ | use Config::Model::Exception; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 59 | ▶ | use Config::Model::ObjTreeScanner; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 59 | ▶ | use List::Util qw/max/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 59 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 59 | ▶ | use feature qw/postderef signatures/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 59 | ▶ | no warnings qw/experimental::postderef experimental::signatures/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 9 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 9 | return bless {}, shift; | |||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 9 | ▶ | sub describe ($self, %args) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe: called CC=11 SCAR=24.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | my $desc_node = delete $args{node} | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 9 | ▶ | || croak "describe: missing 'node' parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $args{'node'} || croak(q[describe: missing 'node' parameter])
MC/DC0%0/1
delete $args{'node'} || croak(q[describe: missing 'node' parameter])
delete $args{'node'}
Truth table50%1/2
A
A= delete $args{'node'}
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 9 | ▶ | my $check = delete $args{check} || 'yes'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $args{'check'} || 'yes'
MC/DC100%1/1
delete $args{'check'} || 'yes'
delete $args{'check'}
Truth table100%2/2
A
A= delete $args{'check'}
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 9 | my $element = delete $args{element} ; # optional | |||||||||||||||||||||||||||||||||||||||||
| 35 | 9 | my $pattern = delete $args{pattern} ; # optional | |||||||||||||||||||||||||||||||||||||||||
| 36 | 9 | ▶ | my $hide_empty = delete $args{hide_empty} // 0 ; # optional | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $args{"hide_empty"} // 0
MC/DC100%1/1
delete $args{"hide_empty"} // 0
delete $args{"hide_empty"}
Truth table100%2/2
A
A= delete $args{"hide_empty"}
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 9 | ▶ | my $verbose = delete $args{verbose} // 0 ; # optional | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $args{"verbose"} // 0
MC/DC100%1/1
delete $args{"verbose"} // 0
delete $args{"verbose"}
Truth table100%2/2
A
A= delete $args{"verbose"}
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 9 | my $show_empty = ! $hide_empty ; | |||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 66 | ▶ | my $tag_name = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 66 | ▶ | $_[1] .= ' ⚠' if $_[0]->has_warning; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 66 | return; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 9 | }; | |||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 8 | ▶ | my $my_content_cb = sub ($scanner, $data_ref, $node, @element) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | # filter elements according to pattern | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 8 | ▶ | my @scan = $pattern ? grep { $_ =~ $pattern } @element : @element; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 8 | for (@scan) { $scanner->scan_element( $data_ref, $node, $_ ) } | |||||||||||||||||||||||||||||||||||||||||
| 50 | 8 | return; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 9 | }; | |||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 39 | ▶ | my $std_cb = sub ($scanner, $data_r, $obj, $element, $index, $value_obj) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=14 SCAR=26.4
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 39 | my $value = $value_obj->fetch( check => $check, mode => 'user' ); | |||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 39 | ▶ | return unless $show_empty or (defined $value and length($value)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$show_empty or defined $value and length $value
defined $value and length $value
MC/DC66%2/3
$show_empty or defined $value and length $value
$show_empty
defined $value
length $value
Truth table75%3/4
A or B and C
A= $show_emptyB= defined $valueC= length $value
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 34 | ▶ | $value = substr($value,0,12).'[…]' if $value and length($value) > 12; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$value and length $value > 12
MC/DC100%2/2
$value and length $value > 12
$value
length $value > 12
Truth table100%3/3
A and B
A= $valueB= length $value > 12
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 34 | ▶ | $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/
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 34 | ▶ | my $name = defined $index ? "$element:$index" : $element; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 34 | ▶ | $value = defined $value ? $value : '[undef]'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 34 | my $type = $value_obj->value_type; | |||||||||||||||||||||||||||||||||||||||||
| 66 | 34 | my @comment; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 34 | ▶ | if (my $default = $value_obj->fetch(mode => 'standard')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 18 | ▶ | my $defstr = $type =~ /uniline|string/ ? qq!"$default"! : $default; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 18 | push @comment, "default: $defstr"; | |||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 34 | ▶ | push @comment, "choice: " . join( ' ', @{ $value_obj->choice } ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | if $type eq 'enum'; | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 34 | ▶ | push @comment, 'mandatory' if $value_obj->mandatory; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 34 | $tag_name->($value_obj,$element); | |||||||||||||||||||||||||||||||||||||||||
| 76 | 34 | push @$data_r, [ $name, $type, $value, join( ', ', @comment ) ]; | |||||||||||||||||||||||||||||||||||||||||
| 77 | 34 | return; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 9 | }; | |||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 12 | ▶ | my $list_element_cb = sub ($scanner, $data_r, $obj, $element, @keys) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | #print "DEBUG: list_element_cb on $element, keys @keys\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 12 | my $list_obj = $obj->fetch_element($element); | |||||||||||||||||||||||||||||||||||||||||
| 83 | 12 | my $elt_type = $list_obj->cargo_type; | |||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 12 | $tag_name->($list_obj,$element); | |||||||||||||||||||||||||||||||||||||||||
| 86 | 12 | ▶ | if ( $elt_type eq 'node' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 3 | my $class_name = $list_obj->config_class_name; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 3 | ▶ | my @show_keys = @keys ? @keys : ('<empty>'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 3 | push @$data_r, [ $element, "<$class_name>", 'node list', "indexes: @show_keys" ]; | |||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 9 | ▶ | my @values = grep { $show_empty or length } $list_obj->fetch_all_values( check => 'no' ) ; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$show_empty || length $_
MC/DC0%0/2
$show_empty || length $_
$show_empty
length $_
Truth table66%2/3
A || B
A= $show_emptyB= length $_
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 9 | ▶ | push @$data_r, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$show_empty or @values
MC/DC100%2/2
$show_empty or @values
$show_empty
@values
Truth table100%3/3
A or B
A= $show_emptyB= @values
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | [ $element, 'list', join( ',', @values ), '' ] if ($show_empty or @values); | ||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 12 | return; | |||||||||||||||||||||||||||||||||||||||||
| 97 | 9 | }; | |||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 3 | ▶ | my $check_list_element_cb = sub ($scanner, $data_r, $obj, $element, @choices) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 3 | my $list_obj = $obj->fetch_element($element); | |||||||||||||||||||||||||||||||||||||||||
| 101 | 3 | $tag_name->($list_obj,$element); | |||||||||||||||||||||||||||||||||||||||||
| 102 | 3 | my @checked = $list_obj->get_checked_list; | |||||||||||||||||||||||||||||||||||||||||
| 103 | 3 | ▶ | push @$data_r, [ $element, 'check_list', join( ',', @checked ), '' ] if $show_empty or @checked; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$show_empty or @checked
MC/DC0%0/2
$show_empty or @checked
$show_empty
@checked
Truth table66%2/3
A or B
A= $show_emptyB= @checked
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 9 | }; | |||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 17 | ▶ | my $hash_element_cb = sub ($scanner, $data_r, $obj, $element, @keys) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | #print "DEBUG: hash_element_cb on $element, keys @keys\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 17 | my $hash_obj = $obj->fetch_element($element); | |||||||||||||||||||||||||||||||||||||||||
| 110 | 17 | my $elt_type = $hash_obj->cargo_type; | |||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 17 | $tag_name->($hash_obj,$element); | |||||||||||||||||||||||||||||||||||||||||
| 113 | 17 | ▶ | if ( $elt_type eq 'node' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 4 | my $class_name = $hash_obj->config_class_name; | |||||||||||||||||||||||||||||||||||||||||
| 115 | 4 | ▶ | my @show_keys = @keys ? map { qq("$_") } @keys : ('<empty>'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 4 | my $show_str = "keys: @show_keys"; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 4 | push @$data_r, [ $element, 'node hash', "<$class_name>", $show_str ]; | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | elsif (@keys) { | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 4 | for ( @keys ) { $scanner->scan_hash( $data_r, $obj, $element, $_ ) } | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 123 | 9 | ▶ | push @$data_r, [ $element, 'value hash', "[empty hash]", "" ] if $show_empty; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 17 | return; | |||||||||||||||||||||||||||||||||||||||||
| 126 | 9 | }; | |||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 6 | ▶ | my $node_element_cb = sub ($scanner, $data_r, $obj, $element, $key, $next) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | #print "DEBUG: elt_cb on $element, key $key\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 6 | my $type = $obj->element_type($element); | |||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 6 | my $class_name = $next->config_class_name; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 6 | push @$data_r, [ $element, 'node', "<$class_name>", $obj->gist ]; | |||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | #$ret .= ":$key" if $type eq 'list' or $type eq 'hash'; | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | #$view_scanner->scan_node($next); | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 6 | return; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 9 | }; | |||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 9 | my @scan_args = ( | |||||||||||||||||||||||||||||||||||||||||
| 142 | auto_vivify => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 143 | list_element_cb => $list_element_cb, | ||||||||||||||||||||||||||||||||||||||||||
| 144 | check_list_element_cb => $check_list_element_cb, | ||||||||||||||||||||||||||||||||||||||||||
| 145 | hash_element_cb => $hash_element_cb, | ||||||||||||||||||||||||||||||||||||||||||
| 146 | leaf_cb => $std_cb, | ||||||||||||||||||||||||||||||||||||||||||
| 147 | node_element_cb => $node_element_cb, | ||||||||||||||||||||||||||||||||||||||||||
| 148 | node_content_cb => $my_content_cb, | ||||||||||||||||||||||||||||||||||||||||||
| 149 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 9 | my @left = keys %args; | |||||||||||||||||||||||||||||||||||||||||
| 152 | 9 | ▶ | croak "Describe: unknown parameter:@left" if @left; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | # perform the scan | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 9 | my $view_scanner = Config::Model::ObjTreeScanner->new(@scan_args); | |||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 9 | my @ret; | |||||||||||||||||||||||||||||||||||||||||
| 158 | 9 | ▶ | if ( defined $element and $desc_node->has_element($element) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
defined $element and $desc_node->has_element($element)
MC/DC50%1/2
defined $element and $desc_node->has_element($element)
defined $element
$desc_node->has_element($element)
Truth table66%2/3
A and B
A= defined $elementB= $desc_node->has_element($element)
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 1 | $view_scanner->scan_element( \@ret, $desc_node, $element ); | |||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | elsif ( defined $element ) { | ||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | Config::Model::Exception::UnknownElement->throw( | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$desc_node->location || 'configuration root'
MC/DC0%0/1
$desc_node->location || 'configuration root'
$desc_node->location
Truth table0%0/2
A
A= $desc_node->location
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | object => $desc_node, | ||||||||||||||||||||||||||||||||||||||||||
| 164 | function => 'Describe', | ||||||||||||||||||||||||||||||||||||||||||
| 165 | where => $desc_node->location || 'configuration root', | ||||||||||||||||||||||||||||||||||||||||||
| 166 | element => $element, | ||||||||||||||||||||||||||||||||||||||||||
| 167 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 169 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 8 | $view_scanner->scan_node( \@ret, $desc_node ); | |||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 9 | my @header = qw/name type value/; | |||||||||||||||||||||||||||||||||||||||||
| 174 | 9 | my $name_length = max map { length($_->[0]) } (@ret, \@header ); | |||||||||||||||||||||||||||||||||||||||||
| 175 | 9 | my $type_length = max map { length($_->[1]) } (@ret, \@header ); | |||||||||||||||||||||||||||||||||||||||||
| 176 | 9 | my $value_length = max map { length($_->[2]) } (@ret, \@header ); | |||||||||||||||||||||||||||||||||||||||||
| 177 | 9 | my $sep_length = $name_length + $type_length + $value_length + 4 ; | |||||||||||||||||||||||||||||||||||||||||
| 178 | 9 | my @format = ("%-${name_length}s", "%-${type_length}s", "%-${value_length}s") ; | |||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 9 | my @show ; | |||||||||||||||||||||||||||||||||||||||||
| 181 | 9 | ▶ | if ($verbose) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 6 | push @format, "%-35s"; | |||||||||||||||||||||||||||||||||||||||||
| 183 | @show = ( | ||||||||||||||||||||||||||||||||||||||||||
| 184 | sprintf( join(" │ ", @format)."\n", qw/name type value comment/) , | ||||||||||||||||||||||||||||||||||||||||||
| 185 | sprintf( join("─┼─", @format)."\n", '─' x $name_length,'─' x $type_length,'─' x $value_length,'─' x 20, ) , | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 6 | map { sprintf( join(" │ ", @format)."\n", @$_ ) } @ret | |||||||||||||||||||||||||||||||||||||||||
| 187 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 190 | @show = ( | ||||||||||||||||||||||||||||||||||||||||||
| 191 | sprintf( join(" │ ", @format)."\n", qw/name type value/) , | ||||||||||||||||||||||||||||||||||||||||||
| 192 | sprintf( join("─┼─", @format)."\n", '─' x $name_length,'─' x $type_length,'─' x $value_length ) , | ||||||||||||||||||||||||||||||||||||||||||
| 193 | 3 | map { sprintf( join(" │ ", @format)."\n", @$_[0,1,2] ) } @ret | |||||||||||||||||||||||||||||||||||||||||
| 194 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 9 | return join ('', @show ); | |||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 59 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | # ABSTRACT: Provide a description of a node element | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | __END__ | ||||||||||||||||||||||||||||||||||||||||||