From: Matt S Trout Date: Thu, 17 Nov 2011 20:06:39 +0000 (+0000) Subject: use all non-arch-specific non-core dirs in @INC X-Git-Tag: v0.001002~14 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7725f2e3cacf9541f7ed27b9f9c7d8ce88efbce1;p=scpubgit%2FTak.git use all non-arch-specific non-core dirs in @INC --- diff --git a/lib/Tak/ModuleSender.pm b/lib/Tak/ModuleSender.pm index 9ecbe68..210d402 100644 --- a/lib/Tak/ModuleSender.pm +++ b/lib/Tak/ModuleSender.pm @@ -1,14 +1,23 @@ 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;