Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions lib/Babble/Plugin/Ellipsis.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package Babble::Plugin::Ellipsis;

use Moo;

sub transform_to_plain {
my ($self, $top) = @_;
$top->each_match_within(Statement => [
'\.\.\.'
] => sub {
my ($m) = @_;
$m->replace_text(q|die 'Unimplemented'|);
});
}

1;
__END__

=head1 NAME

Babble::Plugin::Ellipsis - Plugin for ellipsis / yada yada yada statement

=head1 SYNOPSIS

Converts usage of the ellipsis syntax from

...

to

die 'Unimplemented'

=head1 SEE ALSO

L<... syntax|Syntax::Construct/...>

=cut
24 changes: 24 additions & 0 deletions t/plugin-ellipsis.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use strictures 2;
use Test::More;
use Babble::Plugin::Ellipsis;
use Babble::Match;

my $el = Babble::Plugin::Ellipsis->new;

my @cand = (
# just ellipsis
[ 'sub foo {...}',
q|sub foo {die 'Unimplemented'}|, ],
# partial ellipsis
[ 'sub foo { f; ...; g; }',
q|sub foo { f; die 'Unimplemented'; g; }|, ],
);

foreach my $cand (@cand) {
my ($from, $to) = @$cand;
my $top = Babble::Match->new(top_rule => 'Document', text => $from);
$el->transform_to_plain($top);
is($top->text, $to, "${from}");
}

done_testing;