Base.pm untested

filter: Statementstmt 0.0% 0 / 31 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 54 CC 6 SCAR 24.2
CC
6
Cov
0%
new
20.0
id
12.0
BEGIN
2.0
CRAP 11.3
1 package Watchdog::Base;
2  
3 use strict;
4 use Alias;
5 use base qw(Watchdog::Util);
6 use vars qw($VERSION $NAME $HOST $PORT $FILE);
7  
8 $VERSION = '0.09';
9  
10 =head1 NAME
11  
12 Watchdog::Base - Watchdog base class
13  
14 =head1 SYNOPSIS
15  
16 use Watchdog::Base;
17  
18 =head1 DESCRIPTION
19  
20 B<Watchdog::Base> is the Watchdog base class.
21  
22 =cut
23  
24 my %fields = (
25 NAME => undef,
26 HOST => 'localhost',
27 PORT => undef,
28 FILE => '',
29 );
30  
31 =head1 CLASS METHODS
32  
33 =head2 new($name,$host,$port,$file)
34  
35 Returns a new B<Watchdog::Base> object. I<$name> is a string which
36 will identify the service to a human. I<$host> is the name of the
37 host providing the service (default is 'localhost'). I<$port> is the
38 port on which the service listens.
39  
40 =cut
41  
42 sub new($$$) {
43 my $DEBUG = 0;
44 my $proto = shift;
45 my $class = ref($proto) || $proto;
46 my $self = bless { _PERMITTED => \%fields, %fields, },$class;
47 attr $self;
48  
49 print STDERR "Watchdog::Base::new() $NAME $HOST $PORT $FILE\n" if $DEBUG;
50 my $arg;
51 for (\$NAME,\$HOST,\$PORT,\$FILE) {
52 $$_ = $arg if $arg = shift;
53 }
54 print STDERR "Watchdog::Base::new() $NAME $HOST $PORT $FILE\n" if $DEBUG;
55  
56 return $self;
57 }
58 1;
59  
60 #------------------------------------------------------------------------------
61  
62 =head1 OBJECT METHODS
63  
64 =head2 id()
65  
66 Return a string describing the name of a service and the host (and
67 optionally the port) on which it runs.
68  
69 =cut
70  
71 sub id() {
72 my $self = attr shift;
73 my $id = "$NAME\@$HOST";
74 $id .= ":$PORT" if defined($PORT);
75 $id .= "/$FILE" if ($FILE eq '');
76 return $id;
77 }
78  
79 #------------------------------------------------------------------------------
80  
81 =head1 AUTHOR
82  
83 new Maintainer: Clemens Gesell E<lt>clemens.gesell@vegatron.orgE<gt>
84  
85 Paul Sharpe E<lt>paul@miraclefish.comE<gt>
86  
87 =head1 COPYRIGHT
88  
89 Copyright (c) 1998 Paul Sharpe. England. All rights reserved. This
90 program is free software; you can redistribute it and/or modify it
91 under the same terms as Perl itself.
92  
93 =cut