package Tak::ModuleSender;
use IO::All;
+use List::Util qw(first);
+use Config;
use Moo;
with 'Tak::Role::Service';
+has dir_list => (is => 'lazy');
+
+sub _build_dir_list {
+ my %core = map +($_ => 1), @Config{qw(privlibexp archlibexp)};
+ [ map io->dir($_), grep !/$Config{archname}$/, grep !$core{$_}, @INC ];
+}
+
sub handle_source_for {
my ($self, $module) = @_;
- my $io = io->dir("$ENV{HOME}/perl5/lib/perl5")->catfile($module);
- unless ($io->exists) {
+ my $io = first { $_->exists } map $_->catfile($module), @{$self->dir_list};
+ unless ($io) {
die [ 'failure' ];
}
my $code = $io->all;