lib/PurpleWiki/View/Filter.pm untested

filter: Statementstmt 0.0% 0 / 45 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 82 CC 7 SCAR 28.6
CC
7
Cov
0%
AUTOLOAD
42.0
new
6.0
process
2.0
CRAP 17.5
1 # PurpleWiki::View::Filter.pm
2 #
3 # $Id: Filter.pm 366 2004-05-19 19:22:17Z eekim $
4 #
5 # Copyright (c) Blue Oxen Associates 2002-2004. All rights reserved.
6 #
7 # This file is part of PurpleWiki. PurpleWiki is derived from:
8 #
9 # UseModWiki v0.92 (c) Clifford A. Adams 2000-2001
10 # AtisWiki v0.3 (c) Markus Denker 1998
11 # CVWiki CVS-patches (c) Peter Merel 1997
12 # The Original WikiWikiWeb (c) Ward Cunningham
13 #
14 # PurpleWiki is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 2 of the License, or
17 # (at your option) any later version.
18 #
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write to the
26 # Free Software Foundation, Inc.
27 # 59 Temple Place, Suite 330
28 # Boston, MA 02111-1307 USA
29  
30 package PurpleWiki::View::Filter;
31 use 5.005;
32 use strict;
33 use warnings;
34 use Carp;
35 use PurpleWiki::View::Driver;
36  
37 ######## Package Globals ########
38  
39 our $VERSION;
40 $VERSION = sprintf("%d", q$Id: Filter.pm 366 2004-05-19 19:22:17Z eekim $ =~ /\s(\d+)\s/);
41  
42 our @ISA = qw(PurpleWiki::View::Driver);
43  
44  
45 ######## Public Methods ########
46  
47 sub new {
48 my $proto = shift;
49 my $class = ref($proto) || $proto;
50 my $self = $class->SUPER::new(@_);
51  
52 # Object state.
53 $self->{useOO} = 0 if not defined $self->{useOO};
54  
55 bless($self, $class);
56 return $self;
57 }
58  
59 sub process {
60 my $self = shift;
61 $self->start(@_);
62 $self->view(@_);
63 $self->end(@_);
64 }
65  
66 sub setFilter { shift->setFilters(@_) }
67  
68 sub setFilters {
69 my ($self, %filters) = @_;
70 map { $self->{$_} = $filters{$_} } keys %filters;
71 }
72  
73  
74 ######## Private Methods ########
75  
76 sub AUTOLOAD {
77 our $AUTOLOAD;
78 my $self = shift;
79 my $method = $AUTOLOAD;
80  
81 # Remove all but the method name
82 $method =~ s/(.*)://g; # Reduces Foo::Bar::Baz::Quz::method to "method"
83  
84 # Bail on DESTROY, otherwise we'll cause an infinite loop when our object
85 # is garbage collected.
86 return if $method =~ /DESTROY/;
87  
88 if (defined $self->{$method}) {
89 if ($self->{useOO}) {
90 return $self->{$method}->($self, @_);
91 } else {
92 return $self->{$method}->(@_);
93 }
94 } elsif ($method eq "start" or $method eq "end") {
95 return $self->noop(@_);
96 }
97  
98 eval '$self->SUPER::'.$method.'(@_);';
99 croak "Could not find method: $AUTOLOAD\n" if $@;
100 }
101 1;
102 __END__