make room for $VERSION after package declaration (newer [PkgVersion] requires it)
[p5sagit/Devel-REPL.git] / lib / Devel / REPL / Plugin / CompletionDriver / INC.pm
index 6b882dd..bf4e6c3 100644 (file)
@@ -1,8 +1,17 @@
+use strict;
+use warnings;
 package Devel::REPL::Plugin::CompletionDriver::INC;
+
 use Devel::REPL::Plugin;
+use Devel::REPL::Plugin::Completion;    # die early if cannot load
 use File::Next;
 use File::Spec;
-use namespace::clean -except => [ 'meta' ];
+use namespace::autoclean;
+
+sub BEFORE_PLUGIN {
+    my $self = shift;
+    $self->load_plugin('Completion');
+}
 
 around complete => sub {
   my $orig = shift;
@@ -58,7 +67,7 @@ around complete => sub {
   my @found;
 
   # most VCSes don't litter every single fucking directory with garbage. if you
-  # know of any other, just stick them in here. noone wants to complete
+  # know of any other, just stick them in here. No one wants to complete
   # Devel::REPL::Plugin::.svn
   my %ignored =
   (
@@ -71,7 +80,7 @@ around complete => sub {
   my $add_recursively;
   $add_recursively = sub {
     my ($path, $iteration, @more) = @_;
-    opendir((my $dirhandle), $path);
+    opendir((my $dirhandle), $path) || return;
     for (grep { !$ignored{$_} } readdir $dirhandle)
     {
       my $match = $_;
@@ -94,7 +103,7 @@ around complete => sub {
     }
   };
 
-  # look through all of 
+  # look through all of
   INC: for (@INC)
   {
     my $path = $_;
@@ -115,3 +124,15 @@ around complete => sub {
 
 1;
 
+__END__
+
+=head1 NAME
+
+Devel::REPL::Plugin::CompletionDriver::INC - Complete module names in use and require
+
+=head1 AUTHOR
+
+Shawn M Moore, C<< <sartak at gmail dot com> >>
+
+=cut
+