Config.pm untested

filter: Statementstmt 0.0% 0 / 42 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 70 CC 3 SCAR 14.2
CC
3
Cov
0%
courier_version
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 4.1
1 #
2 # Courier::Config class
3 #
4 # (C) 2003-2008 Julian Mehnle <julian@mehnle.net>
5 # $Id: Config.pm 210 2008-03-21 19:30:31Z julian $
6 #
7 ###############################################################################
8  
9 =head1 NAME
10  
11 Courier::Config - Class providing configuration information for Perl modules
12 related to the Courier MTA
13  
14 =cut
15  
16 package Courier::Config;
17  
18 use warnings;
19 use strict;
20  
21 use version;
22  
23 use constant TRUE => (0 == 0);
24 use constant FALSE => not TRUE;
25  
26 =head1 SYNOPSIS
27  
28 use Courier::Config;
29
30 # Courier base configuration:
31 my $config_dir = Courier::Config->config_dir;
32 my $runtime_dir = Courier::Config->runtime_dir;
33 my $courier_executable = Courier::Config->courier_executable;
34 my $courier_version = Courier::Config->courier_version;
35
36 # Courier::Filter configuration:
37 my $filter_conf_file = Courier::Config->filter_conf_file;
38  
39 =head1 DESCRIPTION
40  
41 This class provides configuration information for Perl modules related to the
42 Courier MTA, e.g. installation specific file system paths.
43  
44 =cut
45  
46 # Declarations:
47 ###############################################################################
48  
49 =head2 Courier base configuration
50  
51 The following methods provide information about Courier's base configuration:
52  
53 =over
54  
55 =item B<config_dir>: returns I<string>
56  
57 The base configuration directory of Courier.
58  
59 =cut
60  
61 use constant config_dir => '/etc/courier';
62  
63 =item B<runtime_dir>: returns I<string>
64  
65 The directory where Courier keeps the message queue (C<msgq>, C<msgs>, C<tmp>)
66 and courierfilter sockets (C<filters>, C<allfilters>).
67  
68 =cut
69  
70 use constant runtime_dir => '/var/lib/courier'; # Normally '/var/run/courier'.
71  
72 =item B<courier_executable>: returns I<string>
73  
74 The full path of the Courier daemon executable.
75  
76 =cut
77  
78 use constant courier_executable => '/usr/sbin/courier';
79  
80 =item B<courier_version>: returns I<version>
81  
82 The version number of the Courier installation.
83  
84 =cut
85  
86 my $courier_version;
87  
88 sub courier_version {
89 my ($self) = @_;
90 my $courier_executable = $self->courier_executable;
91 if (
92 not defined($courier_version) and
93 -x $courier_executable
94 ) {
95 my $courier_version_string = `$courier_executable --version`;
96 if (
97 $? == 0 and
98 $courier_version_string =~ /^Courier ([^ ]+)/
99 ) {
100 $courier_version = version->new($1);
101 }
102 }
103 return $courier_version;
104 }
105  
106 =back
107  
108 =head2 Courier::Filter configuration
109  
110 The following Courier::Filter configuration information is provided:
111  
112 =over
113  
114 =item B<filter_conf_file>: returns I<string>
115  
116 The absolute file name of the Courier::Filter courier-filter-perl configuration
117 file.
118  
119 =cut
120  
121 use constant filter_conf_file => config_dir . '/filters/courier-filter-perl.conf';
122  
123 =back
124  
125 =cut
126  
127 # Support legacy method names:
128  
129 BEGIN {
130 no warnings 'once';
131 *COURIER_CONFIG_DIR = \&config_dir;
132 *COURIER_RUNTIME_DIR = \&runtime_dir;
133 *COURIER_FILTER_CONF = \&filter_conf_file;
134 }
135  
136 =head1 SEE ALSO
137  
138 For AVAILABILITY, SUPPORT, and LICENSE information, see
139 L<Courier::Filter::Overview>.
140  
141 =head1 AUTHOR
142  
143 Julian Mehnle <julian@mehnle.net>
144  
145 =cut
146  
147 TRUE;