use all non-arch-specific non-core dirs in @INC
[scpubgit/Tak.git] / lib / Tak / ModuleSender.pm
CommitLineData
799b77f3 1package Tak::ModuleSender;
2
3use IO::All;
7725f2e3 4use List::Util qw(first);
5use Config;
799b77f3 6use Moo;
7
2791fd73 8with 'Tak::Role::Service';
9
7725f2e3 10has dir_list => (is => 'lazy');
11
12sub _build_dir_list {
13 my %core = map +($_ => 1), @Config{qw(privlibexp archlibexp)};
14 [ map io->dir($_), grep !/$Config{archname}$/, grep !$core{$_}, @INC ];
15}
16
799b77f3 17sub handle_source_for {
18 my ($self, $module) = @_;
7725f2e3 19 my $io = first { $_->exists } map $_->catfile($module), @{$self->dir_list};
20 unless ($io) {
2791fd73 21 die [ 'failure' ];
799b77f3 22 }
23 my $code = $io->all;
2791fd73 24 return $code;
799b77f3 25}
26
271;