From: nothingmuch Date: Tue, 6 May 2008 02:06:01 +0000 (+0000) Subject: Add CompletionDriver::Turtles X-Git-Tag: v1.003015~122 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FDevel-REPL.git;a=commitdiff_plain;h=203774462f847ecce8af8b115fd370dde4572da0 Add CompletionDriver::Turtles git-svn-id: http://dev.catalyst.perl.org/repos/bast/trunk/Devel-REPL@4340 bd8105ee-0ff8-0310-8827-fb3f25b6796d --- diff --git a/lib/Devel/REPL/Plugin/CompletionDriver/Turtles.pm b/lib/Devel/REPL/Plugin/CompletionDriver/Turtles.pm new file mode 100644 index 0000000..940bbff --- /dev/null +++ b/lib/Devel/REPL/Plugin/CompletionDriver/Turtles.pm @@ -0,0 +1,41 @@ +#!/usr/bin/perl + +package Devel::REPL::Plugin::CompletionDriver::Turtles; +use Devel::REPL::Plugin; + +with qw( + Devel::REPL::Plugin::Completion + Devel::REPL::Plugin::Turtles +); + +around complete => sub { + my $orig = shift; + my ($self, $text, $document) = @_; + + my $prefix = $self->default_command_prefix; + my $line_re = qr/^($prefix)(\w+)/; + + my @orig = $self->$orig($text, $document); + + if ( my ( $pre, $method ) = ( $text =~ $line_re ) ) { + my $filter = qr/^\Q$method/; + return ( + @orig, + ( + map { "$pre$_" } + grep { $_ =~ $filter } + map { /^expr?_command_(\w+)/ ? $1 : () } + map { $_->{name} } + $self->meta->compute_all_applicable_methods + ), + ); + } else { + return @orig; + } +}; + +__PACKAGE__ + +__END__ + +