WE_Frontend/Info.pm

filter: Statementstmt 63.2% 67 / 106 Branchbran 50.0% 11 / 22 Conditioncond 44.4% 12 / 27 MC/DCmcdc 22.2% 4 / 18 Subroutinesub 46.1% 24 / 52 Podpod n/a totaltotal 52.4% 118 / 225 CC 21 SCAR 13.6
CC
21
Cov
58%
get
12.0
get
12.0
get
11.4
CRAP 3.9
« WE_Content/YAML.pm ↑ Summary WE_Frontend/FontInfo.pm »
1 package WE_Frontend::Info;
2  
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 $VERSION = sprintf("%d.%02d", q$Revision: 1.34 $ =~ /(\d+)\.(\d+)/);
6  
7 ######################################################################
8 package WEsiteinfo::Paths;
9 7 ▶use base qw(Class::Accessor);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 7 __PACKAGE__->mk_accessors(qw(scheme servername serverport absoluteurl
11 livescheme liveservername liveserverport
12 liveabsoluteurl
13 hosturl livehosturl
14 uprootdir liveuprootdir
15 rooturl rootdir cgiurl cgidir
16 liverooturl liverootdir livecgiurl livecgidir
17 we_templatebase site_we_templatebase
18 site_templatebase we_htmldir we_htmlurl
19 we_datadir photodir downloaddir
20 pubhtmldir prototypedir
21 htuser htpassword
22 ));
23 # backward compat:
24 7 *we_htmlbase = \&we_htmldir;
25 7 *we_database = \&we_datadir;
26  
27 2 ▶sub new { bless {}, shift } # XXX this used to be __PACKAGE__ --- document!
Subroutine new: called CC=1 SCAR=0.0
28  
29 # Provide sensible defaults
30 my %paths_constructed_member =
31 1 ▶ (hosturl => sub { $_[0]->scheme . "://" .
Subroutine __ANON__: called CC=3 SCAR=14.2
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0]->serverport && $_[0]->serverport ne '80' ? : 0 1 1
Condition33%1/3
defined $_[0]->serverport and $_[0]->serverport ne 80
!ll&&!rl&&r
100
MC/DC0%0/2
defined $_[0]->serverport and $_[0]->serverport ne 80
defined $_[0]->serverport $_[0]->serverport ne 80
Truth table33%1/3
A and B
A= defined $_[0]->serverportB= $_[0]->serverport ne 80
ABresult
0X0
100
111
32 $_[0]->servername .
33 (defined $_[0]->serverport && $_[0]->serverport ne "80"
34 ? ":" . $_[0]->serverport
35 : "")
36 },
37 1 ▶ livehosturl => sub { $_[0]->livescheme . "://" .
Subroutine __ANON__: called CC=3 SCAR=14.2
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0]->liveserverport && $_[0]->liveserverport ne '80' ? : 0 1 1
Condition33%1/3
defined $_[0]->liveserverport and $_[0]->liveserverport ne 80
!ll&&!rl&&r
100
MC/DC0%0/2
defined $_[0]->liveserverport and $_[0]->liveserverport ne 80
defined $_[0]->liveserverport $_[0]->liveserverport ne 80
Truth table33%1/3
A and B
A= defined $_[0]->liveserverportB= $_[0]->liveserverport ne 80
ABresult
0X0
100
111
38 $_[0]->liveservername .
39 (defined $_[0]->liveserverport && $_[0]->liveserverport ne "80"
40 ? ":" . $_[0]->liveserverport
41 : "")
42 },
43 0 ▶ absoluteurl => sub { $_[0]->hosturl . $_[0]->rooturl },
Subroutine __ANON__: not called CC=1 SCAR=6.9
44 0 ▶ liveabsoluteurl => sub { $_[0]->livehosturl . $_[0]->liverooturl },
Subroutine __ANON__: not called CC=1 SCAR=6.9
45 1 ▶ rooturl => sub { "" },
Subroutine __ANON__: called CC=1 SCAR=0.0
46 2 ▶ rootdir => sub { $_[0]->uprootdir . "/htdocs" },
Subroutine __ANON__: called CC=1 SCAR=0.0
47 0 ▶ liverooturl => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
48 0 ▶ liverootdir => sub { $_[0]->liveuprootdir . "/htdocs" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
49 0 ▶ cgiurl => sub { "/cgi-bin" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
50 0 ▶ cgidir => sub { $_[0]->uprootdir . "/cgi-bin" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
51 0 ▶ livecgiurl => sub { $_[0]->cgiurl },
Subroutine __ANON__: not called CC=1 SCAR=6.9
52 0 ▶ livecgidir => sub { $_[0]->liveuprootdir . "/cgi-bin" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
53 2 ▶ we_htmldir => sub { $_[0]->rootdir . "/we" },
Subroutine __ANON__: called CC=1 SCAR=0.0
54 2 ▶ we_htmlurl => sub { $_[0]->rooturl . "/we" },
Subroutine __ANON__: called CC=1 SCAR=0.0
55 0 ▶ we_templatebase => sub { $_[0]->we_htmldir . "/we_templates" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
56 0 ▶ site_templatebase => sub { $_[0]->we_htmldir . "/" .
Subroutine __ANON__: not called CC=1 SCAR=6.9
57 $_[0]->{_parent}->project->name .
58 0 "_templates" },
59 1 ▶ site_we_templatebase => sub { $_[0]->we_htmldir . "/" .
Subroutine __ANON__: called CC=1 SCAR=0.0
60 $_[0]->{_parent}->project->name .
61 1 "_we_templates" },
62 0 ▶ prototypedir => sub { $_[0]->we_htmldir . "/" .
Subroutine __ANON__: not called CC=1 SCAR=6.9
63 $_[0]->{_parent}->project->name .
64 0 "_prototypes" },
65 0 ▶ photodir => sub { $_[0]->rootdir . "/photos" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
66 0 ▶ pubhtmldir => sub { $_[0]->rootdir },
Subroutine __ANON__: not called CC=1 SCAR=6.9
67 0 ▶ we_datadir => sub { $_[0]->uprootdir . "/we_data" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
68 1 ▶ scheme => sub { "http" },
Subroutine __ANON__: called CC=1 SCAR=0.0
69 1 ▶ livescheme => sub { "http" },
Subroutine __ANON__: called CC=1 SCAR=0.0
70 7 );
71 25 ▶sub get {
Subroutine get: called CC=3 SCAR=11.0
72 25 my($self, $key) = @_;
73 25 ▶ if (!defined $self->{$key} && exists $paths_constructed_member{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{$key} and exists $paths_constructed_member{$key}) { } 12 13 25
Condition100%3/3
not defined $self->{$key} and exists $paths_constructed_member{$key}
!ll&&!rl&&r
11212
MC/DC100%2/2
not defined $self->{$key} and exists $paths_constructed_member{$key}
not defined $self->{$key} exists $paths_constructed_member{$key}
Truth table100%3/3
not(A) and B
A= not defined $self->{$key}B= exists $paths_constructed_member{$key}
ABresult
0X0
100
111
74 12 $paths_constructed_member{$key}->($self);
75 } else {
76 13 $self->SUPER::get($key);
77 }
78 }
79  
80 ######################################################################
81 package WEsiteinfo::SearchEngine;
82 7 ▶use base qw(Class::Accessor);
Subroutine BEGIN: called CC=1 SCAR=0.0
83 # prelive_htdigconf and live_htdigconf is obsolete
84 7 __PACKAGE__->mk_accessors(qw(searchindexer htdigconf htdigconftemplate
85 prelive_htdigconf live_htdigconf
86 use_prelive_database));
87 0 ▶sub new { bless {}, shift }
Subroutine new: not called CC=1 SCAR=6.9
88  
89 # Provide sensible defaults
90 my %searchengine_constructed_member =
91 0 ▶ (searchindexer => sub { "rundig" }, # XXX or htdig?
Subroutine __ANON__: not called CC=1 SCAR=6.9
92 7 );
93 0 ▶sub get {
Subroutine get: not called CC=3 SCAR=24.8
94 0 my($self, $key) = @_;
95 0 ▶ if (!defined $self->{$key} && exists $searchengine_constructed_member{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{$key} and exists $searchengine_constructed_member{$key}) { } 0 0 0
Condition0%0/3
not defined $self->{$key} and exists $searchengine_constructed_member{$key}
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $self->{$key} and exists $searchengine_constructed_member{$key}
not defined $self->{$key} exists $searchengine_constructed_member{$key}
Truth table0%0/3
not(A) and B
A= not defined $self->{$key}B= exists $searchengine_constructed_member{$key}
ABresult
0X0
100
111
96 0 $searchengine_constructed_member{$key}->($self);
97 } else {
98 0 $self->SUPER::get($key);
99 }
100 }
101  
102 ######################################################################
103 package WEsiteinfo::Staging;
104 7 ▶use base qw(Class::Accessor);
Subroutine BEGIN: called CC=1 SCAR=0.0
105 7 __PACKAGE__->mk_accessors(qw(transport user password host directory
106 cgidirectory tempdirectory temp2directory
107 stagingext rsakey archivefile message));
108 0 ▶sub new { bless {}, shift }
Subroutine new: not called CC=1 SCAR=6.9
109  
110 # Provide sensible defaults
111 my %staging_constructed_member =
112 0 ▶ (directory => sub { $_[0]->{_parent}->paths->liverootdir },
Subroutine __ANON__: not called CC=1 SCAR=6.9
113 0 ▶ cgidirectory => sub { warn $_[0]->{_parent}->paths->livecgidir; $_[0]->{_parent}->paths->livecgidir },
Subroutine __ANON__: not called CC=1 SCAR=6.9
114 7 );
115 0 ▶sub get {
Subroutine get: not called CC=3 SCAR=24.8
116 0 my($self, $key) = @_;
117 0 ▶ if (!defined $self->{$key} && exists $staging_constructed_member{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{$key} and exists $staging_constructed_member{$key}) { } 0 0 0
Condition0%0/3
not defined $self->{$key} and exists $staging_constructed_member{$key}
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $self->{$key} and exists $staging_constructed_member{$key}
not defined $self->{$key} exists $staging_constructed_member{$key}
Truth table0%0/3
not(A) and B
A= not defined $self->{$key}B= exists $staging_constructed_member{$key}
ABresult
0X0
100
111
118 0 $staging_constructed_member{$key}->($self);
119 } else {
120 0 $self->SUPER::get($key);
121 }
122 }
123  
124 ######################################################################
125 package WEsiteinfo::Siteext;
126 7 ▶use base qw(Class::Accessor);
Subroutine BEGIN: called CC=1 SCAR=0.0
127 7 __PACKAGE__->mk_accessors(qw(external_auth notify_mailer notify_background));
128 0 ▶sub new { bless {}, shift }
Subroutine new: not called CC=1 SCAR=6.9
129  
130 ######################################################################
131 package WEprojectinfo;
132 7 ▶use base qw(Class::Accessor);
Subroutine BEGIN: called CC=1 SCAR=0.0
133 7 __PACKAGE__->mk_accessors(qw(name longname
134 sitelanguages editorlanguages pagetypes
135 defaulteditorlang cookieexpirationtime
136 productname templatefortype labelfortype
137 imagetypes imagesubtypes
138 iconfortype features projectext
139 class feclass
140 stagingexcept stagingexceptpat stagingextracgi
141 stagingadditional
142 adminmail developermail
143 sessionlocking useversioning
144 standardext
145 ));
146 1 ▶sub new { bless {}, shift }
Subroutine new: called CC=1 SCAR=0.0
147  
148 # Provide sensible defaults
149 my %projectinfo_constructed_member =
150 0 ▶ (productname => sub { "web.editor" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
151 0 ▶ editorlanguages => sub { [qw(de en)] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
152 0 ▶ defaulteditorlang => sub { $_[0]->editorlanguages->[0] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
153 0 ▶ cookieexpirationtime => sub { '+1d' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
154 0 ▶ developermail => sub { 'eserte@users.sourceforge.net' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
155 0 ▶ standardext => sub { ".html" }
Subroutine __ANON__: not called CC=1 SCAR=6.9
156 7 );
157  
158 4 ▶sub get {
Subroutine get: called CC=8 SCAR=24.3
159 4 my($self, $key) = @_;
160 4 ▶ if (!defined $self->{$key} && exists $projectinfo_constructed_member{$key}) {
Branch: 4 branches
BranchTrueFalseTotal
if (not defined $self->{$key} and exists $projectinfo_constructed_member{$key}) { } 0 4 4
elsif ($key eq 'features' and not exists $self->{'features'}) { } 1 3 4
elsif ($key eq 'longname' and not exists $self->{'longname'}) { } 0 3 3
elsif ($key =~ /^(?:sessionlocking|useversioning)$/) { } 0 3 3
Condition66%2/3
not defined $self->{$key} and exists $projectinfo_constructed_member{$key}
!ll&&!rl&&r
310
MC/DC0%0/2
not defined $self->{$key} and exists $projectinfo_constructed_member{$key}
not defined $self->{$key} exists $projectinfo_constructed_member{$key}
Truth table66%2/3
not(A) and B
A= not defined $self->{$key}B= exists $projectinfo_constructed_member{$key}
ABresult
0X0
100
111
161 0 $projectinfo_constructed_member{$key}->($self);
162 ▶ } elsif ($key eq 'features' && !exists $self->{features}) {
Condition100%3/3
$key eq "features" and not exists $self->{"features"}
!ll&&!rl&&r
121
MC/DC100%2/2
$key eq "features" and not exists $self->{"features"}
$key eq "features" not exists $self->{"features"}
Truth table100%3/3
A and not(B)
A= $key eq "features"B= not exists $self->{"features"}
ABresult
0X0
100
111
163 1 return {};
164 ▶ } elsif ($key eq 'longname' && !exists $self->{longname}) {
Condition33%1/3
$key eq "longname" and not exists $self->{"longname"}
!ll&&!rl&&r
300
MC/DC0%0/2
$key eq "longname" and not exists $self->{"longname"}
$key eq "longname" not exists $self->{"longname"}
Truth table33%1/3
A and not(B)
A= $key eq "longname"B= not exists $self->{"longname"}
ABresult
0X0
100
111
165 0 return $self->{name};
166 } elsif ($key =~ /^(?:sessionlocking|useversioning)$/) {
167 0 return $self->get("features")->{$key};
168 } else {
169 3 $self->SUPER::get($key);
170 }
171 }
172  
173 5 ▶sub set {
Subroutine set: called CC=2 SCAR=7.6
174 5 my($self, $key, $val) = @_;
175 5 ▶ if ($key =~ /^(?:sessionlocking|useversioning)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key =~ /^(?:sessionlocking|useversioning)$/) { } 0 5 5
176 0 return $self->{features}{$key} = $val;
177 } else {
178 5 $self->SUPER::set($key, $val);
179 }
180 }
181  
182 ######################################################################
183 package WEsiteinfo;
184 7 ▶use base qw(Exporter Class::Accessor);
Subroutine BEGIN: called CC=1 SCAR=0.0
185 7 __PACKAGE__->mk_accessors(qw(project paths searchengine staging debug siteext
186 liveconfig preliveconfig));
187 1 ▶sub new { bless {}, shift }
Subroutine new: called CC=1 SCAR=0.0
188 7 @WEsiteinfo::EXPORT_OK = qw($c);
189  
190 7 my %subobject = qw(project 1 paths 1 searchengine 1 staging 1 siteext 1);
191 10 ▶sub set {
Subroutine set: called CC=3 SCAR=12.0
192 10 my($self, $key, $val) = @_;
193 10 ▶ if (exists $subobject{$key} && UNIVERSAL::isa($val, 'HASH')) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $subobject{$key} and UNIVERSAL::isa($val, "HASH")) 10 0 10
Condition33%1/3
exists $subobject{$key} and UNIVERSAL::isa($val, "HASH")
!ll&&!rl&&r
0010
MC/DC0%0/2
exists $subobject{$key} and UNIVERSAL::isa($val, "HASH")
exists $subobject{$key} UNIVERSAL::isa($val, "HASH")
Truth table33%1/3
A and B
A= exists $subobject{$key}B= UNIVERSAL::isa($val, "HASH")
ABresult
0X0
100
111
194 # provide "backlink" to parent object
195 10 $val->{_parent} = $self;
196 }
197 10 $self->SUPER::set($key, $val);
198 }
199  
200 7 1;
201  
202 __END__
« WE_Content/YAML.pm ↑ Summary WE_Frontend/FontInfo.pm »