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