| 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
| |||||||||||
| 22 | 7 | ▶ | if (my $source = $find->($module)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 36 | 8 | return do { local $/; <$fh> }; | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 1; | ||||||||||