lib/Perl/ToPerl6/Transformer/BasicTypes/Strings/RewriteHereDocs.pm

filter: Statementstmt 64.8% 24 / 37 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.9% 10 / 11 Podpod 60.0% 3 / 5 totaltotal 62.7% 37 / 59 CC 5 SCAR 23.7
CC
5
Cov
56%
transform
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 10.7
« lib/Perl/ToPerl6/Annotation.pm ↑ Summary lib/Perl/ToPerl6.pm »
1 package Perl::ToPerl6::Transformer::BasicTypes::Strings::RewriteHereDocs;
2  
3 17 ▶use 5.006001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 17 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 17 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 17 ▶use Perl::ToPerl6::Utils qw{ :severities };
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 17 ▶use base 'Perl::ToPerl6::Transformer';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 #-----------------------------------------------------------------------------
13  
14 17 Readonly::Scalar my $DESC => q{Transform <<EOF to q:to/EOF/};
15 17 Readonly::Scalar my $EXPL => q{Perl6 heredocs now have more flexibility};
16  
17 #-----------------------------------------------------------------------------
18  
19 38 ▶sub supported_parameters { return () }
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
20 27 ▶sub default_necessity { return $NECESSITY_HIGHEST }
Subroutine default_necessity: called CC=1 SCAR=0.0
Pod documented
21 24 ▶sub default_themes { return qw( core ) }
Subroutine default_themes: called CC=1 SCAR=0.0
Pod documented
22 5 ▶sub applies_to { return 'PPI::Token::HereDoc' }
Subroutine applies_to: called CC=1 SCAR=0.0
Pod documented
23  
24 #-----------------------------------------------------------------------------
25  
26 #
27 # <<EOF --> q:to/EOF/
28 #
29 0 ▶sub transform {
Subroutine transform: not called CC=5 SCAR=34.0
Pod undocumented
30 0 my ($self, $elem, $doc) = @_;
31  
32 0 my $content = $elem->content;
33  
34 0 ▶ if ( $content =~ s{<<(\w+)}{q:to/$1/} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($content =~ s[<<(\w+)][q:to/$1/]) { } 0 0 0
elsif ($content =~ s[<<'(\s*(\w+))'][q:to/$2/]) { } 0 0 0
35 }
36  
37 #
38 # XXX This breaks PPI::Token::HereDoc encapsulation.
39 #
40 elsif ( $content =~ s{<<'(\s*(\w+))'}{q:to/$2/} ) {
41 0 my $heredoc = $1;
42 0 my $stripped = $2;
43 0 for my $line ( @{ $elem->{_heredoc} } ) {
44 0 ▶ next unless $line =~ /$heredoc$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $line =~ /$heredoc$/ 0 0 0
45 0 $line = $stripped;
46 0 last;
47 }
48 0 $elem->{_terminator} = $1;
49 }
50  
51 0 $elem->set_content( $content );
52  
53 0 return $self->transformation( $DESC, $EXPL, $elem );
54 }
55  
56 17 1;
57  
58 #-----------------------------------------------------------------------------
59  
60 __END__
« lib/Perl/ToPerl6/Annotation.pm ↑ Summary lib/Perl/ToPerl6.pm »