Devel-Examine-Subs
view release on metacpan or search on metacpan
lib/Devel/Examine/Subs/Engine.pm view on Meta::CPAN
push @processed, $sub->name;
my $start_line = $sub->start;
my $end_line = $sub->end;
$start_line += $added_lines;
$end_line += $added_lines;
my $line_num = 0;
my $new_lines = 0; # don't search added lines
for my $line (@file_contents){
$line_num++;
if ($line_num < $start_line){
next;
}
if ($line_num > $end_line){
last;
}
if ($line =~ /$search/ && ! $new_lines){
my $location = $line_num;
my $indent = '';
if (! $p->{no_indent}){
if ($line =~ /^(\s+)/ && $1){
$indent = $1;
}
}
for (@$code){
splice @file_contents, $location++, 0, $indent . $_;
$new_lines++;
$added_lines++;
}
# stop injecting after N search finds
$num_injects--;
if ($num_injects == 0){
last;
}
}
$new_lines-- if $new_lines != 0;
}
}
$p->{write_file_contents} = \@file_contents;
return \@processed;
};
}
sub _vim_placeholder {1;}
1;
__END__
=head1 NAME
Devel::Examine::Subs::Engine - Provides core engine callbacks for
=for html
<a href="https://github.com/stevieb9/devel-examine-subs/actions"><img src="https://github.com/stevieb9/devel-examine-subs/workflows/CI/badge.svg"/></a>
<a href='https://coveralls.io/github/stevieb9/devel-examine-subs?branch=master'><img src='https://coveralls.io/repos/stevieb9/devel-examine-subs/badge.svg?branch=master&service=github' alt='Coverage Status' /></a>
Devel::Examine::Subs
=head1 SYNOPSIS
use Devel::Examine::Subs::Engine;
my $compiler = Devel::Examine::Subs::Engine->new;
my $engine = 'has';
if (! $compiler->exists($engine)){
confess "engine $engine is not implemented.\n";
}
eval {
$engine_cref = $compiler->{engines}{$engine}->();
};
=head1 METHODS
All methods other than C<exists()> takes an href of configuration data as its
first parameter.
=head2 C<exists('engine')>
Verifies whether the engine name specified as the string parameter exists and
is valid.
=head2 C<all>
Takes C<$struct> params directly from the Processor module.
Returns an aref.
=head2 C<has>
Takes C<$struct> from the output of the 'file_lines_contain' Postprocessor.
Returns an aref.
=head2 C<missing>
Data comes directly from the Processor.
Returns an aref.
=head2 C<lines>
The module that passes data in is dependant on whether 'search' is set.
Otherwise, it comes directly from the Processor.
Returns an href.
=head2 C<objects>
( run in 0.452 second using v1.01-cache-2.11-cpan-5a3173703d6 )