File Coverage

blib/lib/Perl/ToPerl6/Transformer/BasicTypes/Strings/RenameShell.pm
Criterion Covered Total %
statement 20 27 74.0
branch n/a
condition n/a
subroutine 9 12 75.0
pod 3 6 50.0
total 32 45 71.1


line stmt bran cond sub pod time code
1             package Perl::ToPerl6::Transformer::BasicTypes::Strings::RenameShell;
2              
3 1     1   781 use 5.006001;
  1         3  
4 1     1   5 use strict;
  1         1  
  1         18  
5 1     1   4 use warnings;
  1         2  
  1         19  
6 1     1   5 use Readonly;
  1         1  
  1         39  
7              
8 1     1   5 use Perl::ToPerl6::Utils qw{ :severities };
  1         2  
  1         51  
9              
10 1     1   104 use base 'Perl::ToPerl6::Transformer';
  1         2  
  1         238  
11              
12             #-----------------------------------------------------------------------------
13              
14             Readonly::Scalar my $DESC => q{Transform qx{...} to qqx{...}};
15             Readonly::Scalar my $EXPL =>
16             q{Perl6 supports qx{}, but the perl5ish version is qqx{}};
17              
18             #-----------------------------------------------------------------------------
19              
20 1     1 0 4 sub run_after { return 'BasicTypes::Strings::AddWhitespace' }
21 1     1 0 3 sub supported_parameters { return () }
22 1     1 1 5 sub default_necessity { return $NECESSITY_HIGHEST }
23 0     0 1   sub default_themes { return qw( core ) }
24 0     0 1   sub applies_to { return 'PPI::Token::QuoteLike::Command' }
25              
26             #-----------------------------------------------------------------------------
27              
28             #
29             # A PPI::Token::QuoteLike::Command object contains a single string which has
30             # the entire 'qx{...}' token. Therefore we can't add a Token::Whitespace
31             # between the 'qr' and '{..}' like we can with loops and conditionals.
32             #
33              
34             sub transform {
35 0     0 0   my ($self, $elem, $doc) = @_;
36              
37 0           my $content = $elem->content;
38              
39 0           $content =~ s{^qx}{qqx};
40              
41 0           $elem->set_content( $content );
42              
43 0           return $self->transformation( $DESC, $EXPL, $elem );
44             }
45              
46             1;
47              
48             #-----------------------------------------------------------------------------
49              
50             __END__
51              
52             =pod
53              
54             =head1 NAME
55              
56             Perl::ToPerl6::Transformer::BasicTypes::Strings::RenameShell - Rename qx() to qqx()
57              
58              
59             =head1 AFFILIATION
60              
61             This Transformer is part of the core L<Perl::ToPerl6|Perl::ToPerl6>
62             distribution.
63              
64              
65             =head1 DESCRIPTION
66              
67             Perl6 has a C<qx()> operator, but the C<qqx()> operator is more akin to Perl5:
68              
69             qx{..} --> qx{..}
70             qx(..) --> qx (..)
71              
72             This transformer only operates on qx() constructs.
73              
74             =head1 CONFIGURATION
75              
76             This Transformer is not configurable except for the standard options.
77              
78             =head1 AUTHOR
79              
80             Jeffrey Goff <drforr@pobox.com>
81              
82             =head1 COPYRIGHT
83              
84             Copyright (c) 2015 Jeffrey Goff
85              
86             This program is free software; you can redistribute it and/or modify
87             it under the same terms as Perl itself.
88              
89             =cut
90              
91             ##############################################################################
92             # Local Variables:
93             # mode: cperl
94             # cperl-indent-level: 4
95             # fill-column: 78
96             # indent-tabs-mode: nil
97             # c-indentation-style: bsd
98             # End:
99             # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :