| 1 | package Quaint; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use meta; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use Module::Runtime qw/use_module/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 5 | ▶ | use Types::Standard qw/Any Bool Str Int Num HashRef ArrayRef Object/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 5 | our $VERSION = '0.05'; | |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 9 | ▶ | sub import { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 9 | my ($caller) = caller(); | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 9 | my $metapkg; | |||||||||||||||||||||||||||||||||||||||||
| 16 | { | ||||||||||||||||||||||||||||||||||||||||||
| 17 | 5 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 9 | $metapkg = meta::get_package( $caller ); | |||||||||||||||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||||||||||||||||
| 20 | 9 | $metapkg->add_symbol( '%META', \my %META ); | |||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 9 | my $INDEX = 1; | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 5 | ▶ | $metapkg->add_named_sub('ro', sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ro: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 5 | my @ro; | |||||||||||||||||||||||||||||||||||||||||
| 26 | 5 | for (@_) { | |||||||||||||||||||||||||||||||||||||||||
| 27 | 7 | ▶ | if (ref $_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 5 | $_->{is} = 'ro'; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 5 | push @ro, $_; | |||||||||||||||||||||||||||||||||||||||||
| 30 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | $META{attribute}{$_} = { | |||||||||||||||||||||||||||||||||||||||||
| 32 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 33 | index => $INDEX++, | ||||||||||||||||||||||||||||||||||||||||||
| 34 | name => $_ | ||||||||||||||||||||||||||||||||||||||||||
| 35 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | push @ro, $META{attribute}{$_}; | |||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 5 | return @ro; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 9 | })->set_prototype('@'); | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | $metapkg->add_named_sub('req', sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=14.2
Subroutine
req: called CC=3 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my @req; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | for (@_) { | |||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | if (ref $_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $_->{required} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | push @req, $_; | |||||||||||||||||||||||||||||||||||||||||
| 48 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $META{attribute}{$_} = { | |||||||||||||||||||||||||||||||||||||||||
| 50 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 51 | index => $INDEX++, | ||||||||||||||||||||||||||||||||||||||||||
| 52 | name => $_ | ||||||||||||||||||||||||||||||||||||||||||
| 53 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | push @req, $META{attribute}{$_}; | |||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | return @req; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 9 | })->set_prototype('@'); | |||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 8 | ▶ | $metapkg->add_named_sub('default', sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 8 | my $default = shift; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 8 | my @def; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 8 | for (@_) { | |||||||||||||||||||||||||||||||||||||||||
| 64 | 10 | ▶ | if (ref $_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 2 | $_->{default} = $default; | |||||||||||||||||||||||||||||||||||||||||
| 66 | 2 | push @def, $_; | |||||||||||||||||||||||||||||||||||||||||
| 67 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 8 | $META{attribute}{$_} = { | |||||||||||||||||||||||||||||||||||||||||
| 69 | default => $default, | ||||||||||||||||||||||||||||||||||||||||||
| 70 | index => $INDEX++, | ||||||||||||||||||||||||||||||||||||||||||
| 71 | name => $_ | ||||||||||||||||||||||||||||||||||||||||||
| 72 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 8 | push @def, $META{attribute}{$_}; | |||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 8 | return @def; | |||||||||||||||||||||||||||||||||||||||||
| 77 | 9 | })->set_prototype('&@'); | |||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | ▶ | $metapkg->add_named_sub('trigger', sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trigger: called CC=3 SCAR=11.6
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | my $trigger = shift; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | my @tri; | |||||||||||||||||||||||||||||||||||||||||
| 82 | 1 | for (@_) { | |||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | ▶ | if (ref $_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $_->{trigger} = $trigger; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | push @tri, $_; | |||||||||||||||||||||||||||||||||||||||||
| 86 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | $META{attribute}{$_} = { | |||||||||||||||||||||||||||||||||||||||||
| 88 | trigger => $trigger, | ||||||||||||||||||||||||||||||||||||||||||
| 89 | index => $INDEX++, | ||||||||||||||||||||||||||||||||||||||||||
| 90 | name => $_ | ||||||||||||||||||||||||||||||||||||||||||
| 91 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | push @tri, $META{attribute}{$_}; | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | return @tri; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 9 | })->set_prototype('&@'); | |||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 2 | ▶ | $metapkg->add_named_sub('before', sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
before: called CC=5 SCAR=16.3
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 2 | my $function = shift; | |||||||||||||||||||||||||||||||||||||||||
| 100 | 2 | my @before; | |||||||||||||||||||||||||||||||||||||||||
| 101 | 2 | for (@_) { | |||||||||||||||||||||||||||||||||||||||||
| 102 | 2 | ▶ | if (ref $_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | push @{ $_->{before} }, $function; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | push @before, $_; | |||||||||||||||||||||||||||||||||||||||||
| 105 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 1 | ▶ | my $item = $META{attribute}{$_} || $META{function}{$_} || { name => $_, before => [] }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$META{'attribute'}{$_} || $META{'function'}{$_} || {'name', $_, 'before', []}
$META{"attribute"}{$_} or $META{"function"}{$_}
MC/DC0%0/2
$META{'attribute'}{$_} || $META{'function'}{$_} || {'name', $_, 'before', []}
$META{"attribute"}{$_}
$META{"function"}{$_}
Truth table33%1/3
A or B
A= $META{"attribute"}{$_}B= $META{"function"}{$_}
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 1 | push @{$item->{before}}, $function; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 1 | push @before, $item; | |||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 2 | return @before; | |||||||||||||||||||||||||||||||||||||||||
| 112 | 9 | })->set_prototype('&@'); | |||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 2 | ▶ | $metapkg->add_named_sub('around', sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=17.6
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 2 | my $function = shift; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 2 | my @around; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 2 | for (@_) { | |||||||||||||||||||||||||||||||||||||||||
| 118 | 2 | ▶ | if (ref $_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | push @{ $_->{around} }, $function; | |||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | push @around, $_; | |||||||||||||||||||||||||||||||||||||||||
| 121 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 2 | ▶ | my $item = $META{attribute}{$_} || $META{function}{$_} || { name => $_, around => [] }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
$META{'attribute'}{$_} || $META{'function'}{$_} || {'name', $_, 'around', []}
$META{"attribute"}{$_} or $META{"function"}{$_}
MC/DC0%0/2
$META{'attribute'}{$_} || $META{'function'}{$_} || {'name', $_, 'around', []}
$META{"attribute"}{$_}
$META{"function"}{$_}
Truth table66%2/3
A or B
A= $META{"attribute"}{$_}B= $META{"function"}{$_}
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 2 | push @{$item->{around}}, $function; | |||||||||||||||||||||||||||||||||||||||||
| 124 | 2 | push @around, $item; | |||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 2 | return @around; | |||||||||||||||||||||||||||||||||||||||||
| 128 | 9 | })->set_prototype('&@'); | |||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 2 | ▶ | $metapkg->add_named_sub('after', sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
after: called CC=5 SCAR=16.3
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 2 | my $function = shift; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 2 | my @after; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 2 | for (@_) { | |||||||||||||||||||||||||||||||||||||||||
| 134 | 2 | ▶ | if (ref $_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 1 | push @{ $_->{after} }, $function; | |||||||||||||||||||||||||||||||||||||||||
| 136 | 1 | push @after, $_; | |||||||||||||||||||||||||||||||||||||||||
| 137 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 1 | ▶ | my $item = $META{attribute}{$_} || $META{function}{$_} || { name => $_, after => [] }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$META{'attribute'}{$_} || $META{'function'}{$_} || {'name', $_, 'after', []}
$META{"attribute"}{$_} or $META{"function"}{$_}
MC/DC0%0/2
$META{'attribute'}{$_} || $META{'function'}{$_} || {'name', $_, 'after', []}
$META{"attribute"}{$_}
$META{"function"}{$_}
Truth table33%1/3
A or B
A= $META{"attribute"}{$_}B= $META{"function"}{$_}
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 1 | push @{$item->{after}}, $function; | |||||||||||||||||||||||||||||||||||||||||
| 140 | 1 | push @after, $item; | |||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 2 | return @after; | |||||||||||||||||||||||||||||||||||||||||
| 144 | 9 | })->set_prototype('&@'); | |||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 18 | ▶ | my $make_attribute = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 18 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||
| 149 | 18 | for (@_) { | |||||||||||||||||||||||||||||||||||||||||
| 150 | 22 | ▶ | if (ref $_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 17 | $_->{type} = $type; | |||||||||||||||||||||||||||||||||||||||||
| 152 | 17 | $metapkg->add_named_sub($_->{name}, attribute($_)); | |||||||||||||||||||||||||||||||||||||||||
| 153 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 5 | $META{attribute}{$_} = { name => $_, type => $type, index => $INDEX++ }; | |||||||||||||||||||||||||||||||||||||||||
| 155 | 5 | $metapkg->add_named_sub($_, attribute($META{attribute}{$_})); | |||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 158 | 9 | }; | |||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | 12 | ▶ | $metapkg->add_named_sub('any', sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 12 | $make_attribute->(Any, @_); | |||||||||||||||||||||||||||||||||||||||||
| 162 | 9 | })->set_prototype('@'); | |||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 1 | ▶ | $metapkg->add_named_sub('bool', sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 1 | $make_attribute->(Bool, @_); | |||||||||||||||||||||||||||||||||||||||||
| 166 | 9 | })->set_prototype('@'); | |||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 1 | ▶ | $metapkg->add_named_sub('str', sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
str: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 1 | $make_attribute->(Str, @_); | |||||||||||||||||||||||||||||||||||||||||
| 170 | 9 | })->set_prototype('@'); | |||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 1 | ▶ | $metapkg->add_named_sub('num', sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
num: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 1 | $make_attribute->(Num, @_); | |||||||||||||||||||||||||||||||||||||||||
| 174 | 9 | })->set_prototype('@'); | |||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | 1 | ▶ | $metapkg->add_named_sub('array', sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 1 | $make_attribute->(ArrayRef, @_); | |||||||||||||||||||||||||||||||||||||||||
| 178 | 9 | })->set_prototype('@'); | |||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 1 | ▶ | $metapkg->add_named_sub('hash', sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | $make_attribute->(HashRef, @_); | |||||||||||||||||||||||||||||||||||||||||
| 182 | 9 | })->set_prototype('@'); | |||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 1 | ▶ | $metapkg->add_named_sub('obj', sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | $make_attribute->(Object, @_); | |||||||||||||||||||||||||||||||||||||||||
| 186 | 9 | })->set_prototype('@'); | |||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 2 | ▶ | $metapkg->add_named_sub('function', sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 2 | my $function = shift; | |||||||||||||||||||||||||||||||||||||||||
| 190 | 2 | for (@_) { | |||||||||||||||||||||||||||||||||||||||||
| 191 | 2 | ▶ | if (ref $_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | $_->{function} = $function; | |||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | $metapkg->add_named_sub($_->{name}, function($_)); | |||||||||||||||||||||||||||||||||||||||||
| 194 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 2 | $META{function}{$_} = { name => $_, function => $function }; | |||||||||||||||||||||||||||||||||||||||||
| 196 | 2 | $metapkg->add_named_sub($_, function($META{function}{$_})); | |||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 9 | })->set_prototype('&@'); | |||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 4 | ▶ | $metapkg->add_named_sub('extends', sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extends: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 4 | for (@_) { | |||||||||||||||||||||||||||||||||||||||||
| 204 | 4 | eval { use_module($_); }; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 4 | my $extend; | |||||||||||||||||||||||||||||||||||||||||
| 206 | { | ||||||||||||||||||||||||||||||||||||||||||
| 207 | 5 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 4 | $extend = meta::get_package( $_ ); | |||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | 4 | my %local = $extend->get_symbol('%META')->value; | |||||||||||||||||||||||||||||||||||||||||
| 211 | 4 | my $isa = '@' . $caller . '::ISA'; | |||||||||||||||||||||||||||||||||||||||||
| 212 | 4 | eval "push $isa, '$_'"; | |||||||||||||||||||||||||||||||||||||||||
| 213 | 4 | for (sort { $local{attribute}{$a}{index} <=> $local{attribute}{$b}{index} } keys %{$local{attribute}}) { | |||||||||||||||||||||||||||||||||||||||||
| 214 | 18 | ▶ | if (!$META{attribute}{$_}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 18 | $META{attribute}{$_} = {%{$local{attribute}{$_}}}; | |||||||||||||||||||||||||||||||||||||||||
| 216 | 18 | $META{attribute}{$_}{index} = $INDEX++; | |||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 4 | for ( keys %{ $local{function} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 220 | 1 | ▶ | if (!$META{function}{$_}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 1 | $META{function}{$_} = {%{$local{function}{$_}}}; | |||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 9 | })->set_prototype('@'); | |||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | 10 | ▶ | $metapkg->add_named_sub('new', sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 10 | my $self = bless {}, shift; | |||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | my %params = scalar @_ == 1 ? %{$_[0]} : @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | 10 | my @sorted_keys = sort { $META{attribute}{$a}{index} <=> $META{attribute}{$b}{index} } keys %{$META{attribute}}; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 10 | $self->$_($META{attribute}{$_}{default}->($self)) for grep { $META{attribute}{$_}{default} } @sorted_keys; | |||||||||||||||||||||||||||||||||||||||||
| 232 | 10 | $self->$_($params{$_}) for keys %params; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 10 | $self->$_ for grep { $META{attribute}{$_}{required} } @sorted_keys; | |||||||||||||||||||||||||||||||||||||||||
| 234 | 8 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 235 | 9 | }); | |||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 22 | ▶ | sub attribute { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attribute: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 22 | my ($attr) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 240 | 128 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=12 SCAR=24.9
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 128 | $attr = scoped($_[0], 'attribute', $attr); | |||||||||||||||||||||||||||||||||||||||||
| 242 | 128 | ▶ | if (scalar @_ > 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 64 | ▶ | before($attr, @_) if ($attr->{before}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | 64 | ▶ | if ( $attr->{is} && $attr->{is} eq 'ro' && scalar caller() ne 'Quaint' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$attr->{"is"} and $attr->{"is"} eq "ro" and scalar caller() ne "Quaint"
$attr->{"is"} and $attr->{"is"} eq "ro"
MC/DC66%2/3
$attr->{"is"} and $attr->{"is"} eq "ro" and scalar caller() ne "Quaint"
$attr->{"is"}
$attr->{"is"} eq "ro"
scalar caller() ne "Quaint"
Truth table75%3/4
A and B and C
A= $attr->{"is"}B= $attr->{"is"} eq "ro"C= scalar caller() ne "Quaint"
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 2 | die "attribute $attr->{name} is readonly"; | |||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 247 | 62 | ▶ | my $val = $attr->{trigger} ? $attr->{trigger}->($_[0], $_[1]) : $_[1]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 62 | ▶ | ($val) = around($attr, $_[0], $val) if ($attr->{around}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | 62 | ▶ | $_[0]->{$attr->{name}} = $attr->{type} ? $attr->{type}->($val) : $val; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | 62 | ▶ | after($attr, $_[0], $_[0]->{$attr->{name}}) if ($attr->{after}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | 126 | ▶ | if ($attr->{required} && ! defined $_[0]->{$attr->{name}}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$attr->{"required"} and not defined $_[0]{$attr->{"name"}}
MC/DC100%2/2
$attr->{"required"} and not defined $_[0]{$attr->{"name"}}
$attr->{"required"}
not defined $_[0]{$attr->{"name"}}
Truth table100%3/3
A and not(B)
A= $attr->{"required"}B= not defined $_[0]{$attr->{"name"}}
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 2 | die "attribute $attr->{name} is required"; | |||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 255 | return $_[0]->{$attr->{name}} | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 124 | } | |||||||||||||||||||||||||||||||||||||||||
| 257 | 22 | } | |||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | 2 | ▶ | sub function { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
function: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | 2 | my ($attr) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 261 | 3 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | 3 | my ($self, @params) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 263 | 3 | $attr = scoped($self, 'function', $attr); | |||||||||||||||||||||||||||||||||||||||||
| 264 | 3 | ▶ | before($attr, $self, @params) if ($attr->{before}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | 3 | ▶ | @params = around($attr, $self, @params) if ($attr->{around}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | 3 | @params = $attr->{function}->($self, @params); | |||||||||||||||||||||||||||||||||||||||||
| 267 | 3 | ▶ | after($attr, $self, @params) if ($attr->{after}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 268 | 3 | ▶ | return wantarray ? @params : $params[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | 131 | ▶ | sub scoped { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
scoped: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | 131 | my ($self, $type, $attr) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 274 | 131 | my $extend; | |||||||||||||||||||||||||||||||||||||||||
| 275 | { | ||||||||||||||||||||||||||||||||||||||||||
| 276 | 5 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | 131 | $extend = meta::get_package( ref $self ); | |||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||
| 279 | 131 | my %local = $extend->get_symbol('%META')->value; | |||||||||||||||||||||||||||||||||||||||||
| 280 | 131 | return $local{$type}{$attr->{name}}; | |||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | 3 | ▶ | sub before { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
before: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 3 | my ($attr, @params) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 285 | 3 | for (@{$attr->{before}}) { | |||||||||||||||||||||||||||||||||||||||||
| 286 | 3 | $_->(@params); | |||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | 3 | ▶ | sub around { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
around: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | 3 | my ($attr, $self, @val) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 292 | 3 | for (@{$attr->{around}}) { | |||||||||||||||||||||||||||||||||||||||||
| 293 | 3 | @val = $_->($self, @val); | |||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||
| 295 | 3 | return @val; | |||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | 3 | ▶ | sub after { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
after: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | 3 | my ($attr, @params) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 300 | 3 | for (@{$attr->{after}}) { | |||||||||||||||||||||||||||||||||||||||||
| 301 | 3 | $_->(@params); | |||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | __END__ | ||||||||||||||||||||||||||||||||||||||||||