Alien-Selenium
view release on metacpan or search on metacpan
inc/Pod/Snippets.pm view on Meta::CPAN
if ($a->has_enough_cookies()) {
$a->conquer_world();
}
SECOND_SNIPPET
=for metatests "as_data multiple blocks return" end
Notice how the indentation is respected snippet-by-snippet; also,
notice that the FIRST_SNIPPET has been padded with an appropriate
number of carriage returns to replace the B<Pod::Snippets> markup, so
that the return value is line-synchronized with the original POD.
However, leading and trailing whitespace is trimmed, leaving only
strings that starts with a nonblank line and end with a single
newline.
In scalar context, returns the blocks joined with a single newline
character ("\n"), thus resulting in a single piece of text where the
blocks are joined by exactly one empty line (and which as a whole is
no longer line-synchronized with the source code, of course).
=cut
sub as_data {
my ($self) = @_;
$self->_block_access_if_errors();
my @retval = map {
# This may be a pedestrian and sub-optimal way of doing the
# ragging, but it sure is concise:
inc/Pod/Snippets.pm view on Meta::CPAN
} else {
# The merger case.
my $prevstartline = $snippets[-1]->line();
my $newlines_to_add = $snip->line - $prevstartline
- _number_of_newlines_in($snippets[-1]);
if ($newlines_to_add < 0) {
my $filename = $self->filename();
warn <<"ASSERTION_FAILED" ;
Pod::Snippets: problem counting newlines at $filename
near line $prevstartline (trying to skip $newlines_to_add lines)
Output will be desynchronized.
ASSERTION_FAILED
$newlines_to_add = 0;
}
$snippets[-1] = $snippets[-1] . $/ x $newlines_to_add .
$snip;
}
}
pop @snippets if ! defined $snippets[-1];
( run in 0.328 second using v1.01-cache-2.11-cpan-0d8aa00de5b )