File Coverage

blib/lib/Devel/REPL/Plugin/CompletionDriver/Turtles.pm
Criterion Covered Total %
statement 17 17 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 0 1 0.0
total 23 24 95.8


line stmt bran cond sub pod time code
1 2     2   2192 use strict;
  2         3  
  2         54  
2 2     2   7 use warnings;
  2         2  
  2         104  
3             package Devel::REPL::Plugin::CompletionDriver::Turtles;
4             # ABSTRACT: Complete Turtles-based commands
5              
6             our $VERSION = '1.003028';
7              
8 2     2   7 use Devel::REPL::Plugin;
  2         2  
  2         11  
9 2     2   6134 use Devel::REPL::Plugin::Completion; # die early if cannot load
  2         3  
  2         41  
10 2     2   6 use namespace::autoclean;
  2         3  
  2         12  
11              
12             sub BEFORE_PLUGIN {
13 1     1 0 3 my $self = shift;
14 1         5 $self->load_plugin('Completion');
15             }
16              
17             around complete => sub {
18             my $orig = shift;
19             my ($self, $text, $document) = @_;
20              
21             my $prefix = $self->default_command_prefix;
22             my $line_re = qr/^($prefix)(\w+)/;
23              
24             my @orig = $self->$orig($text, $document);
25              
26             if ( my ( $pre, $method ) = ( $text =~ $line_re ) ) {
27             my $filter = qr/^\Q$method/;
28             return (
29             @orig,
30             (
31             map { "$pre$_" }
32             grep { $_ =~ $filter }
33             map { /^expr?_command_(\w+)/ ? $1 : () }
34             map { $_->name }
35             $self->meta->get_all_methods
36             ),
37             );
38             } else {
39             return @orig;
40             }
41             };
42              
43             __PACKAGE__
44              
45             __END__
46              
47             =pod
48              
49             =encoding UTF-8
50              
51             =head1 NAME
52              
53             Devel::REPL::Plugin::CompletionDriver::Turtles - Complete Turtles-based commands
54              
55             =head1 VERSION
56              
57             version 1.003028
58              
59             =head1 SUPPORT
60              
61             Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Devel-REPL>
62             (or L<bug-Devel-REPL@rt.cpan.org|mailto:bug-Devel-REPL@rt.cpan.org>).
63              
64             There is also an irc channel available for users of this distribution, at
65             L<C<#devel> on C<irc.perl.org>|irc://irc.perl.org/#devel-repl>.
66              
67             =head1 AUTHOR
68              
69             Yuval Kogman E<lt>nothingmuch@woobling.orgE<gt>
70              
71             =head1 COPYRIGHT AND LICENCE
72              
73             This software is copyright (c) 2007 by Matt S Trout - mst (at) shadowcatsystems.co.uk (L<http://www.shadowcatsystems.co.uk/>).
74              
75             This is free software; you can redistribute it and/or modify it under
76             the same terms as the Perl 5 programming language system itself.
77              
78             =cut