lib/Dancer/ModuleLoader.pm

filter: Statementstmt 100% 44 / 44 Branchbran 50.0% 11 / 22 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 9 / 9 Podpod 100% 5 / 5 totaltotal 84.3% 70 / 83 CC 14 SCAR 15.2
CC
14
Cov
82%
load_with_params
9.1
require
4.0
use_lib
3.1
CRAP 4.6
« lib/Dancer/Error.pm ↑ Summary lib/Dancer/Route/Cache.pm »
1 package Dancer::ModuleLoader;
2 257 our $AUTHORITY = 'cpan:SUKRIA';
3 #ABSTRACT: dynamic module loading helpers for Dancer core components
4 257 $Dancer::ModuleLoader::VERSION = '1.3522';
5 # Abstraction layer for dynamic module loading
6  
7 257 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 257 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 257 ▶use Module::Runtime qw/ use_module /;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 964 ▶sub load {
Subroutine load: called CC=2 SCAR=6.9
Pod documented
12 964 my ($class, $module, $version) = @_;
13  
14 964 my ($res, $error) = $class->require($module, $version);
15 964 ▶ return wantarray ? ($res, $error) : $res;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 512 452 964
16 }
17  
18 1004 ▶sub require {
Subroutine require: called CC=4 SCAR=13.9
Pod documented
19 1004 my ($class, $module, $version) = @_;
20 1004 ▶ eval { defined $version ? use_module( $module, $version )
Branch: 3 branches
BranchTrueFalseTotal
eval { do { defined $version ? &use_module($module, $version) : &use_module($module) } } or return wantarray ? (0, $@) : 0 987 17 1004
defined $version ? : 49 955 1004
wantarray ? : 17 0 17
21 : use_module( $module ) }
22 or return wantarray ? (0, $@) : 0;
23 987 return 1; #success
24 }
25  
26 39 ▶sub load_with_params {
Subroutine load_with_params: called CC=7 SCAR=22.0
Pod documented
27 39 my ($class, $module, @args) = @_;
28 39 my ($res, $error) = $class->require($module);
29 39 ▶ $res or return wantarray ? (0, $error) : 0;
Branch: 2 branches
BranchTrueFalseTotal
$res or return wantarray ? (0, $error) : 0 39 0 39
wantarray ? : 0 0 0
30  
31 # From perlfunc : If no "import" method can be found then the call is
32 # skipped, even if there is an AUTOLOAD method.
33 39 ▶ if ($module->can('import')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($module->can("import")) 39 0 39
34  
35 # bump Exporter Level to import symbols in the caller
36 39 ▶ local $Exporter::ExportLevel = ($Exporter::ExportLevel || 0) + 1;
Condition50%1/2
$Exporter::ExportLevel || 0
l!l
039
MC/DC0%0/1
$Exporter::ExportLevel || 0
$Exporter::ExportLevel
Truth table50%1/2
A
A= $Exporter::ExportLevel
Aresult
11
00
37 39 local $@;
38 39 eval { $module->import(@args) };
39 39 my $error = $@;
40 39 ▶ $error and return wantarray ? (0, $error) : 0;
Branch: 2 branches
BranchTrueFalseTotal
$error and return wantarray ? (0, $error) : 0 0 39 39
wantarray ? : 0 0 0
41 }
42 39 return 1;
43 }
44  
45 194 ▶sub use_lib {
Subroutine use_lib: called CC=3 SCAR=11.3
Pod documented
46 194 my ($class, @args) = @_;
47 257 ▶ use lib;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 194 local $@;
49 194 lib->import(@args);
50 194 my $error = $@;
51 194 ▶ $error and return wantarray ? (0, $error) : 0;
Branch: 2 branches
BranchTrueFalseTotal
$error and return wantarray ? (0, $error) : 0 0 194 194
wantarray ? : 0 0 0
52 194 return 1;
53 }
54  
55 488 ▶sub class_from_setting {
Subroutine class_from_setting: called CC=2 SCAR=6.9
Pod documented
56 488 my ($self, $namespace, $setting) = @_;
57  
58 488 my $class = '';
59 488 for my $token (split /_/, $setting) {
60 489 $class .= ucfirst($token);
61 }
62 488 return "${namespace}::${class}";
63 }
64  
65 257 1;
66  
67 __END__
« lib/Dancer/Error.pm ↑ Summary lib/Dancer/Route/Cache.pm »