File Coverage

blib/lib/Siesta/Config.pm
Criterion Covered Total %
statement 20 20 100.0
branch 2 4 50.0
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 27 30 90.0


line stmt bran cond sub pod time code
1             # $Id: Config.pm.in 1431 2003-10-17 11:48:27Z richardc $
2             package Siesta::Config;
3 18     18   110 use strict;
  18         43  
  18         790  
4 18     18   96 use vars qw( $CONFIG_FILE $ROOT $MESSAGES @STORAGE $ARCHIVE $LOG_PATH $LOG_LEVEL $config );
  18         35  
  18         2275  
5 18     18   18581 use AppConfig qw(:expand :argcount);
  18         134947  
  18         7647  
6              
7             =head1 NAME
8              
9             Siesta::Config - organise the configuration of a Siesta install
10              
11             =head1 VARIABLES
12              
13             =head2 C<$ROOT>
14              
15             Where to install everything to. Currently this is set to
16              
17             /usr/local/siesta
18              
19             =head2 C<$CONFIG_FILE>
20              
21             Where the config file is currently
22              
23             /usr/local/siesta/siesta.conf
24              
25             This can be overridden when using the command line tools by
26             using
27              
28             -f
29              
30              
31             =head3 CONFIG OPTIONS
32              
33             The following options are set within the config file :
34              
35             =over 4
36              
37             =item root
38              
39             override the C<$ROOT> variable above
40              
41             =item messages
42              
43             Where our message templates are stored.
44              
45             By default - /usr/local/siesta/messages/
46              
47             =item archive
48              
49             Where we archive list mails.
50              
51             By default - /usr/local/siesta/archive//
52              
53             =item log_path
54              
55             Where we log things
56              
57             By default - /usr/local/siesta/error
58              
59              
60             =item log_level
61              
62             By default - 3
63              
64             =item storage_dsn
65              
66             The DSN for our local DB
67              
68             By default - dbi:SQLite:/usr/local/siesta/database
69              
70             =item storage_user
71              
72             The user name for our DB
73              
74             By default - root
75              
76             =item storage_pass
77              
78             The password for our DB
79              
80             By default - undef
81              
82             =back
83              
84             =head2 C<@STORAGE>
85              
86             A list containing the dsn, the user and password.
87              
88             =head1 CREATION
89              
90             This file is autogenerated from Config.pm.in when you run Build.PL
91              
92             =cut
93              
94              
95             sub load_from {
96 18     18 0 44 shift;
97 18         41 my $file = shift;
98 18 50       866 $config->file($file) if -e $file;
99              
100 18         206 @STORAGE = ($config->get('storage_dsn'),
101             $config->get('storage_user'),
102             $config->get('storage_pass')),
103             $MESSAGES = $config->get('messages');
104 18         1875 $ARCHIVE = $config->get('archive');
105 18         484 $LOG_PATH = $config->get('log_path');
106 18         453 $LOG_LEVEL = $config->get('log_level');
107             }
108              
109              
110             BEGIN {
111 18     18   55 $ROOT = '/usr/local/siesta';
112 18 50       101 $CONFIG_FILE = '/usr/local/siesta/siesta.conf' unless defined $CONFIG_FILE;
113              
114 18         237 $config = AppConfig->new({
115             GLOBAL => { ARGCOUNT => ARGCOUNT_ONE,
116             EXPAND => EXPAND_ALL,
117             },
118             },
119              
120             root => {
121             DEFAULT => '/usr/local/siesta',
122             },
123             messages => {
124             DEFAULT => '/usr/local/siesta/messages',
125             },
126             archive => {
127             DEFAULT => '/usr/local/siesta/archive',
128             },
129             log_path => {
130             DEFAULT => '/usr/local/siesta/error',
131             },
132             log_level => {
133             DEFAULT => 3,
134             },
135             storage_dsn => {
136             DEFAULT => 'dbi:SQLite:/usr/local/siesta/database',
137             },
138             storage_user => {
139             DEFAULT => 'root',
140             },
141             storage_pass => {
142             DEFAULT => undef,
143             },
144             );
145 18         11247 __PACKAGE__->load_from( $CONFIG_FILE );
146             }
147              
148             1;