| 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::AnyThing 2.169; | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 59 | ▶ | use Mouse; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | # FIXME: must cleanup warp mechanism to implement this | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # use MouseX::StrictConstructor; | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 59 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 59 | ▶ | use Log::Log4perl qw(get_logger :levels); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 59 | ▶ | use v5.20; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 59 | ▶ | use feature qw/postderef signatures/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 59 | ▶ | no warnings qw/experimental::postderef experimental::signatures/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 59 | ▶ | use Storable qw(dclone); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 59 | my $logger = get_logger("Anything"); | |||||||||||||||||||||||||||||||||||||||||
| 27 | 59 | my $change_logger = get_logger("ChangeTracker"); | |||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 59 | has element_name => ( is => 'ro', isa => 'Str' ); | |||||||||||||||||||||||||||||||||||||||||
| 30 | 59 | has parent => ( is => 'ro', isa => 'Config::Model::Node', weak_ref => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 59 | has instance => ( | |||||||||||||||||||||||||||||||||||||||||
| 33 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 34 | isa => 'Config::Model::Instance', | ||||||||||||||||||||||||||||||||||||||||||
| 35 | weak_ref => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 36 | handles => [qw/show_message root_path/] | ||||||||||||||||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | # needs_check defaults to 1 to trap undef mandatory values | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 59 | has needs_check => ( is => 'rw', isa => 'Bool', default => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | # index_value can be written to when move method is called. But let's | ||||||||||||||||||||||||||||||||||||||||||
| 43 | # not advertise this feature. | ||||||||||||||||||||||||||||||||||||||||||
| 44 | has index_value => ( | ||||||||||||||||||||||||||||||||||||||||||
| 45 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 46 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 1145 | ▶ | trigger => sub ($self, @) { $self->{location} = $self->_location; }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 59 | ); | |||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 59 | has container => ( is => 'ro', isa => 'Ref', required => 1, weak_ref => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 59 | has container_type => ( is => 'ro', isa => 'Str', builder => '_container_type', lazy => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub _container_type ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_container_type: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my $p = $self->parent; | |||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | return defined $p | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | ? $p->element_type( $self->element_name ) | ||||||||||||||||||||||||||||||||||||||||||
| 58 | : 'node'; # root node | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 59 | has root => ( | |||||||||||||||||||||||||||||||||||||||||
| 63 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 64 | isa => 'Config::Model::Node', | ||||||||||||||||||||||||||||||||||||||||||
| 65 | weak_ref => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 66 | builder => '_root', | ||||||||||||||||||||||||||||||||||||||||||
| 67 | lazy => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 68 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 9 | ▶ | sub _root ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_root: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 9 | ▶ | return $self->parent || $self; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->parent || $self
MC/DC0%0/2
$self->parent || $self
$self->parent
$self
Truth table66%2/3
A || B
A= $self->parentB= $self
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 59 | has location => ( is => 'ro', isa => 'Str', builder => '_location', lazy => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 75 | 59 | has location_short => ( is => 'ro', isa => 'Str', builder => '_location_short', lazy => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 59 | has backend_support_annotation => ( | |||||||||||||||||||||||||||||||||||||||||
| 78 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 79 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||
| 80 | builder => '_backend_support_annotation', | ||||||||||||||||||||||||||||||||||||||||||
| 81 | lazy => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 82 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 1 | ▶ | sub _backend_support_annotation ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_backend_support_annotation: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | # this method is overridden in Config::Model::Node | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | return $self->parent->backend_support_annotation; | |||||||||||||||||||||||||||||||||||||||||
| 87 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 59 | has backup => ( | |||||||||||||||||||||||||||||||||||||||||
| 90 | is => 'bare', | ||||||||||||||||||||||||||||||||||||||||||
| 91 | isa => 'Maybe[HashRef]', | ||||||||||||||||||||||||||||||||||||||||||
| 92 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 5634 | ▶ | sub backup ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
backup: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 5634 | return dclone($self->{backup}); | |||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 4409 | ▶ | sub notify_change ($self, %args) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
notify_change: called CC=11 SCAR=24.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 4409 | ▶ | return if $self->instance->initial_load and not $args{really}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->instance->initial_load and not $args{"really"}
MC/DC0%0/2
$self->instance->initial_load and not $args{"really"}
$self->instance->initial_load
not $args{"really"}
Truth table66%2/3
A and not(B)
A= $self->instance->initial_loadB= not $args{"really"}
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 4409 | ▶ | if ($change_logger->is_trace) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 216 | ▶ | my @with = map { "'$_' -> '". ($args{$_} // '<undef>') ."'" } sort keys %args; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{$_} // "<undef>"
MC/DC100%1/1
$args{$_} // "<undef>"
$args{$_}
Truth table100%2/2
A
A= $args{$_}
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 216 | $change_logger->trace("called for ", $self->name, " from ", | |||||||||||||||||||||||||||||||||||||||||
| 106 | join( ' ', caller ), " with ", join( ' ', @with )); | ||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | # needs_save may be overridden by caller | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 4409 | ▶ | $args{needs_save} //= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"needs_save"} //= 1
MC/DC100%1/1
$args{"needs_save"} //= 1
$args{"needs_save"}
Truth table100%2/2
A
A= $args{"needs_save"}
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 4409 | ▶ | $args{path} //= $self->location; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$args{"path"} //= $self->location
MC/DC0%0/2
$args{"path"} //= $self->location
$args{"path"}
$self->location
Truth table66%2/3
A //= B
A= $args{"path"}B= $self->location
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 4409 | ▶ | $args{name} //= $self->element_name if $self->element_name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$args{"name"} //= $self->element_name
MC/DC0%0/2
$args{"name"} //= $self->element_name
$args{"name"}
$self->element_name
Truth table66%2/3
A //= B
A= $args{"name"}B= $self->element_name
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 4409 | ▶ | $args{index} //= $self->index_value if $self->index_value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$args{"index"} //= $self->index_value
MC/DC0%0/2
$args{"index"} //= $self->index_value
$args{"index"}
$self->index_value
Truth table66%2/3
A //= B
A= $args{"index"}B= $self->index_value
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | # better use %args instead of @_ to forward arguments. %args eliminates duplicated keys | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 4409 | $self->container->notify_change(%args); | |||||||||||||||||||||||||||||||||||||||||
| 117 | 4409 | return; | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 3254 | ▶ | sub _location ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_location: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 3254 | my $str = ''; | |||||||||||||||||||||||||||||||||||||||||
| 122 | 3254 | ▶ | $str .= $self->parent->location if defined $self->parent; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 3254 | ▶ | $str .= ' ' if $str; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 3254 | $str .= $self->composite_name; | |||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 3254 | return $str; | |||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 54 | ▶ | sub _location_short ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_location_short: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 54 | my $str = ''; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 54 | ▶ | $str .= $self->parent->location_short if defined $self->parent; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 54 | ▶ | $str .= ' ' if $str; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 54 | $str .= $self->composite_name_short; | |||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 54 | return $str; | |||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | #has composite_name => (is => 'ro', isa => 'Str' , builder => '_composite_name', lazy => 1); | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 3418 | ▶ | sub composite_name ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
composite_name: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 3418 | my $element = $self->element_name; | |||||||||||||||||||||||||||||||||||||||||
| 146 | 3418 | ▶ | $element = '' unless defined $element; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 3418 | my $idx = $self->index_value; | |||||||||||||||||||||||||||||||||||||||||
| 149 | 3418 | ▶ | return $element unless defined $idx; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | 1195 | ▶ | $idx = '"' . $idx . '"' if $idx =~ /\W/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 1195 | return "$element:$idx"; | |||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 54 | ▶ | sub composite_name_short ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
composite_name_short: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 54 | my $element = $self->element_name; | |||||||||||||||||||||||||||||||||||||||||
| 157 | 54 | ▶ | $element = '' unless defined $element; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 54 | my $idx = $self->shorten_idx($self->index_value); | |||||||||||||||||||||||||||||||||||||||||
| 160 | 54 | ▶ | return $element unless length $idx; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 1 | ▶ | $idx = '"' . $idx . '"' if $idx =~ /\W/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 1 | return "$element:$idx"; | |||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 61 | ▶ | sub shorten_idx ($self, $long_index) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shorten_idx: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 61 | ▶ | my @idx = split /\n/, $long_index // '' ; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$long_index // ""
MC/DC100%1/1
$long_index // ""
$long_index
Truth table100%2/2
A
A= $long_index
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 61 | my $idx = shift @idx; | |||||||||||||||||||||||||||||||||||||||||
| 168 | 61 | ▶ | $idx .= '[...]' if @idx; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 61 | ▶ | return $idx // ''; # may be undef on freebsd with perl 5.10.1 ... | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$idx // ""
MC/DC100%1/1
$idx // ""
$idx
Truth table100%2/2
A
A= $idx
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | ## Fixme: not yet tested | ||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | sub xpath ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xpath: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $logger->trace("xpath called on $self"); | |||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my $element = $self->element_name; | |||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | $element = '' unless defined $element; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | my $idx = $self->index_value; | |||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | my $str = ''; | |||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | $str .= $self->cim_parent->parent->xpath | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->can("cim_parent") and defined $self->cim_parent
MC/DC0%0/2
$self->can("cim_parent") and defined $self->cim_parent
$self->can("cim_parent")
defined $self->cim_parent
Truth table0%0/3
A and B
A= $self->can("cim_parent")B= defined $self->cim_parent
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | if $self->can('cim_parent') | ||||||||||||||||||||||||||||||||||||||||||
| 185 | and defined $self->cim_parent; | ||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | $str .= '/' . $element . ( defined $idx ? "[\@id=$idx]" : '' ) if $element; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | return $str; | |||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 7903 | ▶ | sub annotation ($self, @args) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
annotation: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 7903 | ▶ | my $old_note = $self->{annotation} || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'annotation'} || ''
MC/DC100%1/1
$self->{'annotation'} || ''
$self->{'annotation'}
Truth table100%2/2
A
A= $self->{'annotation'}
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | 7903 | ▶ | if (@args and not $self->instance->preset and not $self->instance->layered) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
@args and not $self->instance->preset and not $self->instance->layered
@args and not $self->instance->preset
MC/DC33%1/3
@args and not $self->instance->preset and not $self->instance->layered
@args
not $self->instance->preset
not $self->instance->layered
Truth table50%2/4
A and not(B) and not(C)
A= @argsB= not $self->instance->presetC= not $self->instance->layered
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 190 | my $new = $self->{annotation} = join( "\n", grep { defined $_} @args ); | |||||||||||||||||||||||||||||||||||||||||
| 196 | 190 | ▶ | $self->notify_change(note => 'updated annotation') unless $new eq $old_note; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 7903 | ▶ | return $self->{annotation} || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'annotation'} || ''
MC/DC100%1/1
$self->{'annotation'} || ''
$self->{'annotation'}
Truth table100%2/2
A
A= $self->{'annotation'}
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 1 | ▶ | sub clear_annotation ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_annotation: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 1 | ▶ | $self->notify_change(note => 'deleted annotation') if $self->{annotation}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | return $self->{annotation} = ''; | |||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | # fallback method for object that don't implement has_data | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | sub has_data ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_data: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | $logger->trace("called fall-back has_data for element", $self->name) if $logger->is_trace; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 8 | ▶ | sub model_searcher ($self, %args) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
model_searcher: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 8 | my $model = $self->instance->config_model; | |||||||||||||||||||||||||||||||||||||||||
| 215 | 8 | return Config::Model::SearchElement->new( model => $model, node => $self, %args ); | |||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | sub searcher { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
searcher: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | carp "Config::Model::AnyThing searcher is deprecated"; | |||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | goto &model_searcher; | |||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | 44 | ▶ | sub dump_as_data ($self, %args) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump_as_data: called CC=4 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | 44 | ▶ | my $full = delete $args{full_dump} || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $args{'full_dump'} || 0
MC/DC0%0/1
delete $args{'full_dump'} || 0
delete $args{'full_dump'}
Truth table50%1/2
A
A= delete $args{'full_dump'}
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 44 | ▶ | if ($full) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | carp "dump_as_data: full_dump parameter is deprecated. Please use 'mode => user' instead"; | |||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | $args{mode} //= 'user'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{"mode"} //= "user"
MC/DC0%0/1
$args{"mode"} //= "user"
$args{"mode"}
Truth table0%0/2
A
A= $args{"mode"}
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | 44 | my $dumper = Config::Model::DumpAsData->new; | |||||||||||||||||||||||||||||||||||||||||
| 230 | 44 | return $dumper->dump_as_data( node => $self, %args ); | |||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | # hum, check if the check information is valid | ||||||||||||||||||||||||||||||||||||||||||
| 234 | 44010 | ▶ | sub _check_check ($self, $p) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_check: called CC=7 SCAR=20.1
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 44010 | ▶ | return 'yes' if not defined $p or $p eq '1' or $p eq 'yes'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not defined $p or $p eq 1 or $p eq "yes"
not defined $p or $p eq 1
MC/DC66%2/3
not defined $p or $p eq 1 or $p eq "yes"
not defined $p
$p eq 1
$p eq "yes"
Truth table75%3/4
not(A) or B or C
A= not defined $pB= $p eq 1C= $p eq "yes"
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 6438 | ▶ | return 'no' if $p eq '0' or $p eq 'no'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$p eq 0 or $p eq "no"
MC/DC50%1/2
$p eq 0 or $p eq "no"
$p eq 0
$p eq "no"
Truth table66%2/3
A or B
A= $p eq 0B= $p eq "no"
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | 4693 | ▶ | return $p if $p eq 'skip'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | croak "Internal error: Unvalid check value: $p"; | |||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | sub has_fixes ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_fixes: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $logger->trace( "dummy has_fixes called on " . $self->name ); | |||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | 4 | ▶ | sub has_warning ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_warning: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 4 | $logger->trace( "dummy has_warning called on " . $self->name ); | |||||||||||||||||||||||||||||||||||||||||
| 249 | 4 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | 16 | ▶ | sub warp_error ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
warp_error: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 16 | ▶ | return '' unless defined $self->{warper}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | 7 | return $self->{warper}->warp_error; | |||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | # used by Value and AnyId | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 4 | ▶ | sub set_convert ($self, $arg_ref) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_convert: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | 4 | my $convert = delete $arg_ref->{convert}; | |||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | # convert_sub keeps a subroutine reference | ||||||||||||||||||||||||||||||||||||||||||
| 262 | $self->{convert_sub} = | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 2 | ▶ | $convert eq 'uc' ? sub ($input) { uc($input); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | 3 | ▶ | : $convert eq 'lc' ? sub ($input) { lc($input); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | 4 | ▶ | : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | Config::Model::Exception::Model->throw( | ||||||||||||||||||||||||||||||||||||||||||
| 268 | object => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 269 | error => "Unexpected convert value: $convert, " . "expected lc or uc" | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 4 | ▶ | ) unless defined $self->{convert_sub}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | 59 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | 59 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | # ABSTRACT: Base class for configuration tree item | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | __END__ | ||||||||||||||||||||||||||||||||||||||||||