Remote/FromData.pm

filter: Statementstmt 88.8% 40 / 45 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 58.3% 7 / 12 Podpod 0.0% 0 / 2 totaltotal 78.6% 48 / 61 CC 4 SCAR 4.7
CC
4
Cov
87%
flush_loaded
3.0
import
2.1
__ANON__
1.1
CRAP 1.6
« Remote/Role/Connector.pm ↑ Summary Remote/GlobProxy.pm »
1 package Object::Remote::FromData;
2  
3 4 ▶use strictures 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use Object::Remote;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use Object::Remote::Logging qw ( :log );
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 our %Modules;
8 4 our %Not_Loaded_Yet;
9 4 our %Seen;
10  
11 4 ▶sub import {
Subroutine import: called CC=2 SCAR=7.6
12 4 my $target = caller;
13 4 ▶ log_trace { "import has been invoked by '$target' on " . __PACKAGE__ };
Subroutine __ANON__: not called CC=1 SCAR=1.2
14 4 ▶ return if $Seen{$target};
Branch: 1 branch
BranchTrueFalseTotal
if $Object::Remote::FromData::Seen{$target} 0 4 4
15 4 ▶ log_debug { "'$target' has not yet loaded " . __PACKAGE__ };
Subroutine __ANON__: not called CC=1 SCAR=1.2
16 4 $Seen{$target} = $Not_Loaded_Yet{$target} = 1;
17 }
18  
19 7 ▶sub flush_loaded {
Subroutine flush_loaded: called CC=3 SCAR=11.1
Pod undocumented
20 7 ▶ log_debug { "flushing the loaded classes" };
Subroutine __ANON__: not called CC=1 SCAR=1.2
21 7 foreach my $key (keys %Not_Loaded_Yet) {
22 4 ▶ log_trace { "flushing '$key'" };
Subroutine __ANON__: not called CC=1 SCAR=1.2
23 4 ▶ my $data_fh = do { no strict 'refs'; *{"${key}::DATA"} };
Subroutine BEGIN: called CC=1 SCAR=0.0
24 4 my $data = do { local $/; <$data_fh> };
25 4 my %modules = reverse(
26 $data =~ m/(^package ([^;]+);\n.*?(?:(?=^package)|\Z))/msg
27 );
28 4 $_ .= "\n1;\n" for values %modules;
29 4 @Modules{keys %modules} = values %modules;
30 4 delete $Not_Loaded_Yet{$key};
31 }
32 7 ▶ log_trace { "done flushing loaded classes" };
Subroutine __ANON__: not called CC=1 SCAR=1.2
33 }
34  
35 7 ▶sub find_module {
Subroutine find_module: called CC=1 SCAR=0.0
Pod undocumented
36 7 flush_loaded;
37 7 my ($module) = @_;
38 7 $module =~ s/\//::/g;
39 7 $module =~ s/\.pm$//;
40 7 return $Modules{$module};
41 }
42  
43 4 1;
« Remote/Role/Connector.pm ↑ Summary Remote/GlobProxy.pm »