Server/AsyncEndpoint/Config.pm untested

filter: Statementstmt 0.0% 0 / 37 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 54 CC 5 SCAR 26.1
CC
5
Cov
0%
init
30.0
BEGIN
2.0
BEGIN
2.0
CRAP 13.7
1 package POE::Component::Server::AsyncEndpoint::Config;
2  
3 use warnings;
4 use strict;
5 our @EXPORT = ( );
6 use base qw(Exporter);
7 use vars qw($VERSION);
8 $VERSION = '0.10';
9  
10 use AppConfig ':argcount';
11 use File::Find;
12 use Carp qw(croak);
13  
14 sub init {
15  
16 my $config = AppConfig->new(
17 {GLOBAL => {ARGCOUNT => ARGCOUNT_ONE}},
18 'aes_port' => {DEFAULT => 61613},
19 'aes_addr' => {DEFAULT => '127.0.0.1'},
20 'aes_host' => {DEFAULT => 'localhost'},
21 'aes_cwdg' => {DEFAULT => 10},
22 'aes_wdgr' => {DEFAULT => 3},
23 'aes_rstc' => {DEFAULT => 15},
24 'aes_log_conf' => {DEFAULT => undef},
25 'aes_ikc_addr' => {DEFAULT => undef},
26 'aes_ikc_port' => {DEFAULT => undef},
27 'webserver_port' => {DEFAULT => 32090},
28 'mqdb_data_dir' => {DEFAULT => 'mqdb'},
29 'mqdb_dsn' => {DEFAULT => 'dbi:SQLite:dbname=mqdb/mq.db'},
30 'mqdb_username' => {DEFAULT => ''},
31 'mqdb_password' => {DEFAULT => ''},
32  
33 );
34  
35 my $fn = undef;
36  
37 # find and load server config file...
38 find( sub{ $fn = $File::Find::name if /^aes\.conf$/ }, '.');
39 $config->file($fn) if($fn);
40  
41 # find the logger config file...
42 find( sub{ $fn = $File::Find::name if /^aes_log\.conf$/ }, '.');
43  
44 croak "Refuse to run without a logger config file. See __PACKAGE__ doc for details."
45 unless $fn;
46  
47 $config->set('aes_log_conf', $fn);
48  
49 return $config;
50  
51 }
52  
53 1;
54  
55 __END__