blib/lib/POE.pm

filter: Statementstmt 100% 47 / 47 Branchbran 100% 14 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod n/a totaltotal 100% 71 / 71 CC 9 SCAR 11.2
CC
9
Cov
100%
import
9.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.1
« mylib/MyOtherFreezer.pm ↑ Summary blib/lib/POE/Filter/RecordBlock.pm »
1 # Copyrights and documentation are after __END__.
2  
3 package POE;
4  
5 463 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 417 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 411 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 194 $VERSION = '1.370'; # NOTE - Should be #.### (three decimal places)
10  
11 295 ▶use POE::Resource::Clock qw( monotime time walltime sleep mono2wall wall2mono );
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 380 ▶sub import {
Subroutine import: called CC=9 SCAR=22.0
14 380 my $self = shift;
15  
16 380 my @loops = grep(/^(?:XS::)?Loop::/, @_);
17 380 my @sessions = grep(/^(Session|NFA)$/, @_);
18 374 my @modules = grep(!/^(Kernel|Session|NFA|(?:XS::)?Loop::[\w:]+)$/, @_);
19  
20 374 ▶ croak "can't use multiple event loops at once"
Branch: 1 branch
BranchTrueFalseTotal
if @loops > 1 1 351 352
21 if (@loops > 1);
22 373 ▶ croak "POE::Session and POE::NFA export conflicting constants"
Branch: 1 branch
BranchTrueFalseTotal
if scalar @sessions > 1 1 350 351
23 if scalar @sessions > 1;
24  
25 # If a session was specified, use that. Otherwise use Session.
26 355 ▶ if (@sessions) {
Branch: 1 branch
BranchTrueFalseTotal
if (@sessions) { } 4 346 350
27 9 unshift @modules, @sessions;
28 }
29 else {
30 351 unshift @modules, 'Session';
31 }
32  
33 355 my $package = caller();
34 355 my @failed;
35  
36 # Load POE::Kernel in the caller's package. This is separate
37 # because we need to push POE::Loop classes through POE::Kernel's
38 # import().
39  
40 {
41 355 my $loop = "";
42 350 ▶ if (@loops) {
Branch: 1 branch
BranchTrueFalseTotal
if (@loops) 3 347 350
43 3 $loop = "{ loop => '" . shift (@loops) . "' }";
44 }
45 350 my $code = "package $package; use POE::Kernel $loop;";
46 # warn $code;
47 275 ▶ eval $code;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
48 350 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 1 349 350
49 1 warn $@;
50 1 push @failed, "Kernel"
51 }
52 }
53  
54 # Load all the others.
55  
56 350 foreach my $module (@modules) {
57 1037 my $code = "package $package; use POE::$module;";
58 # warn $code;
59 242 ▶ eval($code);
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
60 1037 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 1 1036 1037
61 1 warn $@;
62 1 push(@failed, $module);
63 }
64 }
65  
66 350 ▶ @failed and croak "could not import qw(" . join(' ', @failed) . ")";
Branch: 1 branch
BranchTrueFalseTotal
@failed and croak('could not import qw(' . join(" ", @failed) . ')') 2 348 350
67 }
68  
69 194 1;
70  
71 __END__
« mylib/MyOtherFreezer.pm ↑ Summary blib/lib/POE/Filter/RecordBlock.pm »