lib/OpenFrame/AppKit/Segment/DispatchOnURI.pm

filter: Statementstmt 89.6% 26 / 29 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 25.0% 1 / 4 totaltotal 81.8% 36 / 44 CC 3 SCAR 4.5
CC
3
Cov
88%
dispatch
2.0
uri
2.0
dispatch_on_uri
2.0
CRAP 1.6
« blib/lib/OpenFrame/AppKit/Segment/LogFile.pm ↑ Summary lib/OpenFrame/AppKit/Session.pm »
1 package OpenFrame::AppKit::Segment::DispatchOnURI;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use Pipeline::Segment;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use base qw ( Pipeline::Segment );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 12 ▶sub uri {
Subroutine uri: called CC=2 SCAR=6.9
Pod undocumented
9 12 my $self = shift;
10 12 my $uri = shift;
11 12 ▶ if (defined($uri)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $uri) { } 2 10 12
12 2 $self->{_uri} = $uri;
13 2 return $self;
14 } else {
15 10 return $self->{_uri};
16 }
17 }
18  
19 0 ▶sub dispatch_on_uri {
Subroutine dispatch_on_uri: not called CC=1 SCAR=6.9
Pod undocumented
20 0 my $self = shift;
21 0 my $pipe = shift;
22 }
23  
24 10 ▶sub match_uri {
Subroutine match_uri: called CC=1 SCAR=0.0
Pod undocumented
25 10 my $self = shift;
26 10 my $uri = shift;
27 10 my $siteUri = $self->uri();
28 10 $uri->path() =~ /^$siteUri/;
29 }
30  
31 10 ▶sub dispatch {
Subroutine dispatch: called CC=2 SCAR=7.1
Pod documented
32 10 my $self = shift;
33 10 my $pipe = shift;
34
35 10 my $store = $pipe->store();
36 10 my $req = $store->get('OpenFrame::Request');
37  
38 10 ▶ if ( $self->match_uri( $req->uri() ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->match_uri($req->uri)) { } 10 0 10
39 10 return ($self->dispatch_on_uri( $pipe ));
40 } else {
41 0 return undef;
42 }
43 }
44  
45 2 1;
46  
47 =head1 NAME
48  
49 OpenFrame::AppKit::Segment::DispatchOnURI - pipeline segments that dispatch only on certain uris
50  
51 =head1 SYNOPSIS
52  
53 package MyPipeSegment;
54  
55 use OpenFrame::AppKit::Segment::DispatchOnURI;
56 use base qw( OpenFrame::AppKit::Segment::DispatchOnURI );
57
58 sub uri {
59 return qr!/some/uri/here.html!
60 }
61  
62 sub dispatch_on_uri {
63 my $self = shift;
64 my $pipe = shift;
65 # ...
66 }
67  
68 1;
69  
70 =head1 DESCRIPTION
71  
72 C<OpenFrame::AppKit::Segment::DispatchOnURI> is a base class for all pipeline segments that want to dispatch
73 only at a certain uri. To subclass it you can simply define the dispatch_on_uri method in your package and
74 call the uri() method, which by default is a get/set for the regular expression that will match the path of
75 your uri. If you wish to set a hard value you can override the uri() method to return a regular expression.
76  
77 =head1 AUTHOR
78  
79 James A. Duncan <jduncan@fotango.com>
80  
81 =head1 COPYRIGHT
82  
83 Copyright 2002 Fotango Ltd. All Rights Reserved
84  
85 This code is released under the GNU GPL and Artistic licenses.
86  
87 =cut
88  
« blib/lib/OpenFrame/AppKit/Segment/LogFile.pm ↑ Summary lib/OpenFrame/AppKit/Session.pm »