ASP/ConfigParser.pm

filter: Statementstmt 17.8% 10 / 56 Branchbran 0.0% 0 / 26 Conditioncond 0.0% 0 / 20 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 60.0% 3 / 5 Podpod 50.0% 1 / 2 totaltotal 11.7% 14 / 119 CC 26 SCAR 64.1
CC
26
Cov
10%
parse
702.0
new
2.0
BEGIN
1.0
CRAP 608.6
↑ Summary ASP/ASPHandler.pm »
1  
2 package Apache2::ASP::ConfigParser;
3  
4 24 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 24 ▶use warnings 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 24 ▶use Apache2::ASP::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8  
9 #==============================================================================
10 sub new
11 {
12 0 ▶ my ($class) = @_;
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
13
14 0 return bless { }, $class;
15 }# end new()
16  
17  
18 #==============================================================================
19 sub parse
20 {
21 0 ▶ my ($s, $doc, $root) = @_;
Subroutine parse: not called CC=26 SCAR=65.5
Pod documented
22
23 # Start out with the <system>
24 SYSTEM: {
25 0 ▶ $doc->{system}->{libs} ||= { };
Condition0%0/2
$doc->{"system"}{"libs"} ||= {}
l!l
00
MC/DC0%0/1
$doc->{"system"}{"libs"} ||= {}
$doc->{"system"}{"libs"}
Truth table0%0/2
A
A= $doc->{"system"}{"libs"}
Aresult
11
00
26 0 ▶ if( $doc->{system}->{libs}->{lib} )
Branch: 1 branch
BranchTrueFalseTotal
if ($doc->{'system'}{'libs'}{'lib'}) { } 0 0 0
27 {
28 $doc->{system}->{libs}->{lib} = [ $doc->{system}->{libs}->{lib} ]
29 0 ▶ unless ref($doc->{system}->{libs}->{lib}) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $doc->{"system"}{"libs"}{"lib"} eq "ARRAY" 0 0 0
30 }
31 else
32 {
33 0 $doc->{system}->{libs}->{lib} = [ ];
34 }# end if()
35
36 0 ▶ $doc->{system}->{load_modules} ||= { };
Condition0%0/2
$doc->{"system"}{"load_modules"} ||= {}
l!l
00
MC/DC0%0/1
$doc->{"system"}{"load_modules"} ||= {}
$doc->{"system"}{"load_modules"}
Truth table0%0/2
A
A= $doc->{"system"}{"load_modules"}
Aresult
11
00
37 0 ▶ if( $doc->{system}->{load_modules}->{module} )
Branch: 1 branch
BranchTrueFalseTotal
if ($doc->{'system'}{'load_modules'}{'module'}) { } 0 0 0
38 {
39 $doc->{system}->{load_modules}->{module} = [ $doc->{system}->{load_modules}->{module} ]
40 0 ▶ unless ref($doc->{system}->{load_modules}->{module}) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $doc->{"system"}{"load_modules"}{"module"} eq "ARRAY" 0 0 0
41 }
42 else
43 {
44 0 $doc->{system}->{load_modules}->{module} = [ ];
45 }# end if()
46  
47 0 ▶ $doc->{system}->{env_vars} ||= { };
Condition0%0/2
$doc->{"system"}{"env_vars"} ||= {}
l!l
00
MC/DC0%0/1
$doc->{"system"}{"env_vars"} ||= {}
$doc->{"system"}{"env_vars"}
Truth table0%0/2
A
A= $doc->{"system"}{"env_vars"}
Aresult
11
00
48 0 ▶ if( $doc->{system}->{env_vars}->{var} )
Branch: 1 branch
BranchTrueFalseTotal
if ($doc->{'system'}{'env_vars'}{'var'}) { } 0 0 0
49 {
50 $doc->{system}->{env_vars}->{var} = [ delete($doc->{system}->{env_vars}->{var}) ]
51 0 ▶ unless ref($doc->{system}->{env_vars}->{var}) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $doc->{"system"}{"env_vars"}{"var"} eq "ARRAY" 0 0 0
52 0 my $ref = delete($doc->{system}->{env_vars}->{var});
53 0 $doc->{system}->{env_vars}->{var} = [ ];
54 0 foreach my $item ( grep { $_->{name} } @$ref )
55 {
56 0 push @{$doc->{system}->{env_vars}->{var}}, { $item->{name} => $item->{value} };
57 }# end foreach()
58 }
59 else
60 {
61 0 $doc->{system}->{env_vars}->{var} = [ ];
62 }# end if()
63
64 # Post-processor:
65 0 ▶ $doc->{system}->{post_processors} ||= { };
Condition0%0/2
$doc->{"system"}{"post_processors"} ||= {}
l!l
00
MC/DC0%0/1
$doc->{"system"}{"post_processors"} ||= {}
$doc->{"system"}{"post_processors"}
Truth table0%0/2
A
A= $doc->{"system"}{"post_processors"}
Aresult
11
00
66 0 ▶ if( $doc->{system}->{post_processors}->{class} )
Branch: 1 branch
BranchTrueFalseTotal
if ($doc->{'system'}{'post_processors'}{'class'}) { } 0 0 0
67 {
68 $doc->{system}->{post_processors}->{class} = [ $doc->{system}->{post_processors}->{class} ]
69 0 ▶ unless ref($doc->{system}->{post_processors}->{class}) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $doc->{"system"}{"post_processors"}{"class"} eq "ARRAY" 0 0 0
70 }
71 else
72 {
73 0 $doc->{system}->{post_processors}->{class} = [ ];
74 }# end if()
75 };
76
77 WEB: {
78 0 ▶ $doc->{web}->{request_filters} ||= { };
Condition0%0/2
$doc->{"web"}{"request_filters"} ||= {}
l!l
00
MC/DC0%0/1
$doc->{"web"}{"request_filters"} ||= {}
$doc->{"web"}{"request_filters"}
Truth table0%0/2
A
A= $doc->{"web"}{"request_filters"}
Aresult
11
00
79 0 ▶ if( $doc->{web}->{request_filters}->{filter} )
Branch: 1 branch
BranchTrueFalseTotal
if ($doc->{'web'}{'request_filters'}{'filter'}) { } 0 0 0
80 {
81 $doc->{web}->{request_filters}->{filter} = [ delete($doc->{web}->{request_filters}->{filter}) ]
82 0 ▶ unless ref($doc->{web}->{request_filters}->{filter}) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $doc->{"web"}{"request_filters"}{"filter"} eq "ARRAY" 0 0 0
83 }
84 else
85 {
86 0 $doc->{web}->{request_filters}->{filter} = [ ];
87 }# end if()
88  
89 0 ▶ $doc->{web}->{disable_persistence} ||= { };
Condition0%0/2
$doc->{"web"}{"disable_persistence"} ||= {}
l!l
00
MC/DC0%0/1
$doc->{"web"}{"disable_persistence"} ||= {}
$doc->{"web"}{"disable_persistence"}
Truth table0%0/2
A
A= $doc->{"web"}{"disable_persistence"}
Aresult
11
00
90 0 ▶ if( $doc->{web}->{disable_persistence}->{location} )
Branch: 1 branch
BranchTrueFalseTotal
if ($doc->{'web'}{'disable_persistence'}{'location'}) { } 0 0 0
91 {
92 $doc->{web}->{disable_persistence}->{location} = [ delete($doc->{web}->{disable_persistence}->{location}) ]
93 0 ▶ unless ref($doc->{web}->{disable_persistence}->{location}) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $doc->{"web"}{"disable_persistence"}{"location"} eq "ARRAY" 0 0 0
94 }
95 else
96 {
97 0 $doc->{web}->{disable_persistence}->{location} = [ ];
98 }# end if()
99 };
100
101 DATA_CONNECTIONS: {
102 0 ▶ $doc->{data_connections} ||= { };
Condition0%0/2
$doc->{"data_connections"} ||= {}
l!l
00
MC/DC0%0/1
$doc->{"data_connections"} ||= {}
$doc->{"data_connections"}
Truth table0%0/2
A
A= $doc->{"data_connections"}
Aresult
11
00
103 0 ▶ $doc->{data_connections}->{session} ||= { };
Condition0%0/2
$doc->{"data_connections"}{"session"} ||= {}
l!l
00
MC/DC0%0/1
$doc->{"data_connections"}{"session"} ||= {}
$doc->{"data_connections"}{"session"}
Truth table0%0/2
A
A= $doc->{"data_connections"}{"session"}
Aresult
11
00
104 0 ▶ $doc->{data_connections}->{application} ||= { };
Condition0%0/2
$doc->{"data_connections"}{"application"} ||= {}
l!l
00
MC/DC0%0/1
$doc->{"data_connections"}{"application"} ||= {}
$doc->{"data_connections"}{"application"}
Truth table0%0/2
A
A= $doc->{"data_connections"}{"application"}
Aresult
11
00
105 0 ▶ $doc->{data_connections}->{main} ||= { };
Condition0%0/2
$doc->{"data_connections"}{"main"} ||= {}
l!l
00
MC/DC0%0/1
$doc->{"data_connections"}{"main"} ||= {}
$doc->{"data_connections"}{"main"}
Truth table0%0/2
A
A= $doc->{"data_connections"}{"main"}
Aresult
11
00
106 };
107
108 0 my $config = Apache2::ASP::Config->new( $doc, $root );
109
110 # Now do any post-processing:
111 0 foreach my $class ( $config->system->post_processors )
112 {
113 0 (my $file = "$class.pm") =~ s/::/\//;
114 0 ▶ require $file unless $INC{$file};
Branch: 1 branch
BranchTrueFalseTotal
unless $INC{$file} 0 0 0
115 0 $config = $class->new()->post_process( $config );
116 }# end foreach()
117
118 0 return $config;
119 }# end parse()
120  
121 24 1;# return true:
122  
123 =pod
124  
125 =head1 NAME
126  
127 Apache2::ASP::ConfigParser - Initial Configuration parser
128  
129 =head1 SYNOPSIS
130  
131 # You will never use this module.
132  
133 =head1 DESCRIPTION
134  
135 This package handles the transformation of the configuration data from a simple hashref
136 into a nicely standardized, blessed hashref.
137  
138 =head1 PUBLIC METHODS
139  
140 =head2 parse( \%doc, $application_root )
141  
142 Returns an instance of L<Apache2::ASP::Config>.
143  
144 Converts a specially-constructed hashref into an instance of L<Apache2::ASP::Config>.
145  
146 Any L<Apache2::ASP::ConfigPostProcessor> classes listed in the C<system.post_processors>
147 section of the configuration will be called be called at the last moment, just before
148 returning the configuration object.
149
150 =head1 BUGS
151
152 It's possible that some bugs have found their way into this release.
153
154 Use RT L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Apache2-ASP> to submit bug reports.
155
156 =head1 HOMEPAGE
157
158 Please visit the Apache2::ASP homepage at L<http://www.devstack.com/> to see examples
159 of Apache2::ASP in action.
160
161 =head1 AUTHOR
162
163 John Drago <jdrago_999@yahoo.com>
164
165 =head1 COPYRIGHT AND LICENSE
166
167 Copyright 2007 John Drago, All rights reserved.
168
169 This software is free software. It may be used and distributed under the
170 same terms as Perl itself.
171  
172 =cut
173  
↑ Summary ASP/ASPHandler.pm »