GX/Route/Dynamic.pm

filter: Statementstmt 93.1% 232 / 249 Branchbran 86.0% 105 / 122 Conditioncond 34.4% 10 / 29 MC/DCmcdc 0.0% 0 / 18 Subroutinesub 80.9% 17 / 21 Podpod 100% 3 / 3 totaltotal 83.0% 367 / 442 CC 79 SCAR 30.6
CC
79
Cov
87%
__finalize
39.1
match
23.5
construct_uri
9.1
CRAP 21.2
« GX/Script/Server/FCGI.pm ↑ Summary GX/Meta/Util.pm »
1 # ----------------------------------------------------------------------------------------------------------------------
2 # GX Framework (c) 2009-2011 Jörg A. Uzarek <uzarek@runlevelnull.de>
3 # File: GX/Route/Dynamic.pm
4 # ----------------------------------------------------------------------------------------------------------------------
5  
6 package GX::Route::Dynamic;
7  
8 23 ▶use GX::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 23 ▶use GX::HTTP::Parameters;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 23 ▶use GX::HTTP::Util qw( url_decode url_encode );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13 # ----------------------------------------------------------------------------------------------------------------------
14 # Class setup
15 # ----------------------------------------------------------------------------------------------------------------------
16  
17 23 ▶use GX::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 23 extends 'GX::Route';
20  
21 has 'action' => (
22 isa => 'Object',
23 required => 1,
24 191 ▶ constraint => sub { $_->isa( 'GX::Action' ) },
Subroutine __ANON__: called CC=1 SCAR=0.0
25 23 accessor => { type => 'get' }
26 );
27  
28 has 'constraints' => (
29 isa => 'Hash',
30 initialize => 1,
31 1 ▶ constraint => sub { defined && eval { qr/$_/ } or throw "Invalid constraint" for values %{$_}; 1 },
Subroutine __ANON__: called CC=4 SCAR=15.2
Branch: 1 branch
BranchTrueFalseTotal
defined $_ and eval { do { qr/$_/ } } or &throw("Invalid constraint") 1 0 1
Condition33%1/3
defined $_ and eval { do { qr/$_/ } }
!ll&&!rl&&r
001
MC/DC0%0/2
defined $_ and eval { do { qr/$_/ } }
defined $_ eval { do { qr/$_/ } }
Truth table33%1/3
A and B
A= defined $_B= eval { do { qr/$_/ } }
ABresult
0X0
100
111
32 23 accessor => { type => 'get_list' }
33 );
34  
35 23 has 'defaults' => (
36 isa => 'Hash',
37 initialize => 1,
38 accessor => { type => 'get_list' }
39 );
40  
41 23 has 'host' => (
42 isa => 'Scalar',
43 initialize => 1,
44 accessor => { type => 'get' }
45 );
46  
47 has 'host_regex' => (
48 isa => 'Scalar',
49 initialize => 0,
50 0 ▶ constraint => sub { ref eq 'Regexp' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
51 23 accessor => { type => 'get' }
52 );
53  
54 23 has 'host_variables' => (
55 isa => 'Array',
56 initialize => 0,
57 accessor => { type => 'get_list' }
58 );
59  
60 23 has 'is_reversible' => (
61 isa => 'Bool',
62 initialize => 1,
63 default => 1,
64 accessor => { type => 'get' }
65 );
66  
67 has 'methods' => (
68 isa => 'Array',
69 initialize => 1,
70 5 ▶ constraint => sub { defined && length or throw "Invalid method name" for @{$_}; 1 },
Subroutine __ANON__: called CC=4 SCAR=15.8
Branch: 1 branch
BranchTrueFalseTotal
defined $_ and length $_ or &throw("Invalid method name") 7 0 7
Condition33%1/3
defined $_ and length $_
!ll&&!rl&&r
007
MC/DC0%0/2
defined $_ and length $_
defined $_ length $_
Truth table33%1/3
A and B
A= defined $_B= length $_
ABresult
0X0
100
111
71 5 ▶ processor => sub { @{$_} = map { uc } @{$_} },
Subroutine __ANON__: called CC=1 SCAR=0.0
72 23 accessor => { type => 'get_list' }
73 );
74  
75 has 'methods_regex' => (
76 isa => 'Scalar',
77 initialize => 0,
78 0 ▶ constraint => sub { ref eq 'Regexp' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
79 23 accessor => { type => 'get' }
80 );
81  
82 23 has 'path' => (
83 isa => 'Scalar',
84 initialize => 1,
85 accessor => { type => 'get' }
86 );
87  
88 has 'path_regex' => (
89 isa => 'Scalar',
90 initialize => 0,
91 0 ▶ constraint => sub { ref eq 'Regexp' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
92 23 accessor => { type => 'get' }
93 );
94  
95 23 has 'path_variables' => (
96 isa => 'Array',
97 initialize => 0,
98 accessor => { type => 'get_list' }
99 );
100  
101 23 has 'reverse_host' => (
102 isa => 'Scalar',
103 initialize => 0,
104 accessor => { type => 'get' }
105 );
106  
107 23 has 'reverse_host_variables' => (
108 isa => 'Array',
109 initialize => 0,
110 accessor => { type => 'get_list' }
111 );
112  
113 23 has 'reverse_path' => (
114 isa => 'Scalar',
115 initialize => 0,
116 accessor => { type => 'get' }
117 );
118  
119 23 has 'reverse_path_variables' => (
120 isa => 'Array',
121 initialize => 0,
122 accessor => { type => 'get_list' }
123 );
124  
125 23 has 'reverse_scheme' => (
126 isa => 'Scalar',
127 initialize => 0,
128 accessor => { type => 'get' }
129 );
130  
131 has 'schemes' => (
132 isa => 'Array',
133 initialize => 1,
134 8 ▶ constraint => sub { defined && length or throw "Invalid URI scheme" for @{$_}; 1 },
Subroutine __ANON__: called CC=4 SCAR=15.8
Branch: 1 branch
BranchTrueFalseTotal
defined $_ and length $_ or &throw("Invalid URI scheme") 10 0 10
Condition33%1/3
defined $_ and length $_
!ll&&!rl&&r
0010
MC/DC0%0/2
defined $_ and length $_
defined $_ length $_
Truth table33%1/3
A and B
A= defined $_B= length $_
ABresult
0X0
100
111
135 8 ▶ processor => sub { @{$_} = map { lc } @{$_} },
Subroutine __ANON__: called CC=1 SCAR=0.0
136 23 accessor => { type => 'get_list' }
137 );
138  
139 has 'schemes_regex' => (
140 isa => 'Scalar',
141 initialize => 0,
142 0 ▶ constraint => sub { ref eq 'Regexp' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
143 23 accessor => { type => 'get' }
144 );
145  
146 23 build;
147  
148  
149 # ----------------------------------------------------------------------------------------------------------------------
150 # Public methods
151 # ----------------------------------------------------------------------------------------------------------------------
152  
153 44 ▶sub construct_path {
Subroutine construct_path: called CC=6 SCAR=17.9
Pod documented
154  
155 44 my $self = shift;
156  
157 44 ▶ if ( ! $self->{'is_reversible'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"is_reversible"}) 0 44 44
158 0 complain "Route is not reversible";
159 }
160  
161 44 ▶ if ( ! defined $self->{'reverse_path'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"reverse_path"}) 1 43 44
162 1 complain "Undefined reverse path";
163 }
164  
165 43 my $path;
166  
167 43 ▶ if ( @{$self->{'reverse_path_variables'}} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{'reverse_path_variables'};}) { } 23 20 43
168  
169 23 my %parameters = ( %{$self->{'defaults'}}, @_ );
170  
171 my @parameters = map {
172 31 ▶ $parameters{$_} // complain( "Missing value for path variable \"$_\"" )
Condition100%3/3
$parameters{$_} // &complain(qq[Missing value for path variable "$_"])
l!l&&r!l&&!r
2911
MC/DC0%0/2
$parameters{$_} // &complain(qq[Missing value for path variable "$_"])
$parameters{$_} &complain(qq[Missing value for path variable "$_"])
Truth table33%1/3
A // B
A= $parameters{$_}B= &complain(qq[Missing value for path variable "$_"])
ABresult
1X1
011
000
173 23 } @{$self->{'reverse_path_variables'}};
174  
175 21 $path = eval { sprintf( $self->{'reverse_path'}, map { url_encode( $_ ) } @parameters ) };
176  
177 21 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 1 20 21
178 1 complain $@;
179 }
180  
181 }
182 else {
183 20 $path = $self->{'reverse_path'};
184 }
185  
186 40 return $path;
187  
188 }
189  
190 24 ▶sub construct_uri {
Subroutine construct_uri: called CC=9 SCAR=22.1
Pod documented
191  
192 24 my $self = shift;
193 24 my %args = @_;
194  
195 24 ▶ if ( ! $self->{'is_reversible'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"is_reversible"}) 0 24 24
196 0 complain "Route is not reversible";
197 }
198  
199 24 ▶ if ( ! exists $args{'path'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $args{"path"}) 21 3 24
200  
201 21 my %parameters;
202  
203 21 ▶ if ( exists $args{'parameters'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"parameters"}) 3 18 21
204  
205 3 ▶ if ( ref $args{'parameters'} ne 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $args{"parameters"} ne "HASH") 0 3 3
206 0 complain "Invalid argument (\"parameters\" must be a hash reference)";
207 }
208  
209 3 %parameters = %{ delete $args{'parameters'} };
210  
211 }
212  
213 21 $args{'path'} = eval { $self->construct_path( %parameters ) };
214  
215 21 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 1 20 21
216 1 complain $@;
217 }
218  
219 }
220  
221 23 ▶ if ( ! exists $args{'scheme'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $args{"scheme"}) 18 5 23
222 18 $args{'scheme'} = $self->{'reverse_scheme'};
223 }
224  
225 23 ▶ if ( ! exists $args{'host'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $args{"host"}) 8 15 23
226 8 $args{'host'} = $self->{'reverse_host'};
227 }
228  
229 23 my $uri = eval { $self->_construct_uri( %args ) };
230  
231 23 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 1 22 23
232 1 complain $@;
233 }
234  
235 22 return $uri;
236  
237 }
238  
239 75 ▶sub match {
Subroutine match: called CC=23 SCAR=31.6
Pod documented
240  
241 75 my $self = shift;
242 75 my $context = shift;
243  
244 75 ▶ my $request = $context->request or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $request = $context->request or return undef 75 0 75
245  
246 23 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
247  
248 75 ▶ if ( $self->{'methods_regex'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"methods_regex"}) 9 66 75
249 9 ▶ return undef if $request->method !~ $self->{'methods_regex'};
Branch: 1 branch
BranchTrueFalseTotal
unless $request->method =~ /$self->{"methods_regex"}/ 6 3 9
250 }
251  
252 69 ▶ if ( $self->{'schemes_regex'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"schemes_regex"}) 9 60 69
253 9 ▶ return undef if $request->scheme !~ $self->{'schemes_regex'};
Branch: 1 branch
BranchTrueFalseTotal
unless $request->scheme =~ /$self->{"schemes_regex"}/ 6 3 9
254 }
255  
256 63 my $parameters;
257  
258 63 ▶ if ( $self->{'host_regex'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"host_regex"}) 30 33 63
259  
260 30 ▶ return undef if $request->host !~ $self->{'host_regex'};
Branch: 1 branch
BranchTrueFalseTotal
unless $request->host =~ /$self->{"host_regex"}/ 24 6 30
261  
262 6 ▶ if ( @{$self->{'host_variables'}} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{"host_variables"};}) 2 4 6
263  
264 2 ▶ $parameters ||= GX::HTTP::Parameters->new;
Condition33%1/3
$parameters ||= "GX::HTTP::Parameters"->new
l!l&&r!l&&!r
020
MC/DC0%0/2
$parameters ||= "GX::HTTP::Parameters"->new
$parameters "GX::HTTP::Parameters"->new
Truth table33%1/3
A ||= B
A= $parametersB= "GX::HTTP::Parameters"->new
ABresult
1X1
011
000
265  
266 2 my $i = 1;
267 2 for ( @{$self->{'host_variables'}} ) {
268 23 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
269 3 ▶ $parameters->add( $_ => url_decode( ${$i} ) ) if defined ${$i};
Branch: 1 branch
BranchTrueFalseTotal
if defined ${$i;} 3 0 3
270 3 $i++;
271 }
272  
273 }
274  
275 }
276  
277 39 ▶ if ( $self->{'path_regex'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"path_regex"}) 27 12 39
278  
279 27 ▶ return undef if $request->path !~ $self->{'path_regex'};
Branch: 1 branch
BranchTrueFalseTotal
unless $request->path =~ /$self->{"path_regex"}/ 17 10 27
280  
281 10 ▶ if ( @{$self->{'path_variables'}} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{"path_variables"};}) 7 3 10
282  
283 7 ▶ $parameters ||= GX::HTTP::Parameters->new;
Condition33%1/3
$parameters ||= "GX::HTTP::Parameters"->new
l!l&&r!l&&!r
070
MC/DC0%0/2
$parameters ||= "GX::HTTP::Parameters"->new
$parameters "GX::HTTP::Parameters"->new
Truth table33%1/3
A ||= B
A= $parametersB= "GX::HTTP::Parameters"->new
ABresult
1X1
011
000
284  
285 7 my $i = 1;
286 7 for ( @{$self->{'path_variables'}} ) {
287 23 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
288 14 ▶ $parameters->add( $_ => url_decode( ${$i} ) ) if defined ${$i};
Branch: 1 branch
BranchTrueFalseTotal
if defined ${$i;} 14 0 14
289 14 $i++;
290 }
291  
292 }
293  
294 }
295  
296 22 ▶ if ( keys %{$self->{'defaults'}} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %{$$self{"defaults"};}) 1 21 22
297  
298 1 ▶ $parameters ||= GX::HTTP::Parameters->new;
Condition33%1/3
$parameters ||= "GX::HTTP::Parameters"->new
l!l&&r!l&&!r
100
MC/DC0%0/2
$parameters ||= "GX::HTTP::Parameters"->new
$parameters "GX::HTTP::Parameters"->new
Truth table33%1/3
A ||= B
A= $parametersB= "GX::HTTP::Parameters"->new
ABresult
1X1
011
000
299  
300 1 for ( keys %{$self->{'defaults'}} ) {
301 3 ▶ $parameters->add( $_ => $self->{'defaults'}{$_} ) unless $parameters->exists( $_ );
Branch: 1 branch
BranchTrueFalseTotal
unless $parameters->exists($_) 2 1 3
302 }
303
304 }
305  
306 22 ▶ my $format = $parameters ? $parameters->get( 'format' ) : undef;
Branch: 1 branch
BranchTrueFalseTotal
$parameters ? : 9 13 22
307  
308 return GX::Route::Match->new(
309 22 action => $self->{'action'},
310 parameters => $parameters,
311 format => $format
312 );
313  
314 }
315  
316  
317 # ----------------------------------------------------------------------------------------------------------------------
318 # Internal methods
319 # ----------------------------------------------------------------------------------------------------------------------
320  
321 191 ▶sub __finalize {
Subroutine __finalize: called CC=35 SCAR=36.7
322  
323 191 my $self = shift;
324 191 my $args = shift;
325  
326 191 ▶ if ( ! exists $self->{'methods_regex'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"methods_regex"}) 191 0 191
327  
328 191 ▶ if ( @{$self->{'methods'}} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{'methods'};}) { } 5 186 191
329 5 my $pattern = join( '|', map { quotemeta } @{$self->{'methods'}} );
330 5 $self->{'methods_regex'} = qr/^$pattern$/;
331 }
332 else {
333 186 $self->{'methods_regex'} = undef;
334 }
335  
336 }
337  
338 191 ▶ if ( ! exists $self->{'schemes_regex'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"schemes_regex"}) 191 0 191
339  
340 191 ▶ if ( @{$self->{'schemes'}} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{'schemes'};}) { } 8 183 191
341 8 my $pattern = join( '|', map { quotemeta } @{$self->{'schemes'}} );
342 8 $self->{'schemes_regex'} = qr/^$pattern$/;
343 }
344 else {
345 183 $self->{'schemes_regex'} = undef;
346 }
347  
348 }
349  
350 191 ▶ if ( ! exists $self->{'host_regex'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $self->{'host_regex'}) { } 191 0 191
351  
352 191 ▶ if ( defined $self->{'host'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'host'}) { } 101 90 191
353  
354 101 my @variables;
355  
356 101 ( my $pattern = $self->{'host'} ) =~ s!
357 \{((?:[^{}]+|\{[0-9,]+\})+)\} |
358 (\*) |
359 ([^{}*]+)
360 !
361 231 ▶ if ( $1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($1) { } 79 152 231
elsif ($2) { } 32 120 152
362 79 my ( $variable, $constraint ) = split( /:/, $1, 2 );
363 79 push @variables, $variable;
364 79 ▶ $constraint = $self->{'constraints'}{$variable} unless defined $constraint;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $constraint 39 40 79
365 79 ▶ defined $constraint ? "($constraint)" : "([^.]+)";
Branch: 1 branch
BranchTrueFalseTotal
defined $constraint ? : 40 39 79
366 } elsif ( $2 ) {
367 32 "(?:[^.]+)";
368 } else {
369 120 quotemeta( $3 );
370 }
371 !egx;
372  
373 101 $self->{'host_regex'} = eval { qr/^$pattern$/ };
374  
375 101 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 101 101
376 0 throw "Invalid host pattern \"$$self{'host'}\"";
377 }
378  
379 101 $self->{'host_variables'} = \@variables;
380  
381 }
382 else {
383 90 $self->{'host_regex'} = undef;
384 90 $self->{'host_variables'} = [];
385 }
386  
387 }
388 else {
389 0 ▶ $self->{'host_variables'} ||= [];
Condition0%0/2
$self->{"host_variables"} ||= []
l!l
00
MC/DC0%0/1
$self->{"host_variables"} ||= []
$self->{"host_variables"}
Truth table0%0/2
A
A= $self->{"host_variables"}
Aresult
11
00
390 }
391  
392 191 ▶ if ( ! exists $self->{'path_regex'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $self->{'path_regex'}) { } 191 0 191
393  
394 191 ▶ if ( defined $self->{'path'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'path'}) { } 86 105 191
395  
396 86 my @variables;
397  
398 86 ( my $pattern = $self->{'path'} ) =~ s!
399 \{((?:[^{}]+|\{[0-9,]+\})+)\} |
400 (\*) |
401 ([^{}*]+)
402 !
403 203 ▶ if ( $1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($1) { } 74 129 203
elsif ($2) { } 11 118 129
404 74 my ( $variable, $constraint ) = split( /:/, $1, 2 );
405 74 push @variables, $variable;
406 74 ▶ $constraint = $self->{'constraints'}{$variable} unless defined $constraint;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $constraint 40 34 74
407 74 ▶ defined $constraint ? "($constraint)" : "([^/]+)";
Branch: 1 branch
BranchTrueFalseTotal
defined $constraint ? : 35 39 74
408 } elsif ( $2 ) {
409 11 "(?:[^/]+)";
410 } else {
411 118 quotemeta( $3 );
412 }
413 !egx;
414  
415 86 $self->{'path_regex'} = eval { qr/^$pattern$/ };
416  
417 86 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 86 86
418 0 throw "Invalid path pattern \"$$self{'path'}\"";
419 }
420  
421 86 $self->{'path_variables'} = \@variables;
422  
423 }
424 else {
425 105 $self->{'path_regex'} = undef;
426 105 $self->{'path_variables'} = [];
427 }
428  
429 }
430 else {
431 0 ▶ $self->{'path_variables'} ||= [];
Condition0%0/2
$self->{"path_variables"} ||= []
l!l
00
MC/DC0%0/1
$self->{"path_variables"} ||= []
$self->{"path_variables"}
Truth table0%0/2
A
A= $self->{"path_variables"}
Aresult
11
00
432 }
433  
434 191 ▶ if ( $self->{'is_reversible'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'is_reversible'}) { } 191 0 191
435  
436 191 ▶ if ( ! exists $self->{'reverse_scheme'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"reverse_scheme"}) 189 2 191
437 189 $self->{'reverse_scheme'} = $self->{'schemes'}[0];
438 }
439  
440 191 ▶ if ( ! exists $self->{'reverse_host'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $self->{'reverse_host'}) { } 189 2 191
441  
442 189 $self->{'reverse_host'} = undef;
443 189 $self->{'reverse_host_variables'} = [];
444  
445 189 ▶ if ( defined $self->{'host'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"host"}) 101 88 189
446  
447 101 my $reversible = 1;
448  
449 101 my @reverse_host_variables;
450  
451 101 ( my $reverse_host = $self->{'host'} ) =~ s!
452 \{((?:[^{}]+|\{[0-9,]+\})+)\} |
453 (\*) |
454 ([^{}*]+)
455 !
456 231 ▶ if ( $1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($1) { } 79 152 231
elsif ($2) { } 32 120 152
457 79 my ( $variable, undef ) = split( /:/, $1, 2 );
458 79 push @reverse_host_variables, $variable;
459 79 '%s';
460 } elsif ( $2 ) {
461 32 $reversible = 0;
462 } else {
463 120 $3;
464 }
465 !egx;
466  
467 101 ▶ if ( $reversible ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($reversible) 73 28 101
468 73 $self->{'reverse_host'} = $reverse_host;
469 73 $self->{'reverse_host_variables'} = \@reverse_host_variables;
470 }
471  
472 }
473  
474 }
475 else {
476 2 ▶ $self->{'reverse_host_variables'} ||= [];
Condition50%1/2
$self->{"reverse_host_variables"} ||= []
l!l
02
MC/DC0%0/1
$self->{"reverse_host_variables"} ||= []
$self->{"reverse_host_variables"}
Truth table50%1/2
A
A= $self->{"reverse_host_variables"}
Aresult
11
00
477 }
478  
479 191 ▶ if ( ! exists $self->{'reverse_path'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $self->{'reverse_path'}) { } 191 0 191
480  
481 191 $self->{'reverse_path'} = undef;
482 191 $self->{'reverse_path_variables'} = [];
483  
484 191 ▶ if ( defined $self->{'path'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"path"}) 86 105 191
485  
486 86 my $reversible = 1;
487  
488 86 my @reverse_path_variables;
489  
490 86 ( my $reverse_path = $self->{'path'} ) =~ s!
491 \{((?:[^{}]+|\{[0-9,]+\})+)\} |
492 (\*) |
493 ([^{}*]+)
494 !
495 203 ▶ if ( $1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($1) { } 74 129 203
elsif ($2) { } 11 118 129
496 74 my ( $variable, undef ) = split( /:/, $1, 2 );
497 74 push @reverse_path_variables, $variable;
498 74 '%s';
499 } elsif ( $2 ) {
500 11 $reversible = 0;
501 } else {
502 118 $3;
503 }
504 !egx;
505  
506 86 ▶ if ( $reversible ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($reversible) 77 9 86
507 77 $self->{'reverse_path'} = $reverse_path;
508 77 $self->{'reverse_path_variables'} = \@reverse_path_variables;
509 }
510  
511 }
512  
513 }
514 else {
515 0 ▶ $self->{'reverse_path_variables'} ||= [];
Condition0%0/2
$self->{"reverse_path_variables"} ||= []
l!l
00
MC/DC0%0/1
$self->{"reverse_path_variables"} ||= []
$self->{"reverse_path_variables"}
Truth table0%0/2
A
A= $self->{"reverse_path_variables"}
Aresult
11
00
516 }
517  
518 }
519 else {
520 0 $self->{'reverse_scheme'} = undef;
521 0 $self->{'reverse_host'} = undef;
522 0 $self->{'reverse_host_variables'} = [];
523 0 $self->{'reverse_path'} = undef;
524 0 $self->{'reverse_path_variables'} = [];
525 }
526  
527 191 return;
528  
529 }
530  
531  
532 23 1;
533  
534 __END__
« GX/Script/Server/FCGI.pm ↑ Summary GX/Meta/Util.pm »