Lazy.pm

filter: Statementstmt 67.5% 98 / 145 Branchbran 25.0% 5 / 20 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 75.6% 31 / 41 Podpod 85.7% 18 / 21 totaltotal 63.3% 152 / 240 CC 14 SCAR 20.3
CC
14
Cov
60%
header
42.0
DESTROY
20.0
new
5.9
CRAP 7.6
« Lazy/Authz.pm ↑ Summary Lazy/CSS.pm »
1 package CGI::Lazy;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use CGI::Pretty;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use CGI::Lazy::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use CGI::Lazy::Plugin;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use CGI::Lazy::DB;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use CGI::Lazy::DB::RecordSet;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use CGI::Lazy::Session;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use CGI::Lazy::Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use CGI::Lazy::Widget;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use CGI::Lazy::Globals;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use CGI::Lazy::ErrorHandler;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use CGI::Lazy::Utility;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use CGI::Lazy::Javascript;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use CGI::Lazy::CSS;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use CGI::Lazy::Image;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use CGI::Lazy::Authn;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use CGI::Lazy::Authz;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 1 ▶use base qw(CGI::Pretty);
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 1 our $VERSION = '1.10';
26  
27 1 our $AutoloadClass = 'CGI'; #this is neccesarry to get around an autoload problem in CGI.pm.
28  
29 #------------------------------------------------------------
30 0 ▶sub DESTROY {
Subroutine DESTROY: not called CC=4 SCAR=30.0
31 0 my $self = shift;
32  
33 0 ▶ if ($self->plugin && $self->plugin->session) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->plugin and $self->plugin->session) 0 0 0
Condition0%0/3
$self->plugin and $self->plugin->session
!ll&&!rl&&r
000
MC/DC0%0/2
$self->plugin and $self->plugin->session
$self->plugin $self->plugin->session
Truth table0%0/3
A and B
A= $self->pluginB= $self->plugin->session
ABresult
0X0
100
111
34 0 ▶ unless ($self->plugin->session->{saveOnDestroy} == 0) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->plugin->session->{"saveOnDestroy"} == 0) 0 0 0
35 0 $self->session->save;
36 }
37 }
38  
39 0 return;
40 }
41  
42 #------------------------------------------------------------
43 0 ▶sub authn {
Subroutine authn: not called CC=1 SCAR=6.9
Pod documented
44 0 my $self = shift;
45  
46 0 return $self->{_authn};
47 }
48  
49 #------------------------------------------------------------
50 0 ▶sub authz {
Subroutine authz: not called CC=1 SCAR=6.9
Pod documented
51 0 my $self = shift;
52  
53 0 return $self->{_authz};
54  
55 }
56  
57 #------------------------------------------------------------
58 1 ▶sub css {
Subroutine css: called CC=1 SCAR=0.0
Pod undocumented
59 1 my $self = shift;
60  
61 1 return CGI::Lazy::CSS->new($self);
62  
63 }
64  
65 #------------------------------------------------------------
66 0 ▶sub csswrap {
Subroutine csswrap: not called CC=1 SCAR=6.9
Pod undocumented
67 0 my $self = shift;
68 0 my $css = shift;
69  
70 0 my $csspre = "\n<style type='text/css'>\n<!--\n";
71 0 my $csspost = "\n-->\n</style>\n";
72  
73 0 return $csspre.$css.$csspost;
74 }
75  
76 #------------------------------------------------------------
77 1 ▶sub image {
Subroutine image: called CC=1 SCAR=0.0
Pod undocumented
78 1 my $self = shift;
79  
80 1 return CGI::Lazy::Image->new($self);
81 }
82  
83 #------------------------------------------------------------
84 1 ▶sub javascript {
Subroutine javascript: called CC=1 SCAR=0.0
Pod documented
85 1 my $self = shift;
86  
87 1 return CGI::Lazy::Javascript->new($self);
88 }
89  
90 #------------------------------------------------------------
91 7 ▶sub config {
Subroutine config: called CC=1 SCAR=0.0
Pod documented
92 7 my $self = shift;
93  
94 7 return $self->{_config};
95 }
96  
97 #------------------------------------------------------------
98 0 ▶sub db {
Subroutine db: not called CC=1 SCAR=6.9
Pod documented
99 0 my $self = shift;
100  
101 0 return $self->{_db};
102 }
103  
104 #------------------------------------------------------------
105 0 ▶sub dbh {
Subroutine dbh: not called CC=1 SCAR=6.9
Pod documented
106 0 my $self = shift;
107  
108 0 return $self->db->dbh;
109 }
110  
111 #------------------------------------------------------------
112 1 ▶sub errorHandler {
Subroutine errorHandler: called CC=1 SCAR=0.0
Pod documented
113 1 my $self = shift;
114  
115 1 return $self->{_errorHandler};
116 }
117  
118 #------------------------------------------------------------
119 0 ▶sub header {
Subroutine header: not called CC=6 SCAR=37.4
Pod documented
120 0 my $self = shift;
121  
122 0 my %args;
123  
124 0 ▶ if (scalar @_ % 2 == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_ % 2 == 0) { } 0 0 0
125 0 %args = @_;
126 } else {
127 0 my $ref = shift;
128 0 %args = %$ref;
129 }
130  
131 0 ▶ my $explicitcookies = $args{-cookie} || []; #cookies set explictly in the instance
Condition0%0/2
$args{'-cookie'} || []
l!l
00
MC/DC0%0/1
$args{'-cookie'} || []
$args{'-cookie'}
Truth table0%0/2
A
A= $args{'-cookie'}
Aresult
11
00
132 0 my $lazycookie;
133  
134 0 ▶ if ($self->plugin) { #it's possible that this object hasn't been built- if the config object doesn't create for instance.
Branch: 1 branch
BranchTrueFalseTotal
if ($self->plugin) { } 0 0 0
135 0 ▶ if ($self->plugin->session && $self->session) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->plugin->session and $self->session) 0 0 0
Condition0%0/3
$self->plugin->session and $self->session
!ll&&!rl&&r
000
MC/DC0%0/2
$self->plugin->session and $self->session
$self->plugin->session $self->session
Truth table0%0/3
A and B
A= $self->plugin->sessionB= $self->session
ABresult
0X0
100
111
136 $lazycookie = $self->cookie(
137 -name => $self->plugin->session->{sessionCookie},
138 -expires => $self->plugin->session->{expires},
139 0 -value => $self->session->sessionID,
140 );
141 }
142 } else { #something really bad happened. Return a header anyway, so we can show an error message
143 0 return $self->SUPER::header();
144 }
145  
146 0 $args{-cookie} = [$lazycookie, @$explicitcookies];
147  
148 0 return $self->SUPER::header(%args);
149 }
150  
151 #------------------------------------------------------------
152 0 ▶sub jswrap {
Subroutine jswrap: not called CC=1 SCAR=6.9
Pod documented
153 0 my $self = shift;
154 0 my $js = shift;
155  
156 0 my $jspre = "\n<script type='text/javascript'>\n<!--\n";
157 0 my $jspost = "\n-->\n</script>\n";
158 0 return $jspre.$js.$jspost;
159 }
160  
161 #------------------------------------------------------------
162 0 ▶sub mod_perl {
Subroutine mod_perl: not called CC=1 SCAR=6.9
Pod documented
163 0 my $self = shift;
164  
165 0 return $self->{_mod_perl};
166 }
167  
168 #------------------------------------------------------------
169 1 ▶sub new {
Subroutine new: called CC=5 SCAR=17.8
Pod documented
170 1 my $class = shift;
171 1 my $vars = shift;
172  
173 1 my $sessionID;
174  
175 1 my $self = bless $class->SUPER::new(@_), $class;
176  
177 1 $self->{_vars} = $vars;
178 1 $self->{_errorHandler} = CGI::Lazy::ErrorHandler->new($self);
179 1 $self->{_config} = CGI::Lazy::Config->new($self, $vars);
180 1 $self->{_plugin} = CGI::Lazy::Plugin->new($self);
181 1 $self->{_db} = CGI::Lazy::DB->new($self);
182  
183 1 ▶ if ($self->plugin->session) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->plugin->session) 0 1 1
184 0 $self->{_session} = CGI::Lazy::Session->open($self, $sessionID);
185 }
186  
187 1 ▶ if ($self->plugin->authn) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->plugin->authn) 0 1 1
188 0 $self->{_authn} = CGI::Lazy::Authn->new($self);
189 }
190  
191 1 ▶ if ($self->plugin->authz) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->plugin->authz) 0 1 1
192 0 $self->{_authz} = CGI::Lazy::Authz->new($self);
193 }
194  
195 1 ▶ if ($self->plugin->mod_perl) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->plugin->mod_perl) 0 1 1
196 0 require CGI::Lazy::ModPerl;
197 0 $self->{_mod_perl} = CGI::Lazy::ModPerl->new($self);
198 }
199  
200 1 return $self;
201 }
202  
203 #------------------------------------------------------------
204 1 ▶sub lazyversion {
Subroutine lazyversion: called CC=1 SCAR=0.0
Pod documented
205 1 my $self = shift;
206  
207 1 return $VERSION;
208 }
209  
210 #------------------------------------------------------------
211 6 ▶sub plugin {
Subroutine plugin: called CC=1 SCAR=0.0
Pod documented
212 6 my $self = shift;
213  
214 6 return $self->{_plugin};
215 }
216  
217 #------------------------------------------------------------
218 0 ▶sub session {
Subroutine session: not called CC=1 SCAR=6.9
Pod documented
219 0 my $self = shift;
220  
221 0 return $self->{_session};
222 }
223  
224 #------------------------------------------------------------
225 1 ▶sub template {
Subroutine template: called CC=2 SCAR=7.4
Pod documented
226 1 my $self = shift;
227 1 my $template = shift;
228  
229 1 ▶ if ($self->{_template}->{$template}) { #if it's been created, return it
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_template'}{$template}) { } 0 1 1
230 0 return $self->{_template}->{$template};
231 } else { #if not, create it and return it
232 1 return $self->{_template}->{$template} = CGI::Lazy::Template->new($self, $template);
233 }
234 }
235  
236 #------------------------------------------------------------
237 1 ▶sub util {
Subroutine util: called CC=1 SCAR=0.0
Pod documented
238 1 my $self = shift;
239  
240 1 return CGI::Lazy::Utility->new($self);
241  
242 }
243  
244 #------------------------------------------------------------
245 2 ▶sub vars {
Subroutine vars: called CC=1 SCAR=0.0
Pod documented
246 2 my $self = shift;
247  
248 2 return $self->{_vars};
249 }
250  
251 #------------------------------------------------------------
252 1 ▶sub widget {
Subroutine widget: called CC=1 SCAR=0.0
Pod documented
253 1 my $self = shift;
254  
255 1 return CGI::Lazy::Widget->new($self);
256 }
257  
258 1 1;
259  
260 __END__
« Lazy/Authz.pm ↑ Summary Lazy/CSS.pm »