| 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
}
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
}
| |||||||||||||||||||||
| 33 | 8 | ▶ | load $package | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 58 | 0 | return decode $charset, $string; | |||||||||||||||||||
| 59 | } | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | __END__ | ||||||||||||||||||||