File Coverage

blib/lib/PPI/Token/Quote/Single.pm
Criterion Covered Total %
statement 15 15 100.0
branch 2 2 100.0
condition n/a
subroutine 5 5 100.0
pod 2 2 100.0
total 24 24 100.0


line stmt bran cond sub pod time code
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 object represents a single quoted string
25             literal.
26              
27             =head1 METHODS
28              
29             There are no methods available for C beyond
30             those provided by the parent L, L and
31             L classes.
32              
33             =cut
34              
35 64     64   364 use strict;
  64         112  
  64         1806  
36 64     64   21491 use PPI::Token::Quote ();
  64         138  
  64         1119  
37 64     64   21791 use PPI::Token::_QuoteEngine::Simple ();
  64         147  
  64         9469  
38              
39             our $VERSION = '1.275';
40              
41             our @ISA = qw{
42             PPI::Token::_QuoteEngine::Simple
43             PPI::Token::Quote
44             };
45              
46              
47              
48              
49              
50             #####################################################################
51             # PPI::Token::Quote Methods
52              
53             sub string {
54 2397     2397 1 11236 my $str = $_[0]->{content};
55 2397         6292 substr( $str, 1, length($str) - 2 );
56             }
57              
58              
59             my %UNESCAPE = (
60             "\\'" => "'",
61             "\\\\" => "\\",
62             );
63              
64             sub literal {
65             # Unescape \\ and \' ONLY
66 10     10 1 2823 my $str = $_[0]->string;
67 10 100       39 $str =~ s/(\\.)/$UNESCAPE{$1} || $1/ge;
  7         54  
68 10         41 return $str;
69             }
70              
71             1;
72              
73             =pod
74              
75             =head1 SUPPORT
76              
77             See the L in the main module.
78              
79             =head1 AUTHOR
80              
81             Adam Kennedy Eadamk@cpan.orgE
82              
83             =head1 COPYRIGHT
84              
85             Copyright 2001 - 2011 Adam Kennedy.
86              
87             This program is free software; you can redistribute
88             it and/or modify it under the same terms as Perl itself.
89              
90             The full text of the license can be found in the
91             LICENSE file included with this module.
92              
93             =cut