PPI/Token/Quote/Single.pm

filter: Statementstmt 100% 22 / 22 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 100% 33 / 33 CC 2 SCAR 2.2
CC
2
Cov
100%
literal
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« PPI/Token/QuoteLike/Words.pm ↑ Summary PPI/Document/Fragment.pm »
1 package PPI::Token::Quote::Single;
2  
3 =pod
4  
5 =head1 NAME
6  
7 PPI::Token::Quote::Single - A 'single quote' token
8  
9 =head1 INHERITANCE
10  
11 PPI::Token::Quote::Single
12 isa PPI::Token::Quote
13 isa PPI::Token
14 isa PPI::Element
15  
16 =head1 SYNOPSIS
17  
18 'This is a single quote'
19
20 q{This is a literal, but NOT a single quote}
21  
22 =head1 DESCRIPTION
23  
24 A C<PPI::Token::Quote::Single> object represents a single quoted string
25 literal.
26  
27 =head1 METHODS
28  
29 There are no methods available for C<PPI::Token::Quote::Single> beyond
30 those provided by the parent L<PPI::Token::Quote>, L<PPI::Token> and
31 L<PPI::Element> classes.
32  
33 =cut
34  
35 62 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 62 ▶use PPI::Token::Quote ();
Subroutine BEGIN: called CC=1 SCAR=0.0
37 62 ▶use PPI::Token::_QuoteEngine::Simple ();
Subroutine BEGIN: called CC=1 SCAR=0.0
38  
39 62 ▶use vars qw{$VERSION @ISA};
Subroutine BEGIN: called CC=1 SCAR=0.0
40 BEGIN {
41 62 ▶ $VERSION = '1.236';
Subroutine BEGIN: called CC=1 SCAR=0.0
42 62 @ISA = qw{
43 PPI::Token::_QuoteEngine::Simple
44 PPI::Token::Quote
45 };
46 }
47  
48  
49  
50  
51  
52 #####################################################################
53 # PPI::Token::Quote Methods
54  
55 sub string {
56 2405 ▶ my $str = $_[0]->{content};
Subroutine string: called CC=1 SCAR=0.0
Pod documented
57 2405 substr( $str, 1, length($str) - 2 );
58 }
59  
60  
61 62 my %UNESCAPE = (
62 "\\'" => "'",
63 "\\\\" => "\\",
64 );
65  
66 sub literal {
67 # Unescape \\ and \' ONLY
68 10 ▶ my $str = $_[0]->string;
Subroutine literal: called CC=2 SCAR=6.9
Pod documented
69 10 ▶ $str =~ s/(\\.)/$UNESCAPE{$1} || $1/ge;
Branch: 1 branch
BranchTrueFalseTotal
$UNESCAPE{$1} or $1 2 5 7
70 10 return $str;
71 }
72  
73 62 1;
74  
75 =pod
76  
77 =head1 SUPPORT
78  
79 See the L<support section|PPI/SUPPORT> in the main module.
80  
81 =head1 AUTHOR
82  
83 Adam Kennedy E<lt>adamk@cpan.orgE<gt>
84  
85 =head1 COPYRIGHT
86  
87 Copyright 2001 - 2011 Adam Kennedy.
88  
89 This program is free software; you can redistribute
90 it and/or modify it under the same terms as Perl itself.
91  
92 The full text of the license can be found in the
93 LICENSE file included with this module.
94  
95 =cut
« PPI/Token/QuoteLike/Words.pm ↑ Summary PPI/Document/Fragment.pm »