Gears.pm

filter: Statementstmt 78.2% 18 / 23 Branchbran 25.0% 2 / 8 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 6 / 9 Podpod 100% 5 / 5 totaltotal 66.0% 33 / 50 CC 6 SCAR 12.7
CC
6
Cov
65%
effective_charset
6.0
charset_encode
6.0
charset_decode
6.0
CRAP 3.6
« Gears/X.pm ↑ Summary Gears/Template.pm »
1 package Gears;
2 6 $Gears::VERSION = '0.105';
3 ###################################################
4 # ~~~~~~~~~~ We fear not our mortality ~~~~~~~~~~ #
5 # ~~~~ We'll serve to the best of our ability ~~~ #
6 # ~~~~~~ We give our lives to our masters ~~~~~~~ #
7 # ~~~~~~~~~ We vow to smite our enemies ~~~~~~~~~ #
8 ###################################################
9  
10 6 ▶use v5.40;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 # TODO: replace with load_module when it stabilizes
13 6 ▶use Module::Load qw(load);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 6 ▶use Encode qw(encode decode find_encoding);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 # TODO: replace with export_lexically when it stabilizes
17 6 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
18 6 our @EXPORT_OK = qw(
19 load_component
20 get_component_name
21 effective_charset
22 charset_encode
23 charset_decode
24 );
25  
26 175 ▶sub load_component ($package)
Subroutine load_component: called CC=3 SCAR=11.0
Pod documented
27 {
28 175 state %loaded;
29  
30 # only load package once for a given class name. Assume components have a
31 # new method (avoids Class::Inspector dependency)
32 175 ▶ return $loaded{$package} //= do {
Condition66%2/3
$loaded{$package} //= do { &load($package) unless $package->can("new"); $package }
l!l&&r!l&&!r
16780
MC/DC0%0/2
$loaded{$package} //= do { &load($package) unless $package->can("new"); $package }
$loaded{$package} do { &load($package) unless $package->can("new"); $package }
Truth table66%2/3
A //= B
A= $loaded{$package}B= do { &load($package) unless $package->can("new"); $package }
ABresult
1X1
011
000
33 8 ▶ load $package
Branch: 1 branch
BranchTrueFalseTotal
unless $package->can("new") 5 3 8
34 unless $package->can('new');
35 8 $package;
36 };
37 }
38  
39 5 ▶sub get_component_name ($package, $base)
Subroutine get_component_name: called CC=1 SCAR=0.0
Pod documented
40 {
41 5 return "${base}::${package}" =~ s{^.+\^}{}r;
42 }
43  
44 0 ▶sub effective_charset ($this_charset)
Subroutine effective_charset: not called CC=2 SCAR=17.9
Pod documented
45 {
46 0 ▶ return find_encoding($this_charset) ? $this_charset : undef;
Branch: 1 branch
BranchTrueFalseTotal
&find_encoding($this_charset) ? : 0 0 0
47 }
48  
49 0 ▶sub charset_encode ($charset, $string)
Subroutine charset_encode: not called CC=2 SCAR=17.9
Pod documented
50 {
51 0 ▶ return $string unless defined $charset;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $charset 0 0 0
52 0 return encode $charset, $string;
53 }
54  
55 0 ▶sub charset_decode ($charset, $string)
Subroutine charset_decode: not called CC=2 SCAR=17.9
Pod documented
56 {
57 0 ▶ return $string unless defined $charset;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $charset 0 0 0
58 0 return decode $charset, $string;
59 }
60  
61 __END__
« Gears/X.pm ↑ Summary Gears/Template.pm »