lib/HTML/Mason/Utils.pm

filter: Statementstmt 93.3% 28 / 30 Branchbran 75.0% 6 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 83.3% 5 / 6 Podpod 100% 2 / 2 totaltotal 82.3% 42 / 51 CC 7 SCAR 15.6
CC
7
Cov
85%
cgi_request_args
7.3
data_cache_namespace
2.0
BEGIN
1.0
CRAP 4.8
« lib/HTML/Mason/Exceptions.pm ↑ Summary lib/HTML/Mason/Tools.pm »
1 # Copyright (c) 1998-2005 by Jonathan Swartz. All rights reserved.
2 # This program is free software; you can redistribute it and/or modify it
3 # under the same terms as Perl itself.
4  
5 #
6 # Miscellaneous Mason-related utilities expected to be used by
7 # external applications.
8 #
9  
10 package HTML::Mason::Utils;
11 32 $HTML::Mason::Utils::VERSION = '1.60';
12 32 ▶use HTML::Mason::Tools qw(compress_path);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 32 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 32 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 32 require Exporter;
17  
18 32 ▶use vars qw(@ISA @EXPORT_OK);
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 32 @ISA = qw(Exporter);
21 32 @EXPORT_OK = qw(data_cache_namespace cgi_request_args);
22  
23 sub data_cache_namespace
24 0 ▶{
Subroutine data_cache_namespace: not called CC=1 SCAR=6.9
Pod documented
25 0 my ($comp_id) = @_;
26 0 return compress_path($comp_id);
27 }
28  
29 sub cgi_request_args
30 8 ▶{
Subroutine cgi_request_args: called CC=7 SCAR=19.9
Pod documented
31 8 my ($q, $method) = @_;
32  
33 8 my %args;
34  
35 # Checking that there really is no query string when the method is
36 # not POST is important because otherwise ->url_param returns a
37 # parameter named 'keywords' with a value of () (empty array).
38 # This is apparently a feature related to <ISINDEX> queries or
39 # something (see the CGI.pm) docs. It makes my head hurt. - dave
40 my @methods =
41 8 ▶ $method ne 'POST' || ! $ENV{QUERY_STRING} ? ( 'param' ) : ( 'param', 'url_param' );
Branch: 1 branch
BranchTrueFalseTotal
$method ne 'POST' || !$ENV{'QUERY_STRING'} ? : 8 0 8
Condition33%1/3
$method ne "POST" or not $ENV{"QUERY_STRING"}
l!l&&r!l&&!r
800
MC/DC0%0/2
$method ne "POST" or not $ENV{"QUERY_STRING"}
$method ne "POST" not $ENV{"QUERY_STRING"}
Truth table33%1/3
A or not(B)
A= $method ne "POST"B= not $ENV{"QUERY_STRING"}
ABresult
1X1
011
000
42  
43 8 foreach my $key ( map { $q->$_() } @methods ) {
44 5 ▶ next if exists $args{$key};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{$key} 0 5 5
45 5 local $CGI::LIST_CONTEXT_WARN = 0;
46 5 my @values = map { $q->$_($key) } @methods;
47 5 ▶ $args{$key} = @values == 1 ? $values[0] : \@values;
Branch: 1 branch
BranchTrueFalseTotal
@values == 1 ? : 4 1 5
48 }
49  
50 8 ▶ return wantarray ? %args : \%args;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 7 1 8
51 }
52  
53  
54 32 1;
55  
56 __END__
« lib/HTML/Mason/Exceptions.pm ↑ Summary lib/HTML/Mason/Tools.pm »