blib/lib/Rose/HTML/Util.pm

filter: Statementstmt 75.0% 27 / 36 Branchbran 35.7% 5 / 14 Conditioncond 25.0% 3 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 71.4% 5 / 7 Podpod 50.0% 2 / 4 totaltotal 52.5% 42 / 80 CC 9 SCAR 19.1
CC
9
Cov
56%
escape_uri
12.0
html_attrs_string
9.3
encode_entities
2.1
CRAP 6.7
« blib/lib/Rose/HTML/Form/Field/Numeric.pm ↑ Summary blib/lib/Rose/HTML/Object/Message.pm »
1 package Rose::HTML::Util;
2  
3 43 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 43 require Exporter;
6 43 our @ISA = qw(Exporter);
7  
8 43 our @EXPORT_OK =
9 qw(escape_html unescape_html escape_uri escape_uri_component
10 encode_entities strip_html html_attrs_string);
11  
12 43 our %EXPORT_TAGS =
13 (
14 all =>
15 [
16 qw(escape_html unescape_html escape_uri escape_uri_component
17 encode_entities)
18 ]
19 );
20  
21 43 ▶use HTML::Entities();
Subroutine BEGIN: called CC=1 SCAR=0.0
22 43 ▶use URI::Escape;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 43 ▶if(exists $ENV{'MOD_PERL'} && require mod_perl && $mod_perl::VERSION < 1.99)
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ENV{'MOD_PERL'} and require mod_perl and $mod_perl::VERSION < 1.99) { } 0 43 43
Condition33%2/6
exists $ENV{"MOD_PERL"} and require mod_perl and $mod_perl::VERSION < "1.99"
!ll&&!rl&&r
4300
exists $ENV{"MOD_PERL"} and require mod_perl
!ll&&!rl&&r
4300
MC/DC0%0/3
exists $ENV{"MOD_PERL"} and require mod_perl and $mod_perl::VERSION < "1.99"
exists $ENV{"MOD_PERL"} require mod_perl $mod_perl::VERSION < "1.99"
Truth table25%1/4
A and B and C
A= exists $ENV{"MOD_PERL"}B= require mod_perlC= $mod_perl::VERSION < "1.99"
ABCresult
0XX0
10X0
1100
1111
25 {
26 0 require Apache::Util;
27  
28 #*escape_html = \&HTML::Entities::encode;
29 0 *escape_html = \&encode_entities;
30 0 *unescape_html = \&HTML::Entities::decode;
31 0 *escape_uri_component = \&Apache::Util::escape_uri;
32 }
33 else
34 {
35 #*escape_html = \&HTML::Entities::encode;
36 43 *escape_html = \&encode_entities;
37 43 *unescape_html = \&HTML::Entities::decode;
38 43 *escape_uri_component = \&URI::Escape::uri_escape;
39 }
40  
41 43 our $VERSION = '0.011';
42  
43 1094 ▶sub encode_entities { HTML::Entities::encode_entities($_[0], @_ > 1 ? $_[1] : '<>&"') }
Subroutine encode_entities: called CC=2 SCAR=7.6
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 0 1094 1094
44  
45 sub escape_uri
46 0 ▶{
Subroutine escape_uri: not called CC=3 SCAR=24.8
Pod documented
47 0 ▶ URI::Escape::uri_escape($_[0],
Branch: 2 branches
BranchTrueFalseTotal
@_ > 1 ? : 0 0 0
defined $_[1] ? : 0 0 0
48 (@_ > 1) ? (defined $_[1] ? $_[1] : ()) : q(^A-Za-z0-9\-_.,'!~*#?&()/?@\:\[\]=));
49 }
50  
51 sub html_attrs_string
52 61 ▶{
Subroutine html_attrs_string: called CC=6 SCAR=22.3
Pod undocumented
53 61 my %attrs;
54  
55 61 ▶ if(@_ == 1 && ref $_[0] eq 'HASH')
Branch: 2 branches
BranchTrueFalseTotal
if (@_ == 1 and ref $_[0] eq 'HASH') { } 61 0 61
elsif (@_ and @_ % 2 == 0) { } 0 0 0
Condition33%1/3
@_ == 1 and ref $_[0] eq "HASH"
!ll&&!rl&&r
0061
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1 ref $_[0] eq "HASH"
Truth table33%1/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
ABresult
0X0
100
111
56 {
57 61 %attrs = %{$_[0]};
58 }
59 ▶ elsif(@_ && @_ % 2 == 0)
Condition0%0/3
@_ and @_ % 2 == 0
!ll&&!rl&&r
000
MC/DC0%0/2
@_ and @_ % 2 == 0
@_ @_ % 2 == 0
Truth table0%0/3
A and B
A= @_B= @_ % 2 == 0
ABresult
0X0
100
111
60 {
61 0 %attrs = @_;
62 }
63  
64 61 ▶ return '' unless(keys %attrs);
Branch: 1 branch
BranchTrueFalseTotal
unless keys %attrs 18 43 61
65  
66 43 return ' ' . join(' ', map { $_ . q(=") . escape_html($attrs{$_}) . q(") }
67 sort keys(%attrs));
68 }
69  
70 sub strip_html
71 0 ▶{
Subroutine strip_html: not called CC=1 SCAR=6.9
Pod undocumented
72 0 my($text) = shift;
73  
74 # XXX: dumb for now...
75 0 $text =~ s{<[^>]*?/?>}{}g;
76  
77 0 return $text;
78 }
79  
80 43 1;
81  
82  
83 __END__
« blib/lib/Rose/HTML/Form/Field/Numeric.pm ↑ Summary blib/lib/Rose/HTML/Object/Message.pm »