ASP4/ConfigNode/Web.pm

filter: Statementstmt 100% 32 / 32 Branchbran 50.0% 4 / 8 Conditioncond 50.0% 5 / 10 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 100% 6 / 6 Podpod 33.3% 1 / 3 totaltotal 75.0% 48 / 64 CC 10 SCAR 21.1
CC
10
Cov
82%
new
11.9
BEGIN
1.0
BEGIN
1.0
CRAP 8.2
« ASP4/ConfigFinder.pm ↑ Summary ASP4/FilterResolver.pm »
1  
2 package ASP4::ConfigNode::Web;
3  
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use base 'ASP4::ConfigNode';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8  
9 sub new
10 {
11 3 ▶ my $class = shift;
Subroutine new: called CC=10 SCAR=24.7
Pod undocumented
12
13 3 my $s = $class->SUPER::new( @_ );
14 3 ▶ $s->{handler_resolver} ||= 'ASP4::HTTPContext::HandlerResolver';
Condition50%1/2
$s->{"handler_resolver"} ||= "ASP4::HTTPContext::HandlerResolver"
l!l
30
MC/DC0%0/1
$s->{"handler_resolver"} ||= "ASP4::HTTPContext::HandlerResolver"
$s->{"handler_resolver"}
Truth table50%1/2
A
A= $s->{"handler_resolver"}
Aresult
11
00
15 3 ▶ $s->{handler_runner} ||= 'ASP4::HTTPContext::HandlerRunner';
Condition50%1/2
$s->{"handler_runner"} ||= "ASP4::HTTPContext::HandlerRunner"
l!l
30
MC/DC0%0/1
$s->{"handler_runner"} ||= "ASP4::HTTPContext::HandlerRunner"
$s->{"handler_runner"}
Truth table50%1/2
A
A= $s->{"handler_runner"}
Aresult
11
00
16 3 ▶ $s->{filter_resolver} ||= 'ASP4::HTTPContext::FilterResolver';
Condition50%1/2
$s->{"filter_resolver"} ||= "ASP4::HTTPContext::FilterResolver"
l!l
30
MC/DC0%0/1
$s->{"filter_resolver"} ||= "ASP4::HTTPContext::FilterResolver"
$s->{"filter_resolver"}
Truth table50%1/2
A
A= $s->{"filter_resolver"}
Aresult
11
00
17
18 map {
19 3 ▶ $_->{uri_match} = undef unless defined($_->{uri_match});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_->{"uri_match"} 0 3 3
20 3 ▶ $_->{uri_equals} = undef unless defined($_->{uri_equals});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_->{"uri_equals"} 3 0 3
21 3 $_ = $class->SUPER::new( $_ );
22 } $s->request_filters;
23 map {
24 3 ▶ $_->{uri_match} = undef unless defined($_->{uri_match});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_->{"uri_match"} 0 12 12
25 12 ▶ $_->{uri_equals} = undef unless defined($_->{uri_equals});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_->{"uri_equals"} 12 0 12
26 12 ▶ $_->{disable_session} ||= 0;
Condition50%1/2
$_->{"disable_session"} ||= 0
l!l
120
MC/DC0%0/1
$_->{"disable_session"} ||= 0
$_->{"disable_session"}
Truth table50%1/2
A
A= $_->{"disable_session"}
Aresult
11
00
27 12 ▶ $_->{disable_application} ||= 0;
Condition50%1/2
$_->{"disable_application"} ||= 0
l!l
012
MC/DC0%0/1
$_->{"disable_application"} ||= 0
$_->{"disable_application"}
Truth table50%1/2
A
A= $_->{"disable_application"}
Aresult
11
00
28 12 $_ = $class->SUPER::new( $_ );
29 } $s->disable_persistence;
30 3 return $s;
31 }# end new()
32  
33  
34 sub request_filters
35 {
36 3 ▶ my $s = shift;
Subroutine request_filters: called CC=1 SCAR=0.0
Pod documented
37
38 3 @{ $s->{request_filters} };
39 }# end request_filters()
40  
41  
42 sub disable_persistence
43 {
44 3 ▶ my $s = shift;
Subroutine disable_persistence: called CC=1 SCAR=0.0
Pod undocumented
45
46 3 @{ $s->{disable_persistence} };
47 }# end disable_persistence()
48  
49 3 1;# return true:
50  
51 =pod
52  
53 =head1 NAME
54  
55 ASP4::ConfigNode::Web - The $Config->web object.
56  
57 =head1 SYNOPSIS
58  
59 Given the following configuration...
60  
61 {
62 ...
63 web: {
64 application_name: "DefaultApp",
65 application_root: "@ServerRoot@",
66 www_root: "@ServerRoot@/htdocs",
67 handler_root: "@ServerRoot@/handlers",
68 page_cache_root: "/tmp/PAGE_CACHE",
69 handler_resolver: "ASP4::HandlerResolver",
70 handler_runner: "ASP4::HandlerRunner",
71 filter_resolver: "ASP4::FilterResolver",
72 request_filters: [
73 {
74 uri_match: "^/.*",
75 filter_class: "My::Filter"
76 }
77 ],
78 disable_persistence: [
79 {
80 uri_match: "^/nostate/.*",
81 disable_session: true,
82 disable_application: false
83 }
84 ]
85 }
86 ...
87 }
88  
89 You would access it like this:
90  
91 $Config->web->application_name; # 'MyApp'
92 $Config->web->application_root; # '/usr/local/projects/mysite.com'
93 $Config->web->handler_root; # '/usr/local/projects/mysite.com/handlers'
94 $Config->web->www_root; # '/usr/local/projects/mysite.com/htdocs'
95 $Config->web->page_cache_root; # '/tmp/PAGE_CACHE'
96
97 You will never need to do this:
98 foreach my $filter ( $Config->web->request_filters )
99 {
100 my $regexp = $filter->uri_match;
101 my $class = $filter->class;
102 }# end foreach()
103  
104 =head1 DESCRIPTION
105  
106 ASP4::ConfigNode::Web provides access to the C<web> portion of the configuration.
107  
108 =head1 PUBLIC PROPERTIES
109  
110 =head2 application_name
111  
112 Returns the name of the application.
113  
114 =head2 application_root
115  
116 Returns the absolute path to the root of the application, i.e. C</usr/local/projects/mysite.com>
117  
118 =head2 handler_root
119  
120 Returns the absolute path to where the 'handlers' are installed, i.e. C</usr/local/projects/mysite.com/handlers>
121  
122 =head2 www_root
123  
124 Returns the absolute path to where the normal website files (ASP, images, css, javascripts, etc) are located,
125 i.e. C</usr/local/projects/mysite.com/htdocs>
126  
127 =head2 page_cache_root
128  
129 Returns the absolute path to where 'compiled' ASP scripts are stored, i.e. C</tmp/PAGE_CACHE>
130  
131 Since the 'compiled' ASP scripts are overwritten whenever the source ASP script has been changed on disk,
132 the webserver process must have read/write access to this location.
133  
134 It is recommended that a temporary path is used - '/tmp' on most Linux distributions.
135  
136 =head2 request_filters
137  
138 Returns a list of ConfigNodes that represent individual C<filter> elements in the configuration.
139  
140 =head1 SEE ALSO
141  
142 L<ASP4::RequestFilter>
143
144 =head1 BUGS
145
146 It's possible that some bugs have found their way into this release.
147
148 Use RT L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=ASP4> to submit bug reports.
149
150 =head1 HOMEPAGE
151
152 Please visit the ASP4 homepage at L<http://www.devstack.com/> to see examples
153 of ASP4 in action.
154
155 =head1 AUTHOR
156
157 John Drago <jdrago_999@yahoo.com>
158
159 =head1 COPYRIGHT AND LICENSE
160
161 Copyright 2007 John Drago, All rights reserved.
162
163 This software is free software. It may be used and distributed under the
164 same terms as Perl itself.
165
166 =cut
167  
« ASP4/ConfigFinder.pm ↑ Summary ASP4/FilterResolver.pm »