lib/TUI/toolkit.pm

filter: Statementstmt 77.3% 191 / 247 Branchbran 46.6% 42 / 90 Conditioncond 28.3% 15 / 53 MC/DCmcdc 5.8% 2 / 34 Subroutinesub 100% 59 / 59 Podpod 0.0% 0 / 7 totaltotal 63.0% 309 / 490 CC 71 SCAR 18.0
CC
71
Cov
64%
_my_moos_has
56.0
_around_hook
20.5
__ANON__
20.4
CRAP 6.0
« lib/TUI/Gadgets/PuzzleWindow.pm ↑ Summary lib/TUI/Menus/StatusDef.pm »
1 package TUI::toolkit;
2 # ABSTRACT: Unified OO facade for the TUI::Vision framework
3
4 953 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 953 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 619 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 183 our $VERSION = '0.08';
9 183 our $AUTHORITY = 'cpan:BRICKPOOL';
10
11 470 ▶use autodie::Scope::Guard ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 305 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13 292 ▶use Devel::StrictMode;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 281 ▶use Import::Into;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 262 ▶use Module::Loaded ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16 255 ▶use PerlX::Assert::PP;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 254 ▶use Symbol ();
Subroutine BEGIN: called CC=1 SCAR=0.0
18
19 249 ▶use Importer ();
Subroutine BEGIN: called CC=1 SCAR=0.0
20 183 our @EXPORT = qw(
21 true
22 false
23 assert
24 has
25 extends
26 signature
27 );
28
29 183 our @EXPORT_OK = qw(
30 is_Moo
31 is_Moos
32 is_Moose
33 is_UNIVERSAL
34 );
35
36 183 our %EXPORT_TAGS = (
37 all => [
38 @EXPORT,
39 @EXPORT_OK
40 ],
41
42 backend => [
43 @EXPORT_OK
44 ],
45
46 boolean => [qw(
47 true
48 false
49 )],
50
51 oo => [qw(
52 has
53 extends
54 )],
55
56 utils => [qw(
57 assert
58 signature
59 )],
60 );
61
62 249 ▶BEGIN { $] >= 5.010 ? require mro : require MRO::Compat }
Subroutine BEGIN: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
$] >= 5.01 ? : 183 0 183
63 244 ▶BEGIN { require Devel::GlobalDestruction unless $] >= 5.014 }
Subroutine BEGIN: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
unless $] >= "5.014" 0 183 183
64 244 ▶BEGIN { *PERL_ONLY = $ENV{PERL_ONLY} ? sub() { !!1 } : sub() { !!0 } }
Subroutine BEGIN: called CC=2 SCAR=7.6
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'PERL_ONLY'} ? : 0 183 183
65 3340 ▶BEGIN { sub XS_ASSERT () { eval q[ require PerlX::Assert ]; !$@ } }
Subroutine XS_ASSERT: called CC=1 SCAR=0.0
Pod undocumented
66 237 ▶BEGIN { sub XS_PARAMS () { eval q[ use Type::Params 2 ]; !$@ } }
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine XS_PARAMS: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Pod undocumented
67 3000 ▶BEGIN { sub SUB_UTIL () { eval q[ require Sub::Util ]; !$@ } }
Subroutine SUB_UTIL: called CC=1 SCAR=0.0
Pod undocumented
68
69 183 our $name;
70 237 ▶BEGIN {
Subroutine BEGIN: called CC=3 SCAR=11.0
71 244 $name = 'UNIVERSAL::Object'; # default if no other toolkit is found
72 243 foreach my $toolkit ( qw( Moose Moo Moos ) ) {
73 606 ▶ if ( Module::Loaded::is_loaded $toolkit ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&Module::Loaded::is_loaded($toolkit)) 2 544 546
74 62 $name = $toolkit;
75 61 last;
76 }
77 }
78
79 2551 ▶ sub is_Moo (){ $name eq 'Moo' }
Subroutine is_Moo: called CC=1 SCAR=0.0
Pod undocumented
80 2369 ▶ sub is_Moos (){ $name eq 'Moos' }
Subroutine is_Moos: called CC=1 SCAR=0.0
Pod undocumented
81 2373 ▶ sub is_Moose (){ $name eq 'Moose' }
Subroutine is_Moose: called CC=1 SCAR=0.0
Pod undocumented
82 2369 ▶ sub is_UNIVERSAL (){ $name eq 'UNIVERSAL::Object' }
Subroutine is_UNIVERSAL: called CC=1 SCAR=0.0
Pod undocumented
83 }
84
85 183 our %ADDED = ();
86
87 183 my %DEFAULT = (
88 Moose => [qw( extends with has before after around override super augment
89 inner blessed confess )],
90 Moo => [qw( extends with has before after around )],
91 Moos => [qw( extends with has blessed confess )],
92 'UNIVERSAL::Object' => [qw( extends has blessed confess )],
93 );
94
95 3537 ▶sub import {
Subroutine import: called CC=18 SCAR=29.3
96 3552 my ( $class, @imports ) = @_;
97 3552 my $caller = caller();
98 3552 ▶ return if $^H{ __PACKAGE__ . "/$caller" };
Branch: 1 branch
BranchTrueFalseTotal
if $^H{'TUI::toolkit' . "/$caller"} 5 3502 3507
99
100 # Resolve semantic imports
101 3547 my $exports = Importer->get( $class, @imports );
102 3544 my %want = map { $_ => 1 } keys %$exports;
103
104 # OO backend routing
105 3544 ▶ if ( my @syms = grep { $want{$_} } @{ $DEFAULT{$name} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@syms) = grep({$want{$_};} @{$DEFAULT{$TUI::toolkit::name};})) 2325 1177 3502
106
107 # Note: strict and warnings will also be enabled for caller
108 SWITCH: {
109 2367 ▶ is_Moose and do {
Branch: 1 branch
BranchTrueFalseTotal
&is_Moose() and do { require Moose; "Moose"->import::into($caller, @syms); last } 2 2323 2325
110 40 require Moose;
111 40 Moose->import::into( $caller, @syms );
112 40 last;
113 };
114 2361 ▶ is_Moo and do {
Branch: 1 branch
BranchTrueFalseTotal
&is_Moo() and do { require Moo; "Moo"->import::into($caller, @syms); last } 2 2321 2323
115 40 require Moo;
116 37 Moo->import::into( $caller, @syms );
117 37 last;
118 };
119 2356 ▶ is_Moos and do {
Branch: 1 branch
BranchTrueFalseTotal
&is_Moos() and do { require Moos; _my_moos_export($caller, @syms); _around_hook($caller, "has", \&TUI::toolkit::_my_moos_has) if $want{"has"}; _add_demolish("Moos::Object") unless $TUI::toolkit::ADDED{"DEMOLISH"}++; last } 0 2321 2321
120 31 require Moos;
121 31 _my_moos_export( $caller, @syms );
122 31 ▶ _around_hook( $caller, has => \&_my_moos_has ) if $want{has};
Branch: 1 branch
BranchTrueFalseTotal
if $want{"has"} 0 0 0
123 31 ▶ _add_demolish( 'Moos::Object' ) unless $ADDED{DEMOLISH}++;
Branch: 1 branch
BranchTrueFalseTotal
unless $TUI::toolkit::ADDED{"DEMOLISH"}++ 0 0 0
124 31 last;
125 };
126 2352 ▶ is_UNIVERSAL and do {
Branch: 1 branch
BranchTrueFalseTotal
&is_UNIVERSAL() and do { require TUI::toolkit::UO::Antlers; "TUI::toolkit::UO::Antlers"->import::into($caller, @syms); last } 2321 0 2321
127 2351 require TUI::toolkit::UO::Antlers;
128 2351 TUI::toolkit::UO::Antlers->import::into( $caller, @syms );
129 2351 last;
130 };
131 DEFAULT: {
132 29 warn "No backend for TUI::toolkit\n";
133 29 last;
134 }
135 } #/ SWITCH:
136
137 } #/ if ( my @syms = grep {...})
138
139 # boolean backend routing
140 3531 ▶ if ( $want{true} || $want{false} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($want{"true"} or $want{"false"}) 2662 840 3502
Condition66%2/3
$want{"true"} or $want{"false"}
l!l&&r!l&&!r
26620840
MC/DC50%1/2
$want{"true"} or $want{"false"}
$want{"true"} $want{"false"}
Truth table66%2/3
A or B
A= $want{"true"}B= $want{"false"}
ABresult
1X1
011
000
141 2691 require TUI::toolkit::boolean;
142 TUI::toolkit::boolean->import::into( $caller,
143 2691 grep { $want{$_} } qw( true false )
144 );
145 }
146
147 # assert routed to backend
148 3529 ▶ if ( $want{assert} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($want{"assert"}) 3284 218 3502
149 3311 ▶ if ( XS_ASSERT and not PERL_ONLY ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&XS_ASSERT() and !0) { } 3284 0 3284
Condition50%1/2
&XS_ASSERT() and
!ll
03284
MC/DC0%0/1
&XS_ASSERT() and
&XS_ASSERT()
Truth table50%1/2
A
A= &XS_ASSERT()
Aresult
00
11
150 # suppress void warnings for XS backend
151 3309 warnings->unimport( 'void' );
152 3309 PerlX::Assert->import::into( $caller, 'assert' );
153 }
154 else {
155 25 PerlX::Assert::PP->import::into( $caller );
156 }
157 }
158
159 # signature routed to backend
160 3527 ▶ if ( $want{signature} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($want{"signature"}) 3501 1 3502
161 3526 ▶ if ( XS_PARAMS and not PERL_ONLY ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&XS_PARAMS() and !0) { } 3501 0 3501
Condition50%1/2
&XS_PARAMS() and
!ll
03501
MC/DC0%0/1
&XS_PARAMS() and
&XS_PARAMS()
Truth table50%1/2
A
A= &XS_PARAMS()
Aresult
00
11
162 3526 Type::Params->import::into( $caller, 'signature' );
163 }
164 else {
165 1 TUI::toolkit::Params->import::into( $caller, 'signature' );
166 }
167 }
168
169 # Add a dump method to the class if it doesn't already have one
170 3531 ▶ $^H{ __PACKAGE__ . "/$caller" } = autodie::Scope::Guard->new(sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
171 3503 ▶ _add_dump( $caller ) unless $caller->can( 'dump' );
Branch: 1 branch
BranchTrueFalseTotal
unless $caller->can("dump") 2947 555 3502
172 3503 });
173
174 # exports living in this module
175 Importer->import_into( $class, $caller, $_ )
176 3503 for grep { $want{$_} } @{ $EXPORT_TAGS{backend} };
177 } #/ sub import
178
179 33 ▶sub unimport {
Subroutine unimport: called CC=9 SCAR=22.7
180 5 my $caller = caller();
181 5 ▶ return unless $^H{ __PACKAGE__ . "/$caller" };
Branch: 1 branch
BranchTrueFalseTotal
unless $^H{'TUI::toolkit' . "/$caller"} 1 3 4
182
183 4 ▶ if ( XS_PARAMS and not PERL_ONLY ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&XS_PARAMS() and !0) { } 3 0 3
Condition50%1/2
&XS_PARAMS() and
!ll
03
MC/DC0%0/1
&XS_PARAMS() and
&XS_PARAMS()
Truth table50%1/2
A
A= &XS_PARAMS()
Aresult
00
11
184 4 Type::Params->unimport::out_of( $caller );
185 }
186 else {
187 1 TUI::toolkit::Params->unimport::out_of( $caller );
188 }
189 4 ▶ if ( XS_ASSERT and not PERL_ONLY ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&XS_ASSERT() and !0) { } 3 0 3
Condition50%1/2
&XS_ASSERT() and
!ll
03
MC/DC0%0/1
&XS_ASSERT() and
&XS_ASSERT()
Truth table50%1/2
A
A= &XS_ASSERT()
Aresult
00
11
190 4 PerlX::Assert->unimport::out_of( $caller );
191 }
192 else {
193 1 PerlX::Assert::PP->unimport::out_of( $caller );
194 }
195 4 TUI::toolkit::boolean->unimport::out_of( $caller );
196 4 ▶ if ( is_Moose ) {
Branch: 3 branches
BranchTrueFalseTotal
if (&is_Moose()) { } 1 2 3
elsif (&is_Moo()) { } 0 2 2
elsif (&is_Moos()) { } 0 2 2
197 2 Moose->unimport::out_of( $caller );
198 }
199 elsif ( is_Moo ) {
200 1 Moo->unimport::out_of( $caller );
201 }
202 elsif ( is_Moos ) {
203 1 Moos->unimport::out_of( $caller );
204 }
205
206 4 $^H{ __PACKAGE__ . "/$caller" } = 0;
207 }
208
209 # Split fully qualified name into package and symbol
210 2975 ▶sub _split_fqn { # ($pkg, $sym) = _split_fqn($fqn)
Subroutine _split_fqn: called CC=5 SCAR=18.9
211 2949 my ( $fqn ) = @_;
212 2949 ▶ assert ( defined $fqn && !ref $fqn );
Condition33%1/3
defined $fqn && !ref($fqn)
!ll&&!rl&&r
002948
MC/DC0%0/2
defined $fqn && !ref($fqn)
defined $fqn !ref($fqn)
Truth table33%1/3
A && not(B)
A= defined $fqnB= !ref($fqn)
ABresult
0X0
100
111
213 2949 ▶ my ( $pkg, $sym ) = $fqn =~ m/^(.*)::([^:]+)\z/
Branch: 1 branch
BranchTrueFalseTotal
$fqn =~ /^(.*)::([^:]+)\z/ ? : 2948 0 2948
214 ? ( $1, $2 )
215 : ( 'main', $fqn );
216 2949 ▶ $pkg = 'main' if !defined( $pkg ) || $pkg eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $pkg or $pkg eq "" 0 2948 2948
Condition33%1/3
not defined $pkg or $pkg eq ""
l!l&&r!l&&!r
002948
MC/DC0%0/2
not defined $pkg or $pkg eq ""
not defined $pkg $pkg eq ""
Truth table33%1/3
not(A) or B
A= not defined $pkgB= $pkg eq ""
ABresult
1X1
011
000
217 2949 return ( $pkg, $sym );
218 }
219
220 # Get the symbol table hash for a package, or undef if it does not exist
221 2973 ▶sub _get_package_stash { # \%stash|undef ($pkg)
Subroutine _get_package_stash: called CC=8 SCAR=21.3
222 2949 my ( $pkg ) = @_;
223 2949 ▶ assert ( defined $pkg && !ref $pkg );
Condition33%1/3
defined $pkg && !ref($pkg)
!ll&&!rl&&r
002948
MC/DC0%0/2
defined $pkg && !ref($pkg)
defined $pkg !ref($pkg)
Truth table33%1/3
A && not(B)
A= defined $pkgB= !ref($pkg)
ABresult
0X0
100
111
224
225 2949 ▶ return \%:: if $pkg eq '' || $pkg eq 'main';
Branch: 1 branch
BranchTrueFalseTotal
if $pkg eq "" or $pkg eq "main" 9 2939 2948
Condition66%2/3
$pkg eq "" or $pkg eq "main"
l!l&&r!l&&!r
092939
MC/DC50%1/2
$pkg eq "" or $pkg eq "main"
$pkg eq "" $pkg eq "main"
Truth table66%2/3
A or B
A= $pkg eq ""B= $pkg eq "main"
ABresult
1X1
011
000
226
227 2940 $pkg =~ s/::\z//;
228 2940 my @parts = split /::/, $pkg;
229 2940 my $stash = \%::; # main::
230
231 242 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
232 2940 for my $p (@parts) {
233 8915 ▶ return undef if $p eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $p eq "" 0 8914 8914
234 8915 my $key = "${p}::";
235 8915 ▶ return undef if !exists $stash->{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $stash->{$key} 0 8914 8914
236 8915 my $glob = $stash->{$key};
237 8915 ▶ my $next = *{$glob}{HASH} or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $next = *{$glob;}{"HASH"} or return undef 8914 0 8914
238 8915 $stash = $next;
239 }
240 2940 return $stash;
241 }
242
243 # Adds a new method to an existing class
244 2973 ▶sub _create_method { # void ($class, $name, \&code)
Subroutine _create_method: called CC=6 SCAR=19.2
245 2949 my ( $class, $name, $code ) = @_;
246 2949 ▶ assert ( defined $class and !ref $class );
Condition33%1/3
defined $class && !ref($class)
!ll&&!rl&&r
002948
MC/DC0%0/2
defined $class && !ref($class)
defined $class !ref($class)
Truth table33%1/3
A && not(B)
A= defined $classB= !ref($class)
ABresult
0X0
100
111
247 2949 ▶ assert ( defined $name and !ref $name );
Condition33%1/3
defined $name && !ref($name)
!ll&&!rl&&r
002948
MC/DC0%0/2
defined $name && !ref($name)
defined $name !ref($name)
Truth table33%1/3
A && not(B)
A= defined $nameB= !ref($name)
ABresult
0X0
100
111
248 2949 ▶ assert ( defined $code and ref $code eq 'CODE' );
Condition33%1/3
defined $code && ref $code eq 'CODE'
!ll&&!rl&&r
002948
MC/DC0%0/2
defined $code && ref $code eq 'CODE'
defined $code ref $code eq 'CODE'
Truth table33%1/3
A && B
A= defined $codeB= ref $code eq 'CODE'
ABresult
0X0
100
111
249
250 # Build fully-qualified name (keeps $name if already qualified)
251 2949 my $fqn = Symbol::qualify( $name, $class );
252 2949 my ( $pkg, $sym ) = _split_fqn( $fqn );
253
254 2949 my $stash = _get_package_stash( $pkg );
255 2949 ▶ unless ( defined $stash ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $stash) 0 2948 2948
256 1 warn "Cannot add method $fqn to non-existing package $pkg\n";
257 1 return;
258 }
259
260 2949 ▶ $code = Sub::Util::set_subname( $fqn, $code ) if SUB_UTIL; # nicer traces
Branch: 1 branch
BranchTrueFalseTotal
if &SUB_UTIL() 2948 0 2948
261 2949 my $glob = Symbol::qualify_to_ref( $sym, $pkg );
262 2949 *{$glob} = $code; # warns if redefining an existing method
263 2949 return;
264 } #/ sub _create_method
265
266 # An around method modifier without checking of an existing method
267 1 ▶sub _around_hook { # void ($class, $name, \&code)
Subroutine _around_hook: called CC=7 SCAR=30.2
268 1 my ( $class, $name, $code ) = @_;
269 1 ▶ assert ( defined $class and !ref $class );
Condition0%0/3
defined $class && !ref($class)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $class && !ref($class)
defined $class !ref($class)
Truth table0%0/3
A && not(B)
A= defined $classB= !ref($class)
ABresult
0X0
100
111
270 1 ▶ assert ( defined $name and !ref $name );
Condition0%0/3
defined $name && !ref($name)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $name && !ref($name)
defined $name !ref($name)
Truth table0%0/3
A && not(B)
A= defined $nameB= !ref($name)
ABresult
0X0
100
111
271 1 ▶ assert ( defined $code and ref $code eq 'CODE' );
Condition0%0/3
defined $code && ref $code eq 'CODE'
!ll&&!rl&&r
000
MC/DC0%0/2
defined $code && ref $code eq 'CODE'
defined $code ref $code eq 'CODE'
Truth table0%0/3
A && B
A= defined $codeB= ref $code eq 'CODE'
ABresult
0X0
100
111
272
273 1 my $fqn = Symbol::qualify( $name, $class ); # builds full name
274 1 my ( $pkg, $sym ) = _split_fqn( $fqn );
275
276 1 my $stash = _get_package_stash( $pkg );
277 1 ▶ unless ( defined $stash ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $stash) 0 0 0
278 1 warn "Cannot hook method $fqn from non-existing package $pkg\n";
279 1 return;
280 }
281
282 # glob ref for installation
283 1 my $glob = Symbol::qualify_to_ref( $sym, $pkg );
284 0 my $orig = *{$glob}{CODE};
285 0 ▶ unless ( $orig ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($orig) 0 0 0
286 0 warn "Cannot wrap non-existing method $fqn\n";
287 0 return;
288 }
289
290 0 ▶ my $wrapper = sub { $code->( $orig, @_ ) };
Subroutine __ANON__: called CC=1 SCAR=6.9
291 0 ▶ $wrapper = Sub::Util::set_subname( $fqn, $wrapper ) if SUB_UTIL;
Branch: 1 branch
BranchTrueFalseTotal
if &SUB_UTIL() 0 0 0
292
293 241 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
294 0 *{$glob} = $wrapper;
295 0 return;
296 } #/ sub _around_hook
297
298 # We are I<patching> the Moos C<has> arguments to support C<< is => 'bare' >>
299 # and C<< default => scalar|ref >>
300 1 ▶sub _my_moos_has { # $return (\&orig, $self, @_)
Subroutine _my_moos_has: called CC=7 SCAR=40.3
301 0 my ( $orig, $self, %args ) = @_;
302 0 ▶ if ( exists $args{is} && $args{is} eq 'bare' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"is"} and $args{"is"} eq "bare") 0 0 0
Condition0%0/3
exists $args{"is"} and $args{"is"} eq "bare"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $args{"is"} and $args{"is"} eq "bare"
exists $args{"is"} $args{"is"} eq "bare"
Truth table0%0/3
A and B
A= exists $args{"is"}B= $args{"is"} eq "bare"
ABresult
0X0
100
111
303 0 $args{is} = 'rw';
304 0 $args{_skip_setup} = 1;
305 }
306 0 ▶ if ( exists $args{default} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"default"}) 0 0 0
307 0 $args{default} = do {
308 0 my $d = $args{default};
309 0 my $r = ref $d;
310 0 ▶ $r eq 'HASH' ? sub { +{%$d} } :
Subroutine __ANON__: called CC=1 SCAR=6.9
311 0 ▶ $r eq 'ARRAY' ? sub { [@$d] } :
Subroutine __ANON__: called CC=1 SCAR=6.9
312 $r eq 'CODE' ? $d :
313 0 ▶ sub { $d } ;
Subroutine __ANON__: called CC=1 SCAR=6.9
Branch: 3 branches
BranchTrueFalseTotal
$r eq 'HASH' ? : 0 0 0
$r eq 'ARRAY' ? : 0 0 0
$r eq 'CODE' ? : 0 0 0
314 };
315 }
316 0 return $self->$orig( %args );
317 } #/ sub _my_moos_has
318
319 # Import only what is requested and not the Moos default
320 1 ▶sub _my_moos_export { # void ($caller, @names)
Subroutine _my_moos_export: called CC=3 SCAR=20.0
321 0 my ( $caller, @names ) = @_;
322 {
323 0 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.2
324 0 ▶ local *Moos::_export = sub { };
Subroutine __ANON__: called CC=1 SCAR=6.9
325 0 Moos->import::into( $caller );
326 }
327 0 my $meta = Moos::Meta::Class->initialize( $caller );
328 0 for my $name ( @names ) {
329 0 ▶ my $code = Moos->can( $name )
Branch: 1 branch
BranchTrueFalseTotal
my $code = "Moos"->can($name) or Carp::croak("Moos has no keyword '${name}'") 0 0 0
330 or Carp::croak "Moos has no keyword '$name'";
331
332 0 Moos::_export( $caller, $name => $code, $meta );
333 }
334 0 return;
335 }
336
337 # Provide an equivalent dump method using L<Data::Dumper>, unless one already
338 # exists
339 2948 ▶sub _add_dump { # void ($target)
Subroutine _add_dump: called CC=2 SCAR=9.8
340 2947 my ( $proto ) = @_;
341 2947 assert ( $proto );
342 2947 ▶ my $target = ref $proto || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
029470
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
343 _create_method( $target,
344 1 ▶ dump => sub {
Subroutine __ANON__: called CC=2 SCAR=13.0
Subroutine dump: called CC=2 SCAR=13.0
345 240 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
346 0 my $self = shift;
347 0 require Data::Dumper;
348 0 local $Data::Dumper::Sortkeys = 1;
349 0 ▶ local $Data::Dumper::Maxdepth = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
350 0 my $str = Data::Dumper::Dumper $self;
351 0 $str =~ s/(^|\s)\$VAR\d+\b/$1'$self'/g;
352 0 return $str;
353 }
354 2947 );
355 2947 return;
356 }
357
358 # Provide DEMOLISH if it is not available
359 1 ▶sub _add_demolish { # void ($target)
Subroutine _add_demolish: called CC=3 SCAR=22.7
360 0 my ( $proto ) = @_;
361 0 assert ( $proto );
362 0 ▶ my $target = ref $proto || $proto;
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
363 0 ▶ return if $target->can( 'DESTROY' );
Branch: 1 branch
BranchTrueFalseTotal
if $target->can("DESTROY") 0 0 0
364 _create_method( $target,
365 1 ▶ DESTROY => sub {
Subroutine __ANON__: called CC=5 SCAR=30.1
366 0 my $self = shift;
367 0 ▶ my $class = ref $self || $self;
Condition0%0/3
ref $self || $self
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table0%0/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
368
369 0 ▶ my $in_global_destruction = defined ${^GLOBAL_PHASE}
Branch: 1 branch
BranchTrueFalseTotal
defined ${^GLOBAL_PHASE} ? : 0 0 0
370 ? ${^GLOBAL_PHASE} eq 'DESTRUCT'
371 : Devel::GlobalDestruction::in_global_destruction();
372
373 # Call all DEMOLISH methods starting with the derived classes.
374 0 foreach ( @{ mro::get_linear_isa( $class ) } ) {
375 237 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
376 0 my $demolish = *{$_.'::DEMOLISH'}{CODE};
377 0 ▶ next unless $demolish;
Branch: 1 branch
BranchTrueFalseTotal
unless $demolish 0 0 0
378 0 $self->$demolish( $in_global_destruction )
379 }
380 0 return;
381 }
382 0 );
383 0 return;
384 }
385
386 183 1
387
388 __END__
« lib/TUI/Gadgets/PuzzleWindow.pm ↑ Summary lib/TUI/Menus/StatusDef.pm »