| 1 | package YAOO; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 7 | ▶ | use strict; no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 7 | ▶ | use Carp qw/croak/; use Tie::IxHash; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use feature qw/state/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 7 | ▶ | use Blessed::Merge; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 7 | ▶ | use Hash::Typed; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 7 | our $VERSION = '0.09'; | |||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 7 | our (%TYPES, %object, $LAST); | |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | sub make_keyword { | ||||||||||||||||||||||||||||||||||||||||||
| 13 | 379 | ▶ | my ($called, $key, $cb) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_keyword: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 379 | *{"${called}::$key"} = $cb; | |||||||||||||||||||||||||||||||||||||||||
| 15 | 379 | $LAST = 10000000000000000000; | |||||||||||||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | sub import { | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 11 | ▶ | my ($package, @attributes) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 11 | my $called = caller(); | |||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 11 | strict->import(); | |||||||||||||||||||||||||||||||||||||||||
| 24 | 11 | warnings->import(); | |||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 11 | for my $is (qw/ro rw/) { | |||||||||||||||||||||||||||||||||||||||||
| 27 | 22 | ▶ | make_keyword($called, $is, sub { is => $is }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 11 | for my $key (qw/isa default coerce required trigger lazy delay build_order/) { | |||||||||||||||||||||||||||||||||||||||||
| 31 | make_keyword($called, $key, sub { | ||||||||||||||||||||||||||||||||||||||||||
| 32 | 32 | ▶ | my (@value) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 32 | ▶ | return $key => scalar @value > 1 ? @value : ($value[0] || 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$value[0] or 1
MC/DC100%1/1
$value[0] or 1
$value[0]
Truth table100%2/2
A
A= $value[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 88 | }); | |||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 11 | for my $isa ( qw/any string scalarref integer float boolean ordered_hash hash array object fh/ ) { | |||||||||||||||||||||||||||||||||||||||||
| 38 | make_keyword($called, $isa, sub { | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 27 | ▶ | my (@args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | my @return = ( | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 27 | \&{"${package}::${isa}"}, | |||||||||||||||||||||||||||||||||||||||||
| 42 | type => $isa, | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 27 | build_default => \&{"${package}::build_${isa}"} | |||||||||||||||||||||||||||||||||||||||||
| 44 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 27 | ▶ | push @return, (default => ($isa eq 'ordered_hash' ? sub { deep_clone_ordered_hash(@args) } : sub { deep_clone( scalar @args > 1 ? $isa eq 'hash' ? {@args} : \@args : @args) })) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | if (scalar @args); | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 27 | @return; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 121 | }); | |||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | make_keyword($called, 'typed_hash', sub { | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 3 | ▶ | my (@args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 3 | my $spec = shift @args; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 3 | ▶ | if (! scalar $spec) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | die 'Invalid declaration of a typed_hash no Hash::Typed spec passed' | |||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 3 | ▶ | if (caller(1)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | return Hash::Typed->new( | ||||||||||||||||||||||||||||||||||||||||||
| 59 | deep_clone($spec), | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 2 | %{ deep_clone_ordered_hash(@args) } | |||||||||||||||||||||||||||||||||||||||||
| 61 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | my @return = ( | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | \&{"${package}::typed_hash"}, | |||||||||||||||||||||||||||||||||||||||||
| 65 | type => 'typed_hash', | ||||||||||||||||||||||||||||||||||||||||||
| 66 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 67 | push @return, default => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 68 | Hash::Typed->new( | ||||||||||||||||||||||||||||||||||||||||||
| 69 | deep_clone($spec), | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 1 | ▶ | %{ deep_clone_ordered_hash(@args) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 73 | @return | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 11 | }); | |||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 11 | ▶ | make_keyword($called, 'auto_build', sub { $object{$called}{auto_build} = 1; }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | make_keyword($called, 'extends', sub { | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 4 | ▶ | my (@args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 4 | my $extend = caller(); | |||||||||||||||||||||||||||||||||||||||||
| 82 | 4 | for my $inherit (@args) { | |||||||||||||||||||||||||||||||||||||||||
| 83 | 4 | load($inherit); | |||||||||||||||||||||||||||||||||||||||||
| 84 | 4 | push @{*{\*{"${extend}::ISA"}}{ARRAY}}, $inherit; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 4 | ▶ | return unless $object{$inherit}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 4 | my $bm = Blessed::Merge->new(blessed => 0, same => 0); | |||||||||||||||||||||||||||||||||||||||||
| 87 | 4 | $object{$extend} = $bm->merge($object{$extend}, $object{$inherit}); | |||||||||||||||||||||||||||||||||||||||||
| 88 | 4 | for my $name (keys %{$object{$extend}{has}}) { | |||||||||||||||||||||||||||||||||||||||||
| 89 | make_keyword($extend, $name, sub { | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 17 | ▶ | my ($self, $value) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=19.9
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 17 | ▶ | if ($value && ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$value and $YAOO::object{$extend}{"has"}{$name}{"is"} eq "rw" || [split(/::/, [caller 1]->[3], 0)]->[-1] =~ /^new|build|set_defaults|auto_build$/
$YAOO::object{$extend}{"has"}{$name}{"is"} eq "rw" or [split(/::/, [caller 1]->[3], 0)]->[-1] =~ /^new|build|set_defaults|auto_build$/
MC/DC33%1/3
$value and $YAOO::object{$extend}{"has"}{$name}{"is"} eq "rw" || [split(/::/, [caller 1]->[3], 0)]->[-1] =~ /^new|build|set_defaults|auto_build$/
$value
$YAOO::object{$extend}{"has"}{$name}{"is"} eq "rw"
[split(/::/, [caller 1]->[3], 0)]->[-1] =~ /^new|build|set_defaults|auto_build$/
Truth table50%2/4
A and B or C
A= $valueB= $YAOO::object{$extend}{"has"}{$name}{"is"} eq "rw"C= [split(/::/, [caller 1]->[3], 0)]->[-1] =~ /^new|build|set_defaults|auto_build$/
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | $object{$extend}{has}{$name}->{is} eq 'rw' | ||||||||||||||||||||||||||||||||||||||||||
| 93 | || [split '::', [caller(1)]->[3]]->[-1] =~ m/^new|build|set_defaults|auto_build$/ | ||||||||||||||||||||||||||||||||||||||||||
| 94 | )) { | ||||||||||||||||||||||||||||||||||||||||||
| 95 | $value = $object{$extend}{has}{$name}->{coerce}($self, $value, $name) | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 13 | ▶ | if ($object{$extend}{has}{$name}->{coerce}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | $object{$extend}{has}{$name}->{required}($self, $value, $name) | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 13 | ▶ | if ($object{$extend}{$name}->{required}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 13 | $value = $object{$extend}{has}{$name}->{isa}($value, $name, $called); | |||||||||||||||||||||||||||||||||||||||||
| 100 | 13 | $self->{$name} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 101 | $object{$extend}{has}{$name}->{trigger}($self, $value, $name) | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 13 | ▶ | if ($object{$extend}{has}{$name}->{trigger}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 17 | $self->{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 16 | }); | |||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 4 | for my $name (keys %{$object{$extend}{method}}) { | |||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | make_keyword($extend, $name, $object{$called}{method}{$name}); | |||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 11 | }); | |||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | make_keyword($called, 'require_has', sub { | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 2 | ▶ | my (@args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 2 | push @{ $object{$called}{require_has} }, @args; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 11 | }); | |||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | make_keyword($called, 'require_sub', sub { | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | ▶ | my (@args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | push @{ $object{$called}{require_sub} }, @args; | |||||||||||||||||||||||||||||||||||||||||
| 121 | 11 | }); | |||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | make_keyword($called, 'require_method', sub { | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | my (@args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | push @{ $object{$called}{require_sub} }, @args; | |||||||||||||||||||||||||||||||||||||||||
| 126 | 11 | }); | |||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 11 | $object{$called}{has} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 11 | $object{$called}{method} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | make_keyword($called, "method", sub { | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 1 | ▶ | my ($name, $sub) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 1 | $object{$called}{method}{$name} = $sub; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 1 | make_keyword($called, $name, $sub); | |||||||||||||||||||||||||||||||||||||||||
| 136 | 11 | }); | |||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 11 | ▶ | make_keyword($called, 'has', sub { build_attribute($called, @_) }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | make_keyword($called, "new", sub { | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 13 | ▶ | my ($pkg) = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 13 | my $self = bless { }, $pkg; | |||||||||||||||||||||||||||||||||||||||||
| 143 | 13 | require_has($called); | |||||||||||||||||||||||||||||||||||||||||
| 144 | 12 | require_sub($self, $called); | |||||||||||||||||||||||||||||||||||||||||
| 145 | 12 | require_method($called); | |||||||||||||||||||||||||||||||||||||||||
| 146 | 12 | ▶ | auto_ld($self, $called, 'lazy') if ($object{$called}{lazy}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 12 | set_defaults($self, $called); | |||||||||||||||||||||||||||||||||||||||||
| 148 | 12 | ▶ | auto_build($self, $called, @_) if ($object{$called}{auto_build}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 12 | ▶ | $self->build(@_) if ($self->can('build')); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | 12 | ▶ | auto_ld($self, $called, 'delay') if ($object{$called}{delay}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 12 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 152 | 11 | }); | |||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | sub build_attribute { | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 32 | ▶ | my ($called, $name, @attrs) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_attribute: called CC=20 SCAR=31.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 32 | ▶ | my $ref = ref $name || 'STRING'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
ref $name || 'STRING'
MC/DC100%1/1
ref $name || 'STRING'
ref $name
Truth table100%2/2
A
A= ref $name
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | 32 | my $attribute_extend; | |||||||||||||||||||||||||||||||||||||||||
| 161 | 32 | ▶ | if ($name =~ s/^_([a-zA-Z].*)/$1/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | $attribute_extend = 1; | |||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 32 | ▶ | if ($ref eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | build_attribute($called, $_, @attrs) for @{ $name }; | |||||||||||||||||||||||||||||||||||||||||
| 167 | } elsif ($ref eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||
| 168 | 1 | build_attribute($called, $_, %{ $name->{$_} }) for keys %{ $name }; | |||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | 32 | ▶ | if ( !$attribute_extend && $object{$called}{has}{$name} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $attribute_extend and $YAOO::object{$called}{"has"}{$name}
MC/DC0%0/2
not $attribute_extend and $YAOO::object{$called}{"has"}{$name}
not $attribute_extend
$YAOO::object{$called}{"has"}{$name}
Truth table33%1/3
not(A) and B
A= not $attribute_extendB= $YAOO::object{$called}{"has"}{$name}
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | croak sprintf "%s attribute already defined for %s object.", $name, $called; | |||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 32 | ▶ | if ( scalar @attrs % 2 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | croak sprintf "Invalid attribute definition odd number of key/value pairs (%s) passed with %s in %s object", scalar @attrs, $name, $called; | |||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 32 | $object{$called}{has}{$name} = {@attrs}; | |||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | $object{$called}{has}{$name}{is} = 'rw' | ||||||||||||||||||||||||||||||||||||||||||
| 182 | 32 | ▶ | if (! $object{$called}{has}{$name}{is}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | $object{$called}{has}{$name}{isa} = $TYPES{all} | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 32 | ▶ | if (not defined $object{$called}{has}{$name}{isa}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 32 | ▶ | if ($object{$called}{has}{$name}{default}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 14 | ▶ | if ($object{$called}{has}{$name}{default} =~ m/^1$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | $object{$called}{has}{$name}{value} = $object{$called}{has}{$name}{build_default}(); | |||||||||||||||||||||||||||||||||||||||||
| 190 | } elsif (ref $object{$called}{has}{$name}{default} eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||
| 191 | 14 | $object{$called}{has}{$name}{value} = $object{$called}{has}{$name}{default}(); | |||||||||||||||||||||||||||||||||||||||||
| 192 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 193 | $object{$called}{has}{$name}{value} = $object{$called}{has}{$name}{type} eq 'ordered_hash' | ||||||||||||||||||||||||||||||||||||||||||
| 194 | ? deep_clone_ordered_hash($object{$called}{has}{$name}{default}) | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | : deep_clone($object{$called}{has}{$name}{default}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 32 | ▶ | if ($object{$called}{has}{$name}{required}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | $object{$called}{has}{$name}{required} = \&required; | |||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | 32 | ▶ | if ($object{$called}{has}{$name}{lazy}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 4 | push @{$object{$called}{lazy}}, $name; | |||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 32 | ▶ | if ($object{$called}{has}{$name}{delay}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 1 | push @{$object{$called}{delay}}, $name; | |||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | make_keyword($called, $name, sub { | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 65 | ▶ | my ($self, $value) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 65 | ▶ | if (@_ > 1 && ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
@_ > 1 and $YAOO::object{$called}{"has"}{$name}{"is"} eq "rw" || [split(/::/, [caller 1]->[3], 0)]->[-1] =~ /^new|build|set_defaults|auto_build$/
$YAOO::object{$called}{"has"}{$name}{"is"} eq "rw" or [split(/::/, [caller 1]->[3], 0)]->[-1] =~ /^new|build|set_defaults|auto_build$/
MC/DC33%1/3
@_ > 1 and $YAOO::object{$called}{"has"}{$name}{"is"} eq "rw" || [split(/::/, [caller 1]->[3], 0)]->[-1] =~ /^new|build|set_defaults|auto_build$/
@_ > 1
$YAOO::object{$called}{"has"}{$name}{"is"} eq "rw"
[split(/::/, [caller 1]->[3], 0)]->[-1] =~ /^new|build|set_defaults|auto_build$/
Truth table50%2/4
A and B or C
A= @_ > 1B= $YAOO::object{$called}{"has"}{$name}{"is"} eq "rw"C= [split(/::/, [caller 1]->[3], 0)]->[-1] =~ /^new|build|set_defaults|auto_build$/
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | $object{$called}{has}{$name}->{is} eq 'rw' | ||||||||||||||||||||||||||||||||||||||||||
| 215 | || [split '::', [caller(1)]->[3]]->[-1] =~ m/^new|build|set_defaults|auto_build$/ | ||||||||||||||||||||||||||||||||||||||||||
| 216 | )) { | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 36 | ▶ | if (defined $value) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | $value = $object{$called}{has}{$name}->{coerce}($self, $value, $name) | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 35 | ▶ | if ($object{$called}{has}{$name}->{coerce}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | $object{$called}{has}{$name}{required}($self, $value, $name) | ||||||||||||||||||||||||||||||||||||||||||
| 221 | 35 | ▶ | if ($object{$called}{$name}->{required}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 35 | $value = $object{$called}{has}{$name}{isa}($value, $name, $called); | |||||||||||||||||||||||||||||||||||||||||
| 223 | 35 | $self->{$name} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 224 | $object{$called}{has}{$name}{trigger}($self, $value, $name) | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 35 | ▶ | if ($object{$called}{has}{$name}->{trigger}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 227 | 1 | $self->{$name} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 65 | $self->{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 32 | ▶ | }) unless $attribute_extend; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | sub require_has { | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 13 | ▶ | my ($called) = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
require_has: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 13 | for (@{ $object{$called}{require_has} }) { | |||||||||||||||||||||||||||||||||||||||||
| 237 | croak sprintf "The required %s attribute is not defined in the %s object.", $_, $called | ||||||||||||||||||||||||||||||||||||||||||
| 238 | 6 | ▶ | if (! $object{$called}{has}{$_} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | sub require_sub { | ||||||||||||||||||||||||||||||||||||||||||
| 243 | 12 | ▶ | my ($self, $called) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
require_sub: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | 12 | for (@{ $object{$called}{require_sub} }) { | |||||||||||||||||||||||||||||||||||||||||
| 245 | 1 | ▶ | croak sprintf "The required %s sub is not defined in the %s object.", $_, $called | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | if (! $self->can($_) ); | ||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | sub require_method { | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 12 | ▶ | my ($called) = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
require_method: called CC=3 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | 12 | for (@{ $object{$called}{require_method} }) { | |||||||||||||||||||||||||||||||||||||||||
| 253 | croak sprintf "The required %s method is not defined in the %s object.", $_, $called | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | if (! $object{$called}{method}{$_} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | sub set_defaults { | ||||||||||||||||||||||||||||||||||||||||||
| 259 | 12 | ▶ | my ($self, $called) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_defaults: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 261 | defined $object{$called}{has}{$_}{value} && $self->$_($object{$called}{has}{$_}{type} eq 'ordered_hash' | ||||||||||||||||||||||||||||||||||||||||||
| 262 | ? deep_clone_ordered_hash($object{$called}{has}{$_}{value}) | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 50 | ▶ | : deep_clone($object{$called}{has}{$_}{value})) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | 73 | ▶ | } sort { ($object{$called}{has}{$a}{build_order} || $LAST) <=> ($object{$called}{has}{$b}{build_order} || $LAST) } | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
$YAOO::object{$called}{'has'}{$a}{'build_order'} || $YAOO::LAST
$YAOO::object{$called}{'has'}{$b}{'build_order'} || $YAOO::LAST
MC/DC0%0/2
$YAOO::object{$called}{'has'}{$a}{'build_order'} || $YAOO::LAST
$YAOO::object{$called}{'has'}{$a}{'build_order'}
$YAOO::LAST
MC/DC0%0/2
$YAOO::object{$called}{'has'}{$b}{'build_order'} || $YAOO::LAST
$YAOO::object{$called}{'has'}{$b}{'build_order'}
$YAOO::LAST
Truth table66%2/3
A || B
A= $YAOO::object{$called}{'has'}{$a}{'build_order'}B= $YAOO::LAST
Truth table66%2/3
A || B
A= $YAOO::object{$called}{'has'}{$b}{'build_order'}B= $YAOO::LAST
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | 12 | keys %{$object{$called}{has}}; | |||||||||||||||||||||||||||||||||||||||||
| 266 | 12 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | sub auto_build { | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 12 | ▶ | my ($self, $called, %build) = (shift, shift, scalar @_ == 1 ? %{ $_[0] } : @_); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_build: called CC=5 SCAR=17.5
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 272 | 17 | ▶ | if ($self->can($_)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | 17 | $self->$_($build{$_}); | |||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 12 | ▶ | } sort { ($object{$called}{has}{$a}{build_order} || $LAST) <=> ($object{$called}{has}{$b}{build_order} || $LAST) } | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
$YAOO::object{$called}{'has'}{$a}{'build_order'} || $YAOO::LAST
$YAOO::object{$called}{'has'}{$b}{'build_order'} || $YAOO::LAST
MC/DC0%0/2
$YAOO::object{$called}{'has'}{$a}{'build_order'} || $YAOO::LAST
$YAOO::object{$called}{'has'}{$a}{'build_order'}
$YAOO::LAST
MC/DC0%0/2
$YAOO::object{$called}{'has'}{$b}{'build_order'} || $YAOO::LAST
$YAOO::object{$called}{'has'}{$b}{'build_order'}
$YAOO::LAST
Truth table66%2/3
A || B
A= $YAOO::object{$called}{'has'}{$a}{'build_order'}B= $YAOO::LAST
Truth table66%2/3
A || B
A= $YAOO::object{$called}{'has'}{$b}{'build_order'}B= $YAOO::LAST
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | keys %build; | ||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | sub auto_ld { | ||||||||||||||||||||||||||||||||||||||||||
| 280 | 2 | ▶ | my ($self, $called, $type) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_ld: called CC=5 SCAR=19.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 282 | 5 | ▶ | my $cb_value = ref $object{$called}{has}{$_}{$type} || $object{$called}{has}{$_}{$type} !~ m/^1$/ ? $object{$called}{has}{$_}{$type} : $object{$called}{has}{$_}{build_default}->(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $YAOO::object{$called}{"has"}{$_}{$type} or not $YAOO::object{$called}{"has"}{$_}{$type} =~ /^1$/
MC/DC0%0/2
ref $YAOO::object{$called}{"has"}{$_}{$type} or not $YAOO::object{$called}{"has"}{$_}{$type} =~ /^1$/
ref $YAOO::object{$called}{"has"}{$_}{$type}
not $YAOO::object{$called}{"has"}{$_}{$type} =~ /^1$/
Truth table33%1/3
A or not(B)
A= ref $YAOO::object{$called}{"has"}{$_}{$type}B= not $YAOO::object{$called}{"has"}{$_}{$type} =~ /^1$/
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 5 | $self->$_($cb_value); | |||||||||||||||||||||||||||||||||||||||||
| 284 | } sort { | ||||||||||||||||||||||||||||||||||||||||||
| 285 | 4 | ▶ | ($object{$called}{has}{$a}{build_order} || $LAST) <=> ($object{$called}{has}{$b}{build_order} || $LAST) | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$YAOO::object{$called}{'has'}{$a}{'build_order'} || $YAOO::LAST
$YAOO::object{$called}{'has'}{$b}{'build_order'} || $YAOO::LAST
MC/DC0%0/2
$YAOO::object{$called}{'has'}{$a}{'build_order'} || $YAOO::LAST
$YAOO::object{$called}{'has'}{$a}{'build_order'}
$YAOO::LAST
MC/DC0%0/2
$YAOO::object{$called}{'has'}{$b}{'build_order'} || $YAOO::LAST
$YAOO::object{$called}{'has'}{$b}{'build_order'}
$YAOO::LAST
Truth table33%1/3
A || B
A= $YAOO::object{$called}{'has'}{$a}{'build_order'}B= $YAOO::LAST
Truth table33%1/3
A || B
A= $YAOO::object{$called}{'has'}{$b}{'build_order'}B= $YAOO::LAST
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | 2 | } @{ $object{$called}{$type} }; | |||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | sub required { | ||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | my ($self, $value, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
required: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | if ( not defined $value ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | croak sprintf "No defined value passed to the required %s attribute.", | |||||||||||||||||||||||||||||||||||||||||
| 293 | $name; | ||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | sub any { $_[0] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
any: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | 1 | ▶ | sub build_string { "" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_string: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | sub string { | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 6 | ▶ | my ($value, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
string: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 6 | ▶ | if (ref $value) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | croak sprintf "The value passed to the %s attribute does not match the string type constraint.", | |||||||||||||||||||||||||||||||||||||||||
| 305 | $name; | ||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||
| 307 | 6 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | 4 | ▶ | sub build_integer { 0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_integer: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | sub integer { | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 12 | ▶ | my ($value, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
integer: called CC=3 SCAR=13.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 12 | ▶ | if (ref $value || $value !~ m/^\d+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $value or not $value =~ /^\d+$/
MC/DC0%0/2
ref $value or not $value =~ /^\d+$/
ref $value
not $value =~ /^\d+$/
Truth table33%1/3
A or not(B)
A= ref $valueB= not $value =~ /^\d+$/
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | croak sprintf "The value passed to the %s attribute does not match the type constraint.", | |||||||||||||||||||||||||||||||||||||||||
| 316 | $name; | ||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||
| 318 | 12 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | sub build_float { 0.00 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_float: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | sub float { | ||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | my ($value, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
float: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | if (ref $value || $value !~ m/^\d+\.\d+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $value or not $value =~ /^\d+\.\d+$/
MC/DC0%0/2
ref $value or not $value =~ /^\d+\.\d+$/
ref $value
not $value =~ /^\d+\.\d+$/
Truth table0%0/3
A or not(B)
A= ref $valueB= not $value =~ /^\d+\.\d+$/
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | croak sprintf "The value passed to the %s attribute does not match the float constraint.", | |||||||||||||||||||||||||||||||||||||||||
| 327 | $name; | ||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | sub build_scalarref { \"" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_scalarref: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||
| 334 | sub scalarref { | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | my ($value, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
scalarref: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | if (ref $value ne 'SCALAR' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | croak sprintf "The value passed to the %s attribute does not match the scalarref constraint.", | |||||||||||||||||||||||||||||||||||||||||
| 338 | $name; | ||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | sub build_boolean { \1 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_boolean: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | sub boolean { | ||||||||||||||||||||||||||||||||||||||||||
| 346 | 2 | ▶ | my ($value, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
boolean: called CC=3 SCAR=11.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | 2 | ▶ | if (! ref $value) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | 2 | $value = \!!$value; | |||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||
| 350 | 2 | ▶ | if (ref $value ne 'SCALAR' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | croak sprintf "The value passed to the %s attribute does not match the scalarref constraint.", | |||||||||||||||||||||||||||||||||||||||||
| 352 | $name; | ||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||
| 354 | 2 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | sub build_ordered_hash { { } } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_ordered_hash: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | 7 | ▶ | sub ordered_hash { hash(@_); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ordered_hash: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | sub typed_hash { | ||||||||||||||||||||||||||||||||||||||||||
| 362 | 6 | ▶ | my ($value, $name, $called) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
typed_hash: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | 6 | ▶ | if (ref $value ne 'Hash::Typed') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 365 | 4 | my $hash = $object{$called}{has}{$name}{value}; | |||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | 4 | ▶ | if (!$hash) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | croak sprintf "The value passed to the %s attribute does not match the typed_hash constraint.", | |||||||||||||||||||||||||||||||||||||||||
| 369 | $name; | ||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | 4 | set_typed_hash($hash, $value); | |||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | 4 | $value = $hash; | |||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | 6 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | sub set_typed_hash { | ||||||||||||||||||||||||||||||||||||||||||
| 381 | 5 | ▶ | my ($hash, $value) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_typed_hash: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | 5 | for my $k (keys %{$value}) { | |||||||||||||||||||||||||||||||||||||||||
| 384 | 13 | ▶ | if (ref $hash->{$k} eq 'Hash::Typed') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | 1 | $hash->{$k} = set_typed_hash($hash->{$k}, $value->{$k}); | |||||||||||||||||||||||||||||||||||||||||
| 386 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 387 | 12 | $hash->{$k} = $value->{$k}; | |||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | 5 | for my $k (keys %{ $hash }) { | |||||||||||||||||||||||||||||||||||||||||
| 392 | 14 | ▶ | if (! exists $value->{$k}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | 1 | delete $hash->{$k}; | |||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | 5 | return $hash; | |||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | sub build_hash { {} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_hash: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | sub hash { | ||||||||||||||||||||||||||||||||||||||||||
| 404 | 15 | ▶ | my ($value, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hash: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 405 | 15 | ▶ | if (ref $value ne 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | croak sprintf "The value passed to the %s attribute does not match the hash type constraint.", | |||||||||||||||||||||||||||||||||||||||||
| 407 | $name; | ||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||
| 409 | 15 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | sub build_array { [] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_array: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | sub array { | ||||||||||||||||||||||||||||||||||||||||||
| 415 | 7 | ▶ | my ($value, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
array: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 416 | 7 | ▶ | if (ref $value ne 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | croak sprintf "The value passed to the %s attribute does not match the array type constraint.", | |||||||||||||||||||||||||||||||||||||||||
| 418 | $name; | ||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||
| 420 | 7 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | sub fh { | ||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | my ($value, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fh: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | ▶ | if (ref $value ne 'GLOB') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | croak sprintf "The value passed to the %s attribute does not match the glob type constraint.", | |||||||||||||||||||||||||||||||||||||||||
| 427 | $name; | ||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | sub build_object { { } } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_object: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||
| 434 | sub object { | ||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | my ($value, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
object: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | if ( ! ref $value || ref $value !~ m/SCALAR|ARRAY|HASH|GLOB/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not ref $value or ref !($value =~ /SCALAR|ARRAY|HASH|GLOB/)
MC/DC0%0/2
not ref $value or ref !($value =~ /SCALAR|ARRAY|HASH|GLOB/)
not ref $value
ref !($value =~ /SCALAR|ARRAY|HASH|GLOB/)
Truth table0%0/3
not(A) or not(B)
A= not ref $valueB= ref !($value =~ /SCALAR|ARRAY|HASH|GLOB/)
| |||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | croak sprintf "The value passed to the %s attribute does not match the object type constraint.", | |||||||||||||||||||||||||||||||||||||||||
| 438 | $name; | ||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | sub deep_clone { | ||||||||||||||||||||||||||||||||||||||||||
| 444 | 259 | ▶ | my ($data) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deep_clone: called CC=5 SCAR=16.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 445 | 259 | my $ref = ref $data; | |||||||||||||||||||||||||||||||||||||||||
| 446 | 259 | ▶ | if (!$ref) { return $data; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | elsif ($ref eq 'SCALAR') { my $r = deep_clone($$data); return \$r; } | |||||||||||||||||||||||||||||||||||||||||
| 448 | 29 | elsif ($ref eq 'ARRAY') { return [ map { deep_clone($_) } @{ $data } ]; } | |||||||||||||||||||||||||||||||||||||||||
| 449 | 49 | elsif ($ref eq 'HASH') { return { map +( $_ => deep_clone($data->{$_}) ), keys %{ $data } }; } | |||||||||||||||||||||||||||||||||||||||||
| 450 | 7 | return $data; | |||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | sub deep_clone_ordered_hash { | ||||||||||||||||||||||||||||||||||||||||||
| 454 | 14 | ▶ | my (@hash) = scalar @_ == 1 ? %{ $_[0] } : @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deep_clone_ordered_hash: called CC=3 SCAR=11.0
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 455 | 14 | my %hash = (); | |||||||||||||||||||||||||||||||||||||||||
| 456 | 14 | tie(%hash, 'Tie::IxHash'); | |||||||||||||||||||||||||||||||||||||||||
| 457 | 14 | ▶ | while (@hash) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 458 | 39 | my ($key, $value) = (shift @hash, shift @hash); | |||||||||||||||||||||||||||||||||||||||||
| 459 | 39 | $hash{$key} = deep_clone($value) | |||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||||
| 461 | 14 | return \%hash; | |||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | sub load { | ||||||||||||||||||||||||||||||||||||||||||
| 465 | 4 | ▶ | my ($module) = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 466 | 4 | $module =~ s/\:\:/\//g; | |||||||||||||||||||||||||||||||||||||||||
| 467 | 4 | require $module . '.pm'; | |||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | 7 | 1 | |||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | __END__ | ||||||||||||||||||||||||||||||||||||||||||