Zydeco/Lite.pm

filter: Statementstmt 74.8% 288 / 385 Branchbran 54.4% 110 / 202 Conditioncond 44.0% 59 / 134 MC/DCmcdc 17.2% 14 / 81 Subroutinesub 73.4% 47 / 64 Podpod 0.0% 0 / 30 totaltotal 57.8% 518 / 896 CC 157 SCAR 25.0
CC
157
Cov
63%
class
36.6
_method
26.1
requires
20.0
CRAP 12.2
« MooX/Press.pm ↑ Summary MooX/Press/Keywords.pm »
1 13 ▶use 5.008008;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Zydeco::Lite;
6  
7 13 our $AUTHORITY = 'cpan:TOBYINK';
8 13 our $VERSION = '0.086';
9  
10 13 ▶use MooX::Press ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 13 ▶use Types::Standard qw( -types -is );
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 13 ▶use Exporter::Shiny our @EXPORT = qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
14 app
15 class role abstract_class interface
16 generator
17 method factory constant
18 multi_method multi_factory
19 symmethod
20 before after around
21 extends with has requires
22 confess
23 true false
24 toolkit
25 coerce
26 overload
27 version authority
28 type_name
29 begin end before_apply after_apply
30 13 );
31  
32 13 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 13 our %THIS;
35  
36 238 ▶sub _shift_type ($\@) {
Subroutine _shift_type: called CC=3 SCAR=11.0
37 238 my ( $type, $ref ) = @_;
38 238 ▶ return shift @$ref if @$ref && $type->check( $ref->[0] );
Branch: 1 branch
BranchTrueFalseTotal
if @$ref and $type->check($ref->[0]) 186 52 238
Condition100%3/3
@$ref and $type->check($ref->[0])
!ll&&!rl&&r
511186
MC/DC100%2/2
@$ref and $type->check($ref->[0])
@$ref $type->check($ref->[0])
Truth table100%3/3
A and B
A= @$refB= $type->check($ref->[0])
ABresult
0X0
100
111
39 52 return undef;
40 }
41  
42 189 ▶sub _pop_type ($\@) {
Subroutine _pop_type: called CC=3 SCAR=11.0
43 189 my ( $type, $ref ) = @_;
44 189 ▶ return pop @$ref if @$ref && $type->check( $ref->[-1] );
Branch: 1 branch
BranchTrueFalseTotal
if @$ref and $type->check($ref->[-1]) 175 14 189
Condition100%3/3
@$ref and $type->check($ref->[-1])
!ll&&!rl&&r
113175
MC/DC100%2/2
@$ref and $type->check($ref->[-1])
@$ref $type->check($ref->[-1])
Truth table100%3/3
A and B
A= @$refB= $type->check($ref->[-1])
ABresult
0X0
100
111
45 14 return undef;
46 }
47  
48 {
49 13 my $app_count = 0;
50 11 ▶ sub _anon_package_name {
Subroutine _anon_package_name: called CC=1 SCAR=0.0
51 11 return sprintf( '%s::__ANON__::PKG%07d', __PACKAGE__, ++$app_count );
52 }
53 }
54  
55 13 ▶sub _return_anon {
Subroutine _return_anon: called CC=3 SCAR=17.3
56 11 my ( $kind, $nameref, $value ) = @_;
57
58 11 ▶ return $value if is_Undef $nameref;
Branch: 1 branch
BranchTrueFalseTotal
if is_Undef($nameref) 11 0 11
59
60 0 ▶ if ( not is_Undef $$nameref ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (is_Undef($$nameref)) 0 0 0
61 0 confess( '%s name expected to be string or reference to empty scalar variable', $kind );
62 }
63
64 0 $$nameref = $value;
65 0 &Internals::SvREADONLY($nameref, 1);
66 0 return;
67 }
68  
69 133 ▶sub _make_definition_context {
Subroutine _make_definition_context: called CC=6 SCAR=19.9
70 133 my ( $level, $coderef ) = @_;
71
72 133 ▶ $level = 1 unless defined $level;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $level 0 133 133
73 133 my ( $pkg, $file, $line ) = caller( $level );
74
75 133 ▶ if ( defined $coderef ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $coderef) 112 21 133
76 112 require B;
77 112 my $b = B::svref_2object($coderef);
78 return {
79 112 ▶ 'package' => $pkg,
Condition33%3/9
$b->FILE || $b->START->file || $file
l!l&&r!l&&!r
11200
$b->FILE or $b->START->file
l!l&&r!l&&!r
11200
$b->START->line || $line
l!l&&r!l&&!r
11200
MC/DC0%0/3
$b->FILE || $b->START->file || $file
$b->FILE $b->START->file $file
MC/DC0%0/2
$b->START->line || $line
$b->START->line $line
Truth table25%1/4
A or B || C
A= $b->FILEB= $b->START->fileC= $file
ABCresult
1XX1
01X1
0011
0000
Truth table33%1/3
A || B
A= $b->START->lineB= $line
ABresult
1X1
011
000
80 'file' => $b->FILE || $b->START->file || $file,
81 'line' => $b->START->line || $line,
82 'via' => __PACKAGE__,
83 };
84 }
85
86 return {
87 21 'package' => $pkg,
88 'file' => $file,
89 'line' => $line,
90 'via' => __PACKAGE__,
91 };
92 }
93  
94 sub true () { !!1 }
95 sub false () { !!0 }
96  
97 0 ▶sub confess {
Subroutine confess: not called CC=2 SCAR=17.9
Pod undocumented
98 0 require Carp;
99 0 ▶ return Carp::confess( @_ > 1 ? sprintf( shift, @_ ) : $_[0] );
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 0 0 0
100 }
101  
102 16 ▶sub app {
Subroutine app: called CC=4 SCAR=13.9
Pod undocumented
103 16 my $definition = _pop_type( CodeRef, @_ );
104 16 my $name = _shift_type( Str|ScalarRef, @_ );
105 16 my %args = @_;
106
107 16 my $package;
108 my $is_anon;
109 16 ▶ if ( is_Str $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_Str($name)) { } 12 4 16
110 12 $package = $name;
111 }
112 else {
113 4 $is_anon = true;
114 4 $package = _anon_package_name();
115 }
116
117 16 my $caller = caller;
118
119 16 local $THIS{APP} = $package;
120 local $THIS{APP_SPEC} = {
121 16 caller => $caller,
122 factory_package => $package,
123 prefix => $package,
124 toolkit => 'Moo',
125 %args,
126 };
127 16 $definition->();
128
129 16 ▶ if ( delete $args{debug} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (delete $args{"debug"}) 0 16 16
130 0 require Data::Dumper;
131 0 print STDERR Data::Dumper::Dumper( $THIS{APP_SPEC} );
132 }
133
134 'MooX::Press'->import(
135 16 %{ $THIS{APP_SPEC} },
136 );
137
138 16 ▶ if ( $is_anon ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_anon) 4 12 16
139 4 @_ = ( app => $name, MooX::Press::make_absolute_package_name($package) );
140 4 goto \&_return_anon;
141 }
142 12 return;
143 }
144  
145 84 ▶sub class {
Subroutine class: called CC=27 SCAR=36.0
Pod undocumented
146 84 my $finalize = undef;
147 84 ▶ if ( not $THIS{APP_SPEC} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Zydeco::Lite::THIS{"APP_SPEC"}) 1 83 84
148 1 my $caller = caller;
149 $THIS{APP_SPEC} = {
150 1 caller => $caller,
151 toolkit => 'Moo',
152 };
153 0 ▶ $finalize = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
154 'MooX::Press'->import(
155 0 %{ $THIS{APP_SPEC} },
156 );
157 0 $THIS{APP_SPEC} = undef;
158 1 };
159 }
160
161 84 my $dummy_dfn = false;
162 84 ▶ my $definition = _pop_type( CodeRef, @_ ) || do { $dummy_dfn = true; sub { 1 } };
Subroutine __ANON__: called CC=1 SCAR=0.0
Condition66%2/3
&_pop_type(scalar &CodeRef(), \@_) || do { $dummy_dfn = !0; sub { 1; } }
l!l&&r!l&&!r
7950
MC/DC0%0/2
&_pop_type(scalar &CodeRef(), \@_) || do { $dummy_dfn = !0; sub { 1; } }
&_pop_type(scalar &CodeRef(), \@_) do { $dummy_dfn = !0; sub { 1; } }
Truth table66%2/3
A || B
A= &_pop_type(scalar &CodeRef(), \@_)B= do { $dummy_dfn = !0; sub { 1; } }
ABresult
1X1
011
000
163 84 ▶ my $name = ( @_ % 2 ) ? _shift_type( Str|ScalarRef, @_ ) : undef;
Branch: 1 branch
BranchTrueFalseTotal
@_ % 2 ? : 77 7 84
164 84 my %args = @_;
165
166 84 ▶ $args{definition_context} ||= _make_definition_context(1, $dummy_dfn ? () : $definition);
Branch: 1 branch
BranchTrueFalseTotal
$dummy_dfn ? : 5 79 84
Condition33%1/3
$args{"definition_context"} ||= _make_definition_context(1, $dummy_dfn ? () : $definition)
l!l&&r!l&&!r
0840
MC/DC0%0/2
$args{"definition_context"} ||= _make_definition_context(1, $dummy_dfn ? () : $definition)
$args{"definition_context"} _make_definition_context(1, $dummy_dfn ? () : $definition)
Truth table33%1/3
A ||= B
A= $args{"definition_context"}B= _make_definition_context(1, $dummy_dfn ? () : $definition)
ABresult
1X1
011
000
167  
168 my $kind =
169 $args{interface} ? 'interface' :
170 $args{abstract} ? 'abstract class' :
171 84 ▶ $args{is_role} ? 'role' :
Branch: 3 branches
BranchTrueFalseTotal
$args{'interface'} ? : 0 84 84
$args{'abstract'} ? : 0 84 84
$args{'is_role'} ? : 31 53 84
172 'class';
173
174 84 ▶ if ( delete $args{is_generator} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (delete $args{"is_generator"}) 2 82 84
175 2 my $gen = _wrap_generator( @_, $definition );
176
177 2 ▶ if ( is_Str $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_Str($name)) { } 2 0 2
178 my $key = sprintf(
179 '%s:%s',
180 2 ▶ $args{is_role} ? 'role_generator' : 'class_generator',
Branch: 1 branch
BranchTrueFalseTotal
$args{'is_role'} ? : 1 1 2
181 $name,
182 );
183 2 $THIS{APP_SPEC}{$key} = $gen;
184 2 ▶ $finalize->() if $finalize;
Branch: 1 branch
BranchTrueFalseTotal
if $finalize 0 2 2
185 2 return;
186 }
187 else {
188 0 ▶ my $method = $args{is_role} ? 'make_role_generator' : 'make_class_generator';
Branch: 1 branch
BranchTrueFalseTotal
$args{'is_role'} ? : 0 0 0
189 0 my $package = _anon_package_name();
190 'MooX::Press'->$method(
191 MooX::Press::make_absolute_package_name($package),
192 0 ▶ %{ $THIS{APP_SPEC} or {} },
Condition0%0/2
$Zydeco::Lite::THIS{'APP_SPEC'} || {}
l!l
00
MC/DC0%0/1
$Zydeco::Lite::THIS{'APP_SPEC'} || {}
$Zydeco::Lite::THIS{'APP_SPEC'}
Truth table0%0/2
A
A= $Zydeco::Lite::THIS{'APP_SPEC'}
Aresult
11
00
193 %args,
194 generator => $gen,
195 );
196
197 0 @_ = ( "$kind generator", $name, MooX::Press::make_absolute_package_name($package) );
198 0 goto \&_return_anon;
199 }
200 }
201
202 my $key = sprintf(
203 '%s:%s',
204 82 ▶ $args{is_role} ? 'role' : 'class',
Branch: 2 branches
BranchTrueFalseTotal
$args{'is_role'} ? : 30 52 82
is_Str($name) ? : 75 7 82
205 is_Str($name) ? $name : '',
206 );
207
208 82 my $class_spec = do {
209 82 ▶ local $THIS{CLASS} = is_Str($name) ? $name : undef;
Branch: 1 branch
BranchTrueFalseTotal
is_Str($name) ? : 75 7 82
210 82 local $THIS{CLASS_SPEC} = { %args };
211 82 $definition->();
212 82 delete $THIS{CLASS_SPEC}{is_role};
213 82 $THIS{CLASS_SPEC};
214 };
215
216 # Anonymous package
217 82 ▶ if ( ! is_Str $name ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not is_Str($name)) { } 7 75 82
elsif ($Zydeco::Lite::THIS{'CLASS_SPEC'}) { } 29 46 75
218 7 ▶ my $method = $args{is_role} ? 'make_role' : 'make_class';
Branch: 1 branch
BranchTrueFalseTotal
$args{'is_role'} ? : 5 2 7
219 7 my $package = _anon_package_name();
220 'MooX::Press'->$method(
221 MooX::Press::make_absolute_package_name($package),
222 7 ▶ %{ $THIS{APP_SPEC} or {} },
Condition50%1/2
$Zydeco::Lite::THIS{'APP_SPEC'} || {}
l!l
70
MC/DC0%0/1
$Zydeco::Lite::THIS{'APP_SPEC'} || {}
$Zydeco::Lite::THIS{'APP_SPEC'}
Truth table50%1/2
A
A= $Zydeco::Lite::THIS{'APP_SPEC'}
Aresult
11
00
223 %$class_spec,
224 );
225 7 @_ = ( $kind, $name, MooX::Press::make_absolute_package_name($package) );
226 7 goto \&_return_anon;
227 }
228 # Nested class
229 elsif ( $THIS{CLASS_SPEC} ) {
230 defined $THIS{CLASS}
231 29 ▶ or confess('cannot subclass anonymous classes');
Branch: 1 branch
BranchTrueFalseTotal
defined $Zydeco::Lite::THIS{"CLASS"} or confess("cannot subclass anonymous classes") 29 0 29
232 $THIS{CLASS_SPEC}{is_role}
233 29 ▶ and confess('cannot subclass roles');
Branch: 1 branch
BranchTrueFalseTotal
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"is_role"} and confess("cannot subclass roles") 0 29 29
234 $THIS{CLASS_SPEC}{is_generator}
235 29 ▶ and confess('cannot subclass class generators');
Branch: 1 branch
BranchTrueFalseTotal
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"is_generator"} and confess("cannot subclass class generators") 0 29 29
236
237 29 ▶ push @{ $THIS{CLASS_SPEC}{subclass} ||= [] }, $name, $class_spec;
Condition100%2/2
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"subclass"} ||= []
l!l
227
MC/DC100%1/1
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"subclass"} ||= []
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"subclass"}
Truth table100%2/2
A
A= $Zydeco::Lite::THIS{"CLASS_SPEC"}{"subclass"}
Aresult
11
00
238 }
239 # Otherwise
240 else {
241 46 $THIS{APP_SPEC}{$key} = $class_spec;
242 }
243
244 75 ▶ $finalize->() if $finalize;
Branch: 1 branch
BranchTrueFalseTotal
if $finalize 0 75 75
245 75 return;
246 }
247  
248 31 ▶sub role {
Subroutine role: called CC=3 SCAR=11.2
Pod undocumented
249 $THIS{APP_SPEC}
250 31 ▶ or confess("`role` used outside an app definition");
Branch: 1 branch
BranchTrueFalseTotal
$Zydeco::Lite::THIS{"APP_SPEC"} or confess("`role` used outside an app definition") 31 0 31
251
252 31 ▶ my $definition = _pop_type( CodeRef, @_ ) || sub { 1 };
Subroutine __ANON__: called CC=1 SCAR=0.1
Condition66%2/3
&_pop_type(scalar &CodeRef(), \@_) || sub { 1; }
l!l&&r!l&&!r
2560
MC/DC0%0/2
&_pop_type(scalar &CodeRef(), \@_) || sub { 1; }
&_pop_type(scalar &CodeRef(), \@_) sub { 1; }
Truth table66%2/3
A || B
A= &_pop_type(scalar &CodeRef(), \@_)B= sub { 1; }
ABresult
1X1
011
000
253 31 push @_, ( is_role => true, $definition );
254 31 goto \&class;
255 }
256  
257 0 ▶sub abstract_class {
Subroutine abstract_class: not called CC=3 SCAR=24.8
Pod undocumented
258 $THIS{APP_SPEC}
259 0 ▶ or confess("`abstract_class` used outside an app definition");
Branch: 1 branch
BranchTrueFalseTotal
$Zydeco::Lite::THIS{"APP_SPEC"} or confess("`abstract_class` used outside an app definition") 0 0 0
260
261 0 ▶ my $definition = _pop_type( CodeRef, @_ ) || sub { 1 };
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
&_pop_type(scalar &CodeRef(), \@_) || sub { 1; }
l!l&&r!l&&!r
000
MC/DC0%0/2
&_pop_type(scalar &CodeRef(), \@_) || sub { 1; }
&_pop_type(scalar &CodeRef(), \@_) sub { 1; }
Truth table0%0/3
A || B
A= &_pop_type(scalar &CodeRef(), \@_)B= sub { 1; }
ABresult
1X1
011
000
262 0 push @_, ( abstract => true, $definition );
263 0 goto \&class;
264 }
265  
266 0 ▶sub interface {
Subroutine interface: not called CC=3 SCAR=24.8
Pod undocumented
267 $THIS{APP_SPEC}
268 0 ▶ or confess("`interface` used outside an app definition");
Branch: 1 branch
BranchTrueFalseTotal
$Zydeco::Lite::THIS{"APP_SPEC"} or confess("`interface` used outside an app definition") 0 0 0
269
270 0 ▶ my $definition = _pop_type( CodeRef, @_ ) || sub { 1 };
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
&_pop_type(scalar &CodeRef(), \@_) || sub { 1; }
l!l&&r!l&&!r
000
MC/DC0%0/2
&_pop_type(scalar &CodeRef(), \@_) || sub { 1; }
&_pop_type(scalar &CodeRef(), \@_) sub { 1; }
Truth table0%0/3
A || B
A= &_pop_type(scalar &CodeRef(), \@_)B= sub { 1; }
ABresult
1X1
011
000
271 0 push @_, ( interface => true, is_role => true, $definition );
272 0 goto \&class;
273 }
274  
275 2 ▶sub _wrap_generator {
Subroutine _wrap_generator: called CC=1 SCAR=0.0
276 2 my $definition = _pop_type( CodeRef, @_ );
277 2 my %args = @_;
278
279 2 my $is_role = delete $args{'is_role'};
280 2 my $app = $THIS{APP_SPEC};
281
282 3 ▶ my $code = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
283 3 local $THIS{APP_SPEC} = $app;
284 3 local $THIS{CLASS_SPEC} = { is_role => $is_role };
285 3 $definition->(@_);
286 3 delete $THIS{CLASS_SPEC}{is_role};
287 3 return $THIS{CLASS_SPEC};
288 2 };
289
290 2 return { code => $code, %args };
291 }
292  
293 2 ▶sub generator {
Subroutine generator: called CC=3 SCAR=12.3
Pod undocumented
294 0 ▶ my $definition = _pop_type( CodeRef, @_ ) || sub { 1 };
Subroutine __ANON__: not called CC=1 SCAR=2.0
Condition33%1/3
&_pop_type(scalar &CodeRef(), \@_) || sub { 1; }
l!l&&r!l&&!r
200
MC/DC0%0/2
&_pop_type(scalar &CodeRef(), \@_) || sub { 1; }
&_pop_type(scalar &CodeRef(), \@_) sub { 1; }
Truth table33%1/3
A || B
A= &_pop_type(scalar &CodeRef(), \@_)B= sub { 1; }
ABresult
1X1
011
000
295 2 my $package = _shift_type( Str|ScalarRef, @_ );
296 2 my $sig = _shift_type( Ref, @_ );
297 2 my %args = @_;
298
299 return (
300 2 ▶ $package ? $package : (),
Branch: 1 branch
BranchTrueFalseTotal
$package ? : 2 0 2
301 %args,
302 is_generator => true,
303 signature => $sig,
304 $definition,
305 );
306 }
307  
308 33 ▶sub _method {
Subroutine _method: called CC=10 SCAR=32.6
309 33 my $next = shift;
310 33 ▶ my $definition = _pop_type( CodeRef, @_ )
Branch: 1 branch
BranchTrueFalseTotal
my $definition = &_pop_type(scalar &CodeRef(), \@_) or confess("methods must have a body") 33 0 33
311 or confess('methods must have a body');
312 33 my $subname = _shift_type( Str|ScalarRef, @_ );
313 33 my $sig = _shift_type( Ref, @_ );
314 33 my %args = @_;
315
316 33 ▶ if ( is_ScalarRef $subname or is_Undef $subname ) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_ScalarRef($subname) or is_Undef($subname)) 0 33 33
Condition33%1/3
is_ScalarRef($subname) or is_Undef($subname)
l!l&&r!l&&!r
0033
MC/DC0%0/2
is_ScalarRef($subname) or is_Undef($subname)
is_ScalarRef($subname) is_Undef($subname)
Truth table33%1/3
A or B
A= is_ScalarRef($subname)B= is_Undef($subname)
ABresult
1X1
011
000
317 0 my $coderef;
318
319 0 ▶ if ( $sig or keys %args ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sig or keys %args) { } 0 0 0
Condition0%0/3
$sig or keys %args
l!l&&r!l&&!r
000
MC/DC0%0/2
$sig or keys %args
$sig keys %args
Truth table0%0/3
A or B
A= $sigB= keys %args
ABresult
1X1
011
000
320 0 ▶ if ( defined $sig ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $sig) 0 0 0
321 0 $args{definition_context} = _make_definition_context(1, $definition);
322 0 $args{caller} = caller;
323 0 $args{code} = $definition;
324 0 $args{signature} = $sig;
325 0 ▶ $args{named} = false unless exists $args{named};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $args{"named"} 0 0 0
326
327 0 $coderef = 'MooX::Press'->wrap_coderef( \%args );
328 }
329 }
330 else {
331 0 $coderef = $definition;
332 }
333
334 0 @_ = ( method => $subname, $coderef );
335 0 goto &_return_anon;
336 }
337
338 33 $args{definition_context} = _make_definition_context(1, $definition);
339 33 $args{caller} = caller;
340 33 $args{code} = $definition;
341
342 33 ▶ if ( defined $sig ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $sig) 7 26 33
343 7 $args{signature} = $sig;
344 7 ▶ $args{named} = false unless exists $args{named};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $args{"named"} 6 1 7
345 }
346
347 33 $next->( $subname, \%args );
348 33 return;
349 }
350  
351 21 ▶sub method {
Subroutine method: called CC=3 SCAR=12.0
Pod undocumented
352 my ( $target, $key ) = $THIS{CLASS_SPEC}
353 ? ( $THIS{CLASS_SPEC}, 'can' )
354 21 ▶ : ( $THIS{APP_SPEC}, 'factory_package_can' );
Branch: 1 branch
BranchTrueFalseTotal
$Zydeco::Lite::THIS{'CLASS_SPEC'} ? : 21 0 21
355 21 my $next;
356
357 21 ▶ if ( $target ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target) { } 21 0 21
358 21 ▶ $next = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
359 21 my ( $subname, $args ) = @_;
360 21 ▶ ( $target->{$key} ||= {} )->{$subname} = $args;
Condition100%2/2
$target->{$key} ||= {}
l!l
318
MC/DC100%1/1
$target->{$key} ||= {}
$target->{$key}
Truth table100%2/2
A
A= $target->{$key}
Aresult
11
00
361 21 };
362 }
363 else {
364 0 my $caller = caller;
365 0 ▶ $next = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
366 0 my ( $subname, $args ) = @_;
367 0 'MooX::Press'->patch_package( $caller, can => { $subname => $args } );
368 0 };
369 }
370
371 21 unshift @_, $next;
372 21 goto \&_method;
373 }
374  
375 7 ▶sub symmethod {
Subroutine symmethod: called CC=4 SCAR=17.1
Pod undocumented
376 7 my $next;
377
378 7 ▶ if ( my $target = $THIS{CLASS_SPEC} || $THIS{APP_SPEC} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $target = $Zydeco::Lite::THIS{'CLASS_SPEC'} || $Zydeco::Lite::THIS{'APP_SPEC'}) { } 7 0 7
Condition33%1/3
$Zydeco::Lite::THIS{'CLASS_SPEC'} || $Zydeco::Lite::THIS{'APP_SPEC'}
l!l&&r!l&&!r
700
MC/DC0%0/2
$Zydeco::Lite::THIS{'CLASS_SPEC'} || $Zydeco::Lite::THIS{'APP_SPEC'}
$Zydeco::Lite::THIS{'CLASS_SPEC'} $Zydeco::Lite::THIS{'APP_SPEC'}
Truth table33%1/3
A || B
A= $Zydeco::Lite::THIS{'CLASS_SPEC'}B= $Zydeco::Lite::THIS{'APP_SPEC'}
ABresult
1X1
011
000
379 7 ▶ $next = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
380 7 my ( $subname, $args ) = @_;
381 7 ▶ push @{ $target->{symmethod} ||= [] }, $subname, $args;
Condition100%2/2
$target->{"symmethod"} ||= []
l!l
25
MC/DC100%1/1
$target->{"symmethod"} ||= []
$target->{"symmethod"}
Truth table100%2/2
A
A= $target->{"symmethod"}
Aresult
11
00
382 7 };
383 }
384 else {
385 0 ▶ my $target = $THIS{APP} || caller;
Condition0%0/3
$Zydeco::Lite::THIS{'APP'} || caller
l!l&&r!l&&!r
000
MC/DC0%0/2
$Zydeco::Lite::THIS{'APP'} || caller
$Zydeco::Lite::THIS{'APP'} caller
Truth table0%0/3
A || B
A= $Zydeco::Lite::THIS{'APP'}B= caller
ABresult
1X1
011
000
386 0 ▶ $next = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
387 0 my ( $subname, $args ) = @_;
388 0 'MooX::Press'->patch_package( $target, symmethod => { $subname => $args } );
389 0 };
390 }
391
392 7 unshift @_, $next;
393 7 goto \&_method;
394 }
395  
396 3 ▶sub multi_method {
Subroutine multi_method: called CC=4 SCAR=15.4
Pod undocumented
397 3 ▶ my $subname = is_Str($_[0])
Branch: 1 branch
BranchTrueFalseTotal
is_Str($_[0]) ? : 3 0 3
398 ? $_[0]
399 : confess('anonymous multi factories not supported');
400 3 ▶ my $target = $THIS{CLASS_SPEC} || $THIS{APP_SPEC};
Condition33%1/3
$Zydeco::Lite::THIS{'CLASS_SPEC'} || $Zydeco::Lite::THIS{'APP_SPEC'}
l!l&&r!l&&!r
300
MC/DC0%0/2
$Zydeco::Lite::THIS{'CLASS_SPEC'} || $Zydeco::Lite::THIS{'APP_SPEC'}
$Zydeco::Lite::THIS{'CLASS_SPEC'} $Zydeco::Lite::THIS{'APP_SPEC'}
Truth table33%1/3
A || B
A= $Zydeco::Lite::THIS{'CLASS_SPEC'}B= $Zydeco::Lite::THIS{'APP_SPEC'}
ABresult
1X1
011
000
401 3 my $next;
402
403 3 ▶ if ( $target ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target) { } 3 0 3
404 3 ▶ $next = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
405 3 my ( $subname, $args ) = @_;
406 3 ▶ push @{ $target->{multimethod} ||= [] }, $subname, $args;
Condition100%2/2
$target->{"multimethod"} ||= []
l!l
12
MC/DC100%1/1
$target->{"multimethod"} ||= []
$target->{"multimethod"}
Truth table100%2/2
A
A= $target->{"multimethod"}
Aresult
11
00
407 3 };
408 }
409 else {
410 0 my $caller = shift;
411 0 ▶ $next = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
412 0 my ( $subname, $args ) = @_;
413 0 'MooX::Press'->patch_package( $caller, multimethod => { $subname => $args } );
414 0 };
415 }
416
417 3 unshift @_, $next;
418 3 goto \&_method;
419 }
420  
421 10 ▶sub factory {
Subroutine factory: called CC=11 SCAR=24.2
Pod undocumented
422 $THIS{CLASS_SPEC}
423 10 ▶ or confess("`factory` used outside a class definition");
Branch: 1 branch
BranchTrueFalseTotal
$Zydeco::Lite::THIS{"CLASS_SPEC"} or confess("`factory` used outside a class definition") 10 0 10
424 $THIS{CLASS_SPEC}{is_role}
425 10 ▶ and confess("`factory` used in a role definition");
Branch: 1 branch
BranchTrueFalseTotal
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"is_role"} and confess("`factory` used in a role definition") 0 10 10
426
427 10 ▶ if ( @_==0 and not $THIS{CLASS_SPEC}{factory} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 0 and not $Zydeco::Lite::THIS{"CLASS_SPEC"}{"factory"}) 1 9 10
Condition66%2/3
@_ == 0 and not $Zydeco::Lite::THIS{"CLASS_SPEC"}{"factory"}
!ll&&!rl&&r
901
MC/DC50%1/2
@_ == 0 and not $Zydeco::Lite::THIS{"CLASS_SPEC"}{"factory"}
@_ == 0 not $Zydeco::Lite::THIS{"CLASS_SPEC"}{"factory"}
Truth table66%2/3
A and not(B)
A= @_ == 0B= not $Zydeco::Lite::THIS{"CLASS_SPEC"}{"factory"}
ABresult
0X0
100
111
428 1 $THIS{CLASS_SPEC}{factory} = undef;
429 1 return;
430 }
431
432 9 my $definition = _pop_type( CodeRef|ScalarRef, @_ );
433 9 ▶ my $subnames = _shift_type( Str|ArrayRef, @_ )
Branch: 1 branch
BranchTrueFalseTotal
my $subnames = &_shift_type(&Str() | &ArrayRef(), \@_) or confess("factory cannot be anonymous") 9 0 9
434 or confess("factory cannot be anonymous");
435 9 my $sig = _shift_type( Ref, @_ );
436 9 my %args = @_;
437
438 9 ▶ $subnames = [ $subnames ] if is_Str $subnames;
Branch: 1 branch
BranchTrueFalseTotal
if is_Str($subnames) 3 6 9
439 9 ▶ $definition ||= \ "new";
Condition100%2/2
$definition ||= \"new"
l!l
63
MC/DC100%1/1
$definition ||= \"new"
$definition
Truth table100%2/2
A
A= $definition
Aresult
11
00
440
441 9 ▶ if ( ! is_ScalarRef $definition ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (is_ScalarRef($definition)) 3 6 9
442 3 my $code = $definition;
443 3 $definition = \%args;
444 3 $definition->{code} = $code;
445 3 ▶ $definition->{signature} = $sig if $sig;
Branch: 1 branch
BranchTrueFalseTotal
if $sig 0 3 3
446 }
447
448 9 ▶ push @{ $THIS{CLASS_SPEC}{factory} ||= [] }, @$subnames, $definition;
Condition100%2/2
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"factory"} ||= []
l!l
63
MC/DC100%1/1
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"factory"} ||= []
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"factory"}
Truth table100%2/2
A
A= $Zydeco::Lite::THIS{"CLASS_SPEC"}{"factory"}
Aresult
11
00
449 }
450  
451 2 ▶sub multi_factory {
Subroutine multi_factory: called CC=4 SCAR=14.5
Pod undocumented
452 my $target = $THIS{CLASS_SPEC}
453 2 ▶ or confess("`multi_factory` used outside a class definition");
Branch: 1 branch
BranchTrueFalseTotal
my $target = $Zydeco::Lite::THIS{"CLASS_SPEC"} or confess("`multi_factory` used outside a class definition") 2 0 2
454 $target->{is_role}
455 2 ▶ and confess("`multi_factory` used in a role definition");
Branch: 1 branch
BranchTrueFalseTotal
$target->{"is_role"} and confess("`multi_factory` used in a role definition") 0 2 2
456
457 2 ▶ my $subname = is_Str($_[0])
Branch: 1 branch
BranchTrueFalseTotal
is_Str($_[0]) ? : 2 0 2
458 ? $_[0]
459 : confess('anonymous multi factories not supported');
460
461 2 ▶ unshift @_, sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
462 2 my ( $subname, $args ) = @_;
463 2 ▶ push @{ $target->{multifactory} ||= [] }, $subname, $args;
Condition50%1/2
$target->{"multifactory"} ||= []
l!l
02
MC/DC0%0/1
$target->{"multifactory"} ||= []
$target->{"multifactory"}
Truth table50%1/2
A
A= $target->{"multifactory"}
Aresult
11
00
464 2 };
465 2 goto \&_method;
466 }
467  
468 12 ▶sub _modifier {
Subroutine _modifier: called CC=10 SCAR=27.1
469 12 my $modifier_type = shift;
470 12 ▶ my $definition = _pop_type( CodeRef, @_ )
Branch: 1 branch
BranchTrueFalseTotal
my $definition = &_pop_type(scalar &CodeRef(), \@_) or confess("methods modifiers must have a body") 12 0 12
471 or confess('methods modifiers must have a body');
472 12 ▶ my $subname = _shift_type( Str|ArrayRef, @_ )
Branch: 1 branch
BranchTrueFalseTotal
my $subname = &_shift_type(&Str() | &ArrayRef(), \@_) or confess("modified methods cannot be anonymous") 12 0 12
473 or confess("modified methods cannot be anonymous");
474 12 my $sig = _shift_type( Ref, @_ );
475 12 my %args = @_;
476
477 12 $args{code} = $definition;
478
479 12 ▶ if ( defined $sig ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $sig) 0 12 12
480 0 $args{signature} = $sig;
481 0 ▶ $args{named} = false unless exists $args{named};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $args{"named"} 0 0 0
482 }
483
484 12 my @keys = keys %args;
485 12 ▶ if ( @keys > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@keys > 1) 0 12 12
486 0 $definition = \%args;
487 }
488
489 12 ▶ my $target = $THIS{CLASS_SPEC} || $THIS{APP_SPEC};
Condition66%2/3
$Zydeco::Lite::THIS{'CLASS_SPEC'} || $Zydeco::Lite::THIS{'APP_SPEC'}
l!l&&r!l&&!r
1110
MC/DC0%0/2
$Zydeco::Lite::THIS{'CLASS_SPEC'} || $Zydeco::Lite::THIS{'APP_SPEC'}
$Zydeco::Lite::THIS{'CLASS_SPEC'} $Zydeco::Lite::THIS{'APP_SPEC'}
Truth table66%2/3
A || B
A= $Zydeco::Lite::THIS{'CLASS_SPEC'}B= $Zydeco::Lite::THIS{'APP_SPEC'}
ABresult
1X1
011
000
490
491 12 ▶ if ( $target ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target) { } 12 0 12
492 12 ▶ push @{ $target->{$modifier_type} ||= [] }, (
Branch: 1 branch
BranchTrueFalseTotal
ref $subname ? : 4 8 12
Condition50%1/2
$target->{$modifier_type} ||= []
l!l
012
MC/DC0%0/1
$target->{$modifier_type} ||= []
$target->{$modifier_type}
Truth table50%1/2
A
A= $target->{$modifier_type}
Aresult
11
00
493 ref($subname) ? @$subname : $subname,
494 $definition,
495 );
496 }
497 else {
498 0 my $caller = caller;
499 0 'MooX::Press'->patch_package( $caller, $modifier_type => { $subname => $definition } );
500 }
501
502 12 return;
503 }
504  
505 4 ▶sub before {
Subroutine before: called CC=1 SCAR=0.0
Pod undocumented
506 4 unshift @_, 'before';
507 4 goto \&_modifier;
508 }
509  
510 0 ▶sub after {
Subroutine after: not called CC=1 SCAR=6.9
Pod undocumented
511 0 unshift @_, 'after';
512 0 goto \&_modifier;
513 }
514  
515 8 ▶sub around {
Subroutine around: called CC=1 SCAR=0.0
Pod undocumented
516 8 unshift @_, 'around';
517 8 goto \&_modifier;
518 }
519  
520 6 ▶sub extends {
Subroutine extends: called CC=5 SCAR=18.1
Pod undocumented
521 my $spec = $THIS{CLASS_SPEC} || $THIS{APP_SPEC}
522 6 ▶ or confess("`extends` used outside a class or app definition");
Branch: 1 branch
BranchTrueFalseTotal
my $spec = $Zydeco::Lite::THIS{"CLASS_SPEC"} || $Zydeco::Lite::THIS{"APP_SPEC"} or confess("`extends` used outside a class or app definition") 6 0 6
Condition33%1/3
$Zydeco::Lite::THIS{'CLASS_SPEC'} || $Zydeco::Lite::THIS{'APP_SPEC'}
l!l&&r!l&&!r
600
MC/DC0%0/2
$Zydeco::Lite::THIS{'CLASS_SPEC'} || $Zydeco::Lite::THIS{'APP_SPEC'}
$Zydeco::Lite::THIS{'CLASS_SPEC'} $Zydeco::Lite::THIS{'APP_SPEC'}
Truth table33%1/3
A || B
A= $Zydeco::Lite::THIS{'CLASS_SPEC'}B= $Zydeco::Lite::THIS{'APP_SPEC'}
ABresult
1X1
011
000
523 $spec->{is_role}
524 6 ▶ and confess("`extends` used in a role definition");
Branch: 1 branch
BranchTrueFalseTotal
$spec->{"is_role"} and confess("`extends` used in a role definition") 0 6 6
525
526 6 ▶ @{ $spec->{extends} ||= [] } = @_;
Condition50%1/2
$spec->{"extends"} ||= []
l!l
06
MC/DC0%0/1
$spec->{"extends"} ||= []
$spec->{"extends"}
Truth table50%1/2
A
A= $spec->{"extends"}
Aresult
11
00
527
528 6 return;
529 }
530  
531 36 ▶sub with {
Subroutine with: called CC=4 SCAR=14.1
Pod undocumented
532 my $spec = $THIS{CLASS_SPEC} || $THIS{APP_SPEC}
533 36 ▶ or confess("`with` used outside a class, role, or app definition");
Branch: 1 branch
BranchTrueFalseTotal
my $spec = $Zydeco::Lite::THIS{"CLASS_SPEC"} || $Zydeco::Lite::THIS{"APP_SPEC"} or confess("`with` used outside a class, role, or app definition") 36 0 36
Condition66%2/3
$Zydeco::Lite::THIS{'CLASS_SPEC'} || $Zydeco::Lite::THIS{'APP_SPEC'}
l!l&&r!l&&!r
3510
MC/DC0%0/2
$Zydeco::Lite::THIS{'CLASS_SPEC'} || $Zydeco::Lite::THIS{'APP_SPEC'}
$Zydeco::Lite::THIS{'CLASS_SPEC'} $Zydeco::Lite::THIS{'APP_SPEC'}
Truth table66%2/3
A || B
A= $Zydeco::Lite::THIS{'CLASS_SPEC'}B= $Zydeco::Lite::THIS{'APP_SPEC'}
ABresult
1X1
011
000
534
535 36 ▶ push @{ $spec->{with} ||= [] }, @_;
Condition100%2/2
$spec->{"with"} ||= []
l!l
234
MC/DC100%1/1
$spec->{"with"} ||= []
$spec->{"with"}
Truth table100%2/2
A
A= $spec->{"with"}
Aresult
11
00
536
537 36 return;
538 }
539  
540 19 ▶sub has {
Subroutine has: called CC=10 SCAR=24.6
Pod undocumented
541 $THIS{CLASS_SPEC}
542 19 ▶ or confess("`has` used outside a class or role definition");
Branch: 1 branch
BranchTrueFalseTotal
$Zydeco::Lite::THIS{"CLASS_SPEC"} or confess("`has` used outside a class or role definition") 19 0 19
543
544 19 ▶ my $names = _shift_type( ArrayRef|ScalarRef|Str, @_ )
Branch: 1 branch
BranchTrueFalseTotal
my $names = &_shift_type(&ArrayRef() | &ScalarRef() | &Str(), \@_) or confess("attributes cannot be anonymous") 19 0 19
545 or confess("attributes cannot be anonymous");
546 19 ▶ my $spec = @_ == 1 ? $_[0] : { @_ };
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 9 10 19
547
548 19 ▶ if ( is_ArrayRef $spec ) {
Branch: 2 branches
BranchTrueFalseTotal
if (is_ArrayRef($spec)) { } 0 19 19
elsif (is_HashRef($spec)) { } 16 3 19
549 0 unshift @$spec, definition_context => _make_definition_context(1);
550 }
551 elsif ( is_HashRef $spec ) {
552 16 ▶ $spec->{definition_context} ||= _make_definition_context(1);
Condition33%1/3
$spec->{"definition_context"} ||= _make_definition_context(1)
l!l&&r!l&&!r
0160
MC/DC0%0/2
$spec->{"definition_context"} ||= _make_definition_context(1)
$spec->{"definition_context"} _make_definition_context(1)
Truth table33%1/3
A ||= B
A= $spec->{"definition_context"}B= _make_definition_context(1)
ABresult
1X1
011
000
553 }
554
555 19 ▶ $names = [ $names ] unless is_ArrayRef $names;
Branch: 1 branch
BranchTrueFalseTotal
unless is_ArrayRef($names) 19 0 19
556 19 ▶ push @{ $THIS{CLASS_SPEC}{has} ||= [] }, ( $_, $spec ) for @$names;
Condition100%2/2
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"has"} ||= []
l!l
910
MC/DC100%1/1
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"has"} ||= []
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"has"}
Truth table100%2/2
A
A= $Zydeco::Lite::THIS{"CLASS_SPEC"}{"has"}
Aresult
11
00
557
558 19 return;
559 }
560  
561 5 ▶sub constant {
Subroutine constant: called CC=9 SCAR=29.5
Pod undocumented
562 5 ▶ my $names = _shift_type( ArrayRef|Str, @_ )
Branch: 1 branch
BranchTrueFalseTotal
my $names = &_shift_type(&ArrayRef() | &Str(), \@_) or confess("constants cannot be anonymous") 5 0 5
563 or confess("constants cannot be anonymous");
564 5 my $value = shift;
565
566 5 ▶ $names = [ $names ] unless is_ArrayRef $names;
Branch: 1 branch
BranchTrueFalseTotal
unless is_ArrayRef($names) 5 0 5
567
568 5 ▶ if ( my $spec = $THIS{CLASS_SPEC} || $THIS{APP_SPEC} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $spec = $Zydeco::Lite::THIS{'CLASS_SPEC'} || $Zydeco::Lite::THIS{'APP_SPEC'}) { } 5 0 5
Condition33%1/3
$Zydeco::Lite::THIS{'CLASS_SPEC'} || $Zydeco::Lite::THIS{'APP_SPEC'}
l!l&&r!l&&!r
500
MC/DC0%0/2
$Zydeco::Lite::THIS{'CLASS_SPEC'} || $Zydeco::Lite::THIS{'APP_SPEC'}
$Zydeco::Lite::THIS{'CLASS_SPEC'} $Zydeco::Lite::THIS{'APP_SPEC'}
Truth table33%1/3
A || B
A= $Zydeco::Lite::THIS{'CLASS_SPEC'}B= $Zydeco::Lite::THIS{'APP_SPEC'}
ABresult
1X1
011
000
569 5 ▶ ( $spec->{constant} ||= {} )->{$_} = $value for @$names;
Condition100%2/2
$spec->{"constant"} ||= {}
l!l
23
MC/DC100%1/1
$spec->{"constant"} ||= {}
$spec->{"constant"}
Truth table100%2/2
A
A= $spec->{"constant"}
Aresult
11
00
570 }
571 else {
572 0 ▶ my $caller = $THIS{APP} || caller;
Condition0%0/3
$Zydeco::Lite::THIS{'APP'} || caller
l!l&&r!l&&!r
000
MC/DC0%0/2
$Zydeco::Lite::THIS{'APP'} || caller
$Zydeco::Lite::THIS{'APP'} caller
Truth table0%0/3
A || B
A= $Zydeco::Lite::THIS{'APP'}B= caller
ABresult
1X1
011
000
573 0 my %constants;
574 0 $constants{$_} = $value for @$names;
575 0 'MooX::Press'->patch_package( $caller, constant => \%constants );
576 }
577
578 5 return;
579 }
580  
581 0 ▶sub requires {
Subroutine requires: not called CC=4 SCAR=30.0
Pod undocumented
582 $THIS{CLASS_SPEC} && $THIS{CLASS_SPEC}{is_role}
583 0 ▶ or confess("`requires` used outside a role definition");
Branch: 1 branch
BranchTrueFalseTotal
$Zydeco::Lite::THIS{"CLASS_SPEC"} and $Zydeco::Lite::THIS{"CLASS_SPEC"}{"is_role"} or confess("`requires` used outside a role definition") 0 0 0
Condition0%0/3
$Zydeco::Lite::THIS{"CLASS_SPEC"} and $Zydeco::Lite::THIS{"CLASS_SPEC"}{"is_role"}
!ll&&!rl&&r
000
MC/DC0%0/2
$Zydeco::Lite::THIS{"CLASS_SPEC"} and $Zydeco::Lite::THIS{"CLASS_SPEC"}{"is_role"}
$Zydeco::Lite::THIS{"CLASS_SPEC"} $Zydeco::Lite::THIS{"CLASS_SPEC"}{"is_role"}
Truth table0%0/3
A and B
A= $Zydeco::Lite::THIS{"CLASS_SPEC"}B= $Zydeco::Lite::THIS{"CLASS_SPEC"}{"is_role"}
ABresult
0X0
100
111
584
585 #TODO: handle signatures
586 0 my ( @subnames ) = @_;
587
588 0 ▶ push @{ $THIS{CLASS_SPEC}{requires} ||= [] }, @subnames;
Condition0%0/2
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"requires"} ||= []
l!l
00
MC/DC0%0/1
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"requires"} ||= []
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"requires"}
Truth table0%0/2
A
A= $Zydeco::Lite::THIS{"CLASS_SPEC"}{"requires"}
Aresult
11
00
589
590 0 return;
591 }
592  
593 6 ▶sub toolkit {
Subroutine toolkit: called CC=6 SCAR=21.6
Pod undocumented
594 my $target = $THIS{CLASS_SPEC} || $THIS{APP_SPEC}
595 6 ▶ or confess('`toolkit` used outside app, class, or role definition');
Branch: 1 branch
BranchTrueFalseTotal
my $target = $Zydeco::Lite::THIS{"CLASS_SPEC"} || $Zydeco::Lite::THIS{"APP_SPEC"} or confess("`toolkit` used outside app, class, or role definition") 6 0 6
Condition33%1/3
$Zydeco::Lite::THIS{'CLASS_SPEC'} || $Zydeco::Lite::THIS{'APP_SPEC'}
l!l&&r!l&&!r
060
MC/DC0%0/2
$Zydeco::Lite::THIS{'CLASS_SPEC'} || $Zydeco::Lite::THIS{'APP_SPEC'}
$Zydeco::Lite::THIS{'CLASS_SPEC'} $Zydeco::Lite::THIS{'APP_SPEC'}
Truth table33%1/3
A || B
A= $Zydeco::Lite::THIS{'CLASS_SPEC'}B= $Zydeco::Lite::THIS{'APP_SPEC'}
ABresult
1X1
011
000
596
597 6 my ( $toolkit, @imports ) = @_;
598 6 ▶ confess('no toolkit given') unless $toolkit;
Branch: 1 branch
BranchTrueFalseTotal
unless $toolkit 0 6 6
599
600 6 $target->{toolkit} = $toolkit;
601 6 ▶ push @{ $target->{import} ||= [] }, map {
Condition50%1/2
$target->{"import"} ||= []
l!l
06
MC/DC0%0/1
$target->{"import"} ||= []
$target->{"import"}
Truth table50%1/2
A
A= $target->{"import"}
Aresult
11
00
602 0 ▶ /^::(.+)/ ? $1 : "${toolkit}X::$_";
Branch: 1 branch
BranchTrueFalseTotal
/^::(.+)/ ? : 0 0 0
603 } @imports;
604
605 6 return;
606 }
607  
608 3 ▶sub type_name {
Subroutine type_name: called CC=4 SCAR=15.6
Pod undocumented
609 $THIS{CLASS_SPEC}
610 3 ▶ or confess("`type_name` used outside a class or role definition");
Branch: 1 branch
BranchTrueFalseTotal
$Zydeco::Lite::THIS{"CLASS_SPEC"} or confess("`type_name` used outside a class or role definition") 3 0 3
611
612 3 ▶ @_==1 && ( Str|Undef )->check( $_[0] )
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 and (&Str() | &Undef())->check($_[0]) or confess("expected type name") 3 0 3
Condition33%1/3
@_ == 1 and (&Str() | &Undef())->check($_[0])
!ll&&!rl&&r
003
MC/DC0%0/2
@_ == 1 and (&Str() | &Undef())->check($_[0])
@_ == 1 (&Str() | &Undef())->check($_[0])
Truth table33%1/3
A and B
A= @_ == 1B= (&Str() | &Undef())->check($_[0])
ABresult
0X0
100
111
613 or confess("expected type name");
614
615 3 $THIS{CLASS_SPEC}{type_name} = shift;
616
617 3 return;
618 }
619  
620 3 ▶sub version {
Subroutine version: called CC=3 SCAR=12.5
Pod undocumented
621 my $target = $THIS{CLASS_SPEC} || $THIS{APP_SPEC}
622 3 ▶ or confess("`version` used outside app, class, or role definition");
Branch: 1 branch
BranchTrueFalseTotal
my $target = $Zydeco::Lite::THIS{"CLASS_SPEC"} || $Zydeco::Lite::THIS{"APP_SPEC"} or confess("`version` used outside app, class, or role definition") 3 0 3
Condition33%1/3
$Zydeco::Lite::THIS{'CLASS_SPEC'} || $Zydeco::Lite::THIS{'APP_SPEC'}
l!l&&r!l&&!r
030
MC/DC0%0/2
$Zydeco::Lite::THIS{'CLASS_SPEC'} || $Zydeco::Lite::THIS{'APP_SPEC'}
$Zydeco::Lite::THIS{'CLASS_SPEC'} $Zydeco::Lite::THIS{'APP_SPEC'}
Truth table33%1/3
A || B
A= $Zydeco::Lite::THIS{'CLASS_SPEC'}B= $Zydeco::Lite::THIS{'APP_SPEC'}
ABresult
1X1
011
000
623 3 $target->{version} = shift;
624 3 return;
625 }
626  
627 3 ▶sub authority {
Subroutine authority: called CC=3 SCAR=12.5
Pod undocumented
628 my $target = $THIS{CLASS_SPEC} || $THIS{APP_SPEC}
629 3 ▶ or confess("`authority` used outside app, class, or role definition");
Branch: 1 branch
BranchTrueFalseTotal
my $target = $Zydeco::Lite::THIS{"CLASS_SPEC"} || $Zydeco::Lite::THIS{"APP_SPEC"} or confess("`authority` used outside app, class, or role definition") 3 0 3
Condition33%1/3
$Zydeco::Lite::THIS{'CLASS_SPEC'} || $Zydeco::Lite::THIS{'APP_SPEC'}
l!l&&r!l&&!r
030
MC/DC0%0/2
$Zydeco::Lite::THIS{'CLASS_SPEC'} || $Zydeco::Lite::THIS{'APP_SPEC'}
$Zydeco::Lite::THIS{'CLASS_SPEC'} $Zydeco::Lite::THIS{'APP_SPEC'}
Truth table33%1/3
A || B
A= $Zydeco::Lite::THIS{'CLASS_SPEC'}B= $Zydeco::Lite::THIS{'APP_SPEC'}
ABresult
1X1
011
000
630 3 $target->{authority} = shift;
631 3 return;
632 }
633  
634 0 ▶sub overload {
Subroutine overload: not called CC=4 SCAR=30.0
Pod undocumented
635 $THIS{CLASS_SPEC}
636 0 ▶ or confess("`overload` used outside a class");
Branch: 1 branch
BranchTrueFalseTotal
$Zydeco::Lite::THIS{"CLASS_SPEC"} or confess("`overload` used outside a class") 0 0 0
637 $THIS{CLASS_SPEC}{is_role}
638 0 ▶ and confess("`overload` used in a role definition");
Branch: 1 branch
BranchTrueFalseTotal
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"is_role"} and confess("`overload` used in a role definition") 0 0 0
639
640 0 my %overload = @_;
641
642 $THIS{CLASS_SPEC}{overload} = +{
643 0 ▶ %{ $THIS{CLASS_SPEC}{overload} or {} },
Condition0%0/2
$Zydeco::Lite::THIS{'CLASS_SPEC'}{'overload'} || {}
l!l
00
MC/DC0%0/1
$Zydeco::Lite::THIS{'CLASS_SPEC'}{'overload'} || {}
$Zydeco::Lite::THIS{'CLASS_SPEC'}{'overload'}
Truth table0%0/2
A
A= $Zydeco::Lite::THIS{'CLASS_SPEC'}{'overload'}
Aresult
11
00
644 %overload,
645 };
646
647 0 return;
648 }
649  
650 3 ▶sub coerce {
Subroutine coerce: called CC=6 SCAR=19.3
Pod undocumented
651 $THIS{CLASS_SPEC}
652 3 ▶ or confess("`coerce` used outside a class or role");
Branch: 1 branch
BranchTrueFalseTotal
$Zydeco::Lite::THIS{"CLASS_SPEC"} or confess("`coerce` used outside a class or role") 3 0 3
653
654 3 ▶ my $type = _shift_type( Str|Object, @_ )
Branch: 1 branch
BranchTrueFalseTotal
my $type = &_shift_type(&Str() | &Object(), \@_) or confess("expected type to coerce from") 3 0 3
655 or confess("expected type to coerce from");
656 3 ▶ my $method = _shift_type( Str, @_ )
Branch: 1 branch
BranchTrueFalseTotal
my $method = &_shift_type(scalar &Str(), \@_) or confess("expected method name to coerce via") 3 0 3
657 or confess("expected method name to coerce via");
658 3 my $code = _shift_type( CodeRef, @_ );
659
660 3 ▶ push @{ $THIS{CLASS_SPEC}{coerce} ||= [] }, (
Branch: 1 branch
BranchTrueFalseTotal
$code ? : 3 0 3
Condition50%1/2
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"coerce"} ||= []
l!l
03
MC/DC0%0/1
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"coerce"} ||= []
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"coerce"}
Truth table50%1/2
A
A= $Zydeco::Lite::THIS{"CLASS_SPEC"}{"coerce"}
Aresult
11
00
661 $type,
662 $method,
663 $code ? $code : (),
664 );
665
666 3 return;
667 }
668  
669 6 ▶sub _handle_hook {
Subroutine _handle_hook: called CC=2 SCAR=7.0
670 6 my $package = $THIS{CLASS};
671 6 my %spec = %{ $THIS{CLASS_SPEC} };
672
673 6 my %remains = 'MooX::Press'->patch_package(
674 $package,
675 %spec,
676 );
677 confess( 'bad stuff in %s hook', $THIS{HOOK} )
678 6 ▶ if keys %remains;
Branch: 1 branch
BranchTrueFalseTotal
if keys %remains 0 6 6
679
680 6 return;
681  
682 }
683  
684 0 ▶sub begin (&) {
Subroutine begin: not called CC=4 SCAR=30.0
Pod undocumented
685 $THIS{CLASS_SPEC}
686 0 ▶ or confess("`begin` used outside a class or role definition");
Branch: 1 branch
BranchTrueFalseTotal
$Zydeco::Lite::THIS{"CLASS_SPEC"} or confess("`begin` used outside a class or role definition") 0 0 0
687
688 0 ▶ is_CodeRef( my $coderef = shift ) or confess('expected coderef');
Branch: 1 branch
BranchTrueFalseTotal
is_CodeRef(my $coderef = shift()) or confess("expected coderef") 0 0 0
689
690 0 ▶ push @{ $THIS{CLASS_SPEC}{begin} ||= [] }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/2
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"begin"} ||= []
l!l
00
MC/DC0%0/1
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"begin"} ||= []
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"begin"}
Truth table0%0/2
A
A= $Zydeco::Lite::THIS{"CLASS_SPEC"}{"begin"}
Aresult
11
00
691 0 local $THIS{CLASS} = $_[0];
692 0 local $THIS{CLASS_SPEC} = {};
693 0 local $THIS{HOOK} = 'begin';
694 0 $coderef->(@_);
695 0 return _handle_hook(@_);
696 0 };
697
698 0 return;
699 }
700  
701 0 ▶sub end (&) {
Subroutine end: not called CC=4 SCAR=30.0
Pod undocumented
702 $THIS{CLASS_SPEC}
703 0 ▶ or confess("`end` used outside a class or role definition");
Branch: 1 branch
BranchTrueFalseTotal
$Zydeco::Lite::THIS{"CLASS_SPEC"} or confess("`end` used outside a class or role definition") 0 0 0
704
705 0 ▶ is_CodeRef( my $coderef = shift ) or confess('expected coderef');
Branch: 1 branch
BranchTrueFalseTotal
is_CodeRef(my $coderef = shift()) or confess("expected coderef") 0 0 0
706
707 0 ▶ push @{ $THIS{CLASS_SPEC}{end} ||= [] }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/2
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"end"} ||= []
l!l
00
MC/DC0%0/1
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"end"} ||= []
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"end"}
Truth table0%0/2
A
A= $Zydeco::Lite::THIS{"CLASS_SPEC"}{"end"}
Aresult
11
00
708 0 local $THIS{CLASS} = $_[0];
709 0 local $THIS{CLASS_SPEC} = {};
710 0 local $THIS{HOOK} = 'end';
711 0 $coderef->(@_);
712 0 return _handle_hook(@_);
713 0 };
714
715 0 return;
716 }
717  
718 2 ▶sub before_apply (&) {
Subroutine before_apply: called CC=5 SCAR=16.9
Pod undocumented
719 $THIS{CLASS_SPEC} && $THIS{CLASS_SPEC}{is_role}
720 2 ▶ or confess("`before_apply` used outside a class or role definition");
Branch: 1 branch
BranchTrueFalseTotal
$Zydeco::Lite::THIS{"CLASS_SPEC"} and $Zydeco::Lite::THIS{"CLASS_SPEC"}{"is_role"} or confess("`before_apply` used outside a class or role definition") 2 0 2
Condition33%1/3
$Zydeco::Lite::THIS{"CLASS_SPEC"} and $Zydeco::Lite::THIS{"CLASS_SPEC"}{"is_role"}
!ll&&!rl&&r
002
MC/DC0%0/2
$Zydeco::Lite::THIS{"CLASS_SPEC"} and $Zydeco::Lite::THIS{"CLASS_SPEC"}{"is_role"}
$Zydeco::Lite::THIS{"CLASS_SPEC"} $Zydeco::Lite::THIS{"CLASS_SPEC"}{"is_role"}
Truth table33%1/3
A and B
A= $Zydeco::Lite::THIS{"CLASS_SPEC"}B= $Zydeco::Lite::THIS{"CLASS_SPEC"}{"is_role"}
ABresult
0X0
100
111
721
722 2 ▶ is_CodeRef( my $coderef = shift ) or confess('expected coderef');
Branch: 1 branch
BranchTrueFalseTotal
is_CodeRef(my $coderef = shift()) or confess("expected coderef") 2 0 2
723
724 2 require Role::Hooks;
725 2 ▶ push @{ $THIS{CLASS_SPEC}{before_apply} ||= [] }, sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
Condition50%1/2
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"before_apply"} ||= []
l!l
02
MC/DC0%0/1
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"before_apply"} ||= []
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"before_apply"}
Truth table50%1/2
A
A= $Zydeco::Lite::THIS{"CLASS_SPEC"}{"before_apply"}
Aresult
11
00
726 2 local $THIS{CLASS} = $_[1];
727 2 local $THIS{CLASS_SPEC} = {};
728 2 local $THIS{HOOK} = 'before_apply';
729 2 ▶ my $kind = 'Role::Hooks'->is_role($_[1]) ? 'role' : 'class';
Branch: 1 branch
BranchTrueFalseTotal
'Role::Hooks'->is_role($_[1]) ? : 0 2 2
730 2 $coderef->(@_, $kind);
731 2 return _handle_hook(@_);
732 2 };
733
734 2 return;
735 }
736  
737 3 ▶sub after_apply (&) {
Subroutine after_apply: called CC=5 SCAR=16.6
Pod undocumented
738 $THIS{CLASS_SPEC} && $THIS{CLASS_SPEC}{is_role}
739 3 ▶ or confess("`after_apply` used outside a class or role definition");
Branch: 1 branch
BranchTrueFalseTotal
$Zydeco::Lite::THIS{"CLASS_SPEC"} and $Zydeco::Lite::THIS{"CLASS_SPEC"}{"is_role"} or confess("`after_apply` used outside a class or role definition") 3 0 3
Condition33%1/3
$Zydeco::Lite::THIS{"CLASS_SPEC"} and $Zydeco::Lite::THIS{"CLASS_SPEC"}{"is_role"}
!ll&&!rl&&r
003
MC/DC0%0/2
$Zydeco::Lite::THIS{"CLASS_SPEC"} and $Zydeco::Lite::THIS{"CLASS_SPEC"}{"is_role"}
$Zydeco::Lite::THIS{"CLASS_SPEC"} $Zydeco::Lite::THIS{"CLASS_SPEC"}{"is_role"}
Truth table33%1/3
A and B
A= $Zydeco::Lite::THIS{"CLASS_SPEC"}B= $Zydeco::Lite::THIS{"CLASS_SPEC"}{"is_role"}
ABresult
0X0
100
111
740
741 3 ▶ is_CodeRef( my $coderef = shift ) or confess('expected coderef');
Branch: 1 branch
BranchTrueFalseTotal
is_CodeRef(my $coderef = shift()) or confess("expected coderef") 3 0 3
742
743 3 require Role::Hooks;
744 3 ▶ push @{ $THIS{CLASS_SPEC}{after_apply} ||= [] }, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
Condition50%1/2
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"after_apply"} ||= []
l!l
03
MC/DC0%0/1
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"after_apply"} ||= []
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"after_apply"}
Truth table50%1/2
A
A= $Zydeco::Lite::THIS{"CLASS_SPEC"}{"after_apply"}
Aresult
11
00
745 4 local $THIS{CLASS} = $_[1];
746 4 local $THIS{CLASS_SPEC} = {};
747 4 local $THIS{HOOK} = 'after_apply';
748 4 ▶ my $kind = 'Role::Hooks'->is_role($_[1]) ? 'role' : 'class';
Branch: 1 branch
BranchTrueFalseTotal
'Role::Hooks'->is_role($_[1]) ? : 1 3 4
749 4 $coderef->(@_, $kind);
750 4 return _handle_hook(@_);
751 3 };
752
753 3 return;
754 }
755  
756 13 true;
757  
758 __END__
« MooX/Press.pm ↑ Summary MooX/Press/Keywords.pm »