Caribou/Utils.pm

filter: Statementstmt 100% 55 / 55 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 20 / 20 Podpod n/a totaltotal 100% 77 / 77 CC 2 SCAR 0.9
CC
2
Cov
100%
escape
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« Caribou/Tags/HTML/Extended.pm ↑ Summary Caribou/Tags/HTML.pm »
1 package Template::Caribou::Utils;
2 18 our $AUTHORITY = 'cpan:YANICK';
3 # ABSTRACT: internal utilities for Template::Caribou
4 18 $Template::Caribou::Utils::VERSION = '1.1.0';
5  
6 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 18 ▶no warnings qw/ uninitialized /;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 BEGIN {
11 18 ▶ *::RAW = *::STDOUT;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 }
13  
14 18 ▶use parent 'Exporter::Tiny';
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 18 ▶use experimental 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 18 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20  
21 package
22 Template::Caribou::String;
23  
24 use overload
25 115 ▶ '""' => sub { return ${$_[0] } },
Subroutine __ANON__: called CC=1 SCAR=0.0
26 18 ▶ 'eq' => sub { ${$_[0]} eq $_[1] };
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
27  
28 113 ▶sub new { my ( $class, $string ) = @_; bless \$string, $class; }
Subroutine new: called CC=1 SCAR=0.0
29  
30  
31 package
32 Template::Caribou::Output;
33  
34 18 ▶use parent 'Tie::Handle';
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 144 ▶sub TIEHANDLE { return bless \my $i, shift; }
Subroutine TIEHANDLE: called CC=1 SCAR=0.0
37  
38 sub escape {
39 18 ▶ no warnings qw/ uninitialized/;
Subroutine BEGIN: called CC=1 SCAR=0.0
40 @_ = map {
41 116 ▶ my $x = $_;
Subroutine escape: called CC=2 SCAR=6.9
42 116 $x =~ s/&/&/g;
43 116 $x =~ s/</&lt;/g;
44 116 $x;
45 } @_;
46  
47 116 ▶ return wantarray ? @_ : join '', @_;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 21 95 116
48 }
49  
50 21 ▶sub PRINT { shift; print ::RAW escape( @_ ) }
Subroutine PRINT: called CC=1 SCAR=0.0
51  
52 package
53 Template::Caribou::OutputRaw;
54  
55 18 ▶use parent 'Tie::Handle';
Subroutine BEGIN: called CC=1 SCAR=0.0
56  
57 144 ▶sub TIEHANDLE { return bless \my $i, shift; }
Subroutine TIEHANDLE: called CC=1 SCAR=0.0
58  
59 sub PRINT {
60 84 ▶ shift;
Subroutine PRINT: called CC=1 SCAR=0.0
61 18 ▶ no warnings qw/ uninitialized /;
Subroutine BEGIN: called CC=1 SCAR=0.0
62 84 $Template::Caribou::OUTPUT .= join '', @_, $\;
63 }
64  
65 18 1;
66  
67 __END__
68  
69 =pod
70  
71 =encoding UTF-8
72  
73 =head1 NAME
74  
75 Template::Caribou::Utils - internal utilities for Template::Caribou
76  
77 =head1 VERSION
78  
79 version 1.1.0
80  
81 =head1 DESCRIPTION
82  
83 Used internally by L<Template::Caribou>. Nothing interesting
84 for end-users.
85  
86 =head1 AUTHOR
87  
88 Yanick Champoux <yanick@cpan.org>
89  
90 =head1 COPYRIGHT AND LICENSE
91  
92 This software is copyright (c) 2017 by Yanick Champoux.
93  
94 This is free software; you can redistribute it and/or modify it under
95 the same terms as the Perl 5 programming language system itself.
96  
97 =cut
« Caribou/Tags/HTML/Extended.pm ↑ Summary Caribou/Tags/HTML.pm »