Remote/ModuleSender.pm

filter: Statementstmt 82.9% 34 / 41 Branchbran 87.5% 7 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 8 / 14 Podpod 0.0% 0 / 1 totaltotal 76.5% 49 / 64 CC 9 SCAR 10.5
CC
9
Cov
84%
source_for
5.1
source_for
5.1
__ANON__
1.3
CRAP 2.8
« Remote/Node.pm ↑ Summary Remote/Loop.pm »
1 package Object::Remote::ModuleSender;
2  
3 28 ▶use Object::Remote::Logging qw( :log :dlog );
Subroutine BEGIN: called CC=1 SCAR=0.0
4 14 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 14 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 14 ▶use List::Util qw(first);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 14 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 has dir_list => (is => 'lazy');
10  
11 7 ▶sub _build_dir_list {
Subroutine _build_dir_list: called CC=1 SCAR=2.0
12 my %core = map +($_ => 1), grep $_, @Config{
13 0 ▶ qw(privlibexp archlibexp vendorarchexp sitearchexp)
Subroutine _build_dir_list: not called CC=1 SCAR=2.0
14 };
15 0 ▶ DlogS_trace { "dir list built in ModuleSender: $_" } [ grep !$core{$_}, @INC ];
Subroutine __ANON__: not called CC=1 SCAR=2.6
16 }
17  
18 sub source_for {
19 15 ▶ my ($self, $module) = @_;
Subroutine source_for: called CC=5 SCAR=16.3
Pod undocumented
20 15 ▶ log_debug { "locating source for module '$module'" };
Subroutine __ANON__: not called CC=1 SCAR=1.2
21 15 ▶ if (my $find = Object::Remote::FromData->can('find_module')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $find = "Object::Remote::FromData"->can("find_module")) 7 8 15
22 7 ▶ if (my $source = $find->($module)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $source = &$find($module)) 6 1 7
23 6 ▶ Dlog_trace { "source of '$module' was found by Object::Remote::FromData" };
Subroutine __ANON__: not called CC=1 SCAR=1.2
24 6 return $source;
25 }
26 }
27 9 ▶ log_trace { "Searching for module in library directories" };
Subroutine __ANON__: not called CC=1 SCAR=1.2
28 13 ▶ my ($found) = first { -f $_ }
Subroutine __ANON__: called CC=1 SCAR=0.0
29 map File::Spec->catfile($_, $module),
30 9 @{$self->dir_list};
31 die "Can't locate ${module} in \@INC. (on remote host) dir_list contains:\n"
32 9 ▶ .join("\n", @{$self->dir_list})
Branch: 1 branch
BranchTrueFalseTotal
unless $found 1 8 9
33 unless $found;
34 8 ▶ log_debug { "found '$module' at '$found'" };
Subroutine __ANON__: not called CC=1 SCAR=1.2
35 8 ▶ open my $fh, '<', $found or die "Couldn't open ${found} for ${module}: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $found or die "Couldn't open $found for ${module}: $!" 8 0 8
36 8 return do { local $/; <$fh> };
37 }
38  
39 1;
« Remote/Node.pm ↑ Summary Remote/Loop.pm »