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
« blib/lib/POE/Filter/Stackable.pm ↑ Summary blib/lib/POE/Filter/RecordBlock.pm »
1 # Copyrights and documentation are after __END__.
2  
3 package POE;
4  
5 460 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 414 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 408 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 193 $VERSION = '1.367'; # NOTE - Should be #.### (three decimal places)
10  
11 293 ▶use POE::Resource::Clock qw( monotime time walltime sleep mono2wall wall2mono );
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 sub import {
14 378 ▶ my $self = shift;
Subroutine import: called CC=9 SCAR=22.0
15  
16 378 my @loops = grep(/^(?:XS::)?Loop::/, @_);
17 378 my @sessions = grep(/^(Session|NFA)$/, @_);
18 372 my @modules = grep(!/^(Kernel|Session|NFA|(?:XS::)?Loop::[\w:]+)$/, @_);
19  
20 372 ▶ croak "can't use multiple event loops at once"
Branch: 1 branch
BranchTrueFalseTotal
if @loops > 1 1 349 350
21 if (@loops > 1);
22 371 ▶ croak "POE::Session and POE::NFA export conflicting constants"
Branch: 1 branch
BranchTrueFalseTotal
if scalar @sessions > 1 1 348 349
23 if scalar @sessions > 1;
24  
25 # If a session was specified, use that. Otherwise use Session.
26 353 ▶ if (@sessions) {
Branch: 1 branch
BranchTrueFalseTotal
if (@sessions) { } 3 345 348
27 8 unshift @modules, @sessions;
28 }
29 else {
30 350 unshift @modules, 'Session';
31 }
32  
33 353 my $package = caller();
34 353 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 353 my $loop = "";
42 348 ▶ if (@loops) {
Branch: 1 branch
BranchTrueFalseTotal
if (@loops) 3 345 348
43 3 $loop = "{ loop => '" . shift (@loops) . "' }";
44 }
45 348 my $code = "package $package; use POE::Kernel $loop;";
46 # warn $code;
47 273 ▶ eval $code;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
48 348 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 2 346 348
49 2 warn $@;
50 2 push @failed, "Kernel"
51 }
52 }
53  
54 # Load all the others.
55  
56 348 foreach my $module (@modules) {
57 1029 my $code = "package $package; use POE::$module;";
58 # warn $code;
59 241 ▶ 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 1029 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 1 1028 1029
61 1 warn $@;
62 1 push(@failed, $module);
63 }
64 }
65  
66 348 ▶ @failed and croak "could not import qw(" . join(' ', @failed) . ")";
Branch: 1 branch
BranchTrueFalseTotal
@failed and croak('could not import qw(' . join(" ", @failed) . ')') 3 345 348
67 }
68  
69 193 1;
70  
71 __END__
« blib/lib/POE/Filter/Stackable.pm ↑ Summary blib/lib/POE/Filter/RecordBlock.pm »