| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | ################################################################################ | 
| 2 |  |  |  |  |  |  | # | 
| 3 |  |  |  |  |  |  | # Apache::Voodoo::Constants | 
| 4 |  |  |  |  |  |  | # | 
| 5 |  |  |  |  |  |  | # This package provide an OO interface to retrive the various paths and config | 
| 6 |  |  |  |  |  |  | # settings used by Apache Voodoo. | 
| 7 |  |  |  |  |  |  | # | 
| 8 |  |  |  |  |  |  | ################################################################################ | 
| 9 |  |  |  |  |  |  | package Apache::Voodoo::Constants; | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | $VERSION = "3.0200"; | 
| 12 |  |  |  |  |  |  |  | 
| 13 | 4 |  |  | 4 |  | 2997 | use strict; | 
|  | 4 |  |  |  |  | 6 |  | 
|  | 4 |  |  |  |  | 171 |  | 
| 14 | 4 |  |  | 4 |  | 22 | use warnings; | 
|  | 4 |  |  |  |  | 8 |  | 
|  | 4 |  |  |  |  | 2717 |  | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | my $self; | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | sub new { | 
| 19 | 18 |  |  | 18 | 0 | 3363 | my $class       = shift; | 
| 20 | 18 |  |  |  |  | 28 | my $config_file = shift; | 
| 21 |  |  |  |  |  |  |  | 
| 22 | 18 | 100 |  |  |  | 72 | if (ref($self)) { | 
| 23 | 15 | 100 |  |  |  | 45 | if ($config_file) { | 
| 24 | 3 |  |  |  |  | 5 | $self->{_conf_package} = $config_file; | 
| 25 | 3 |  |  |  |  | 7 | $self->_init(); | 
| 26 |  |  |  |  |  |  | } | 
| 27 | 14 |  |  |  |  | 66 | return $self; | 
| 28 |  |  |  |  |  |  | } | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | $self = { | 
| 31 | 3 |  | 50 |  |  | 19 | _conf_package => $config_file || 'Apache::Voodoo::MyConfig' | 
| 32 |  |  |  |  |  |  | }; | 
| 33 |  |  |  |  |  |  |  | 
| 34 | 3 |  |  |  |  | 10 | bless($self,$class); | 
| 35 |  |  |  |  |  |  |  | 
| 36 | 3 |  |  |  |  | 15 | $self->_init(); | 
| 37 |  |  |  |  |  |  |  | 
| 38 | 2 |  |  |  |  | 7 | return $self; | 
| 39 |  |  |  |  |  |  | } | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | sub _init { | 
| 42 | 6 |  |  | 6 |  | 39 | my $self = shift; | 
| 43 |  |  |  |  |  |  |  | 
| 44 | 6 |  |  |  |  | 24 | my $p = $self->{_conf_package}; | 
| 45 | 6 |  |  |  |  | 9 | my $f = $self->{_conf_package}; | 
| 46 | 6 |  |  |  |  | 24 | $f =~ s/::/\//g; | 
| 47 | 6 |  |  |  |  | 12 | $f .= '.pm'; | 
| 48 |  |  |  |  |  |  |  | 
| 49 | 6 |  |  |  |  | 11 | eval { | 
| 50 | 6 |  |  |  |  | 1935 | require $f; | 
| 51 |  |  |  |  |  |  | }; | 
| 52 | 6 | 100 |  |  |  | 97 | if ($@) { | 
| 53 | 1 |  |  |  |  | 9 | die "$@\n". | 
| 54 |  |  |  |  |  |  | "Can't find $p.  This probably means that Apache Voodoo hasn't been configured yet.\n". | 
| 55 |  |  |  |  |  |  | "Please do so by running \"voodoo-control setconfig\"\n"; | 
| 56 |  |  |  |  |  |  | } | 
| 57 |  |  |  |  |  |  |  | 
| 58 | 5 | 100 |  |  |  | 252 | unless (ref(eval '$'.$p."::CONFIG") eq "HASH") { | 
| 59 | 1 |  |  |  |  | 8 | die "There was an error loading $p.  Please run \"voodoo-control setconfig\"\n"; | 
| 60 |  |  |  |  |  |  | } | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | # copy the config. | 
| 63 | 4 |  |  |  |  | 192 | my %h = eval '%{$'.$p."::CONFIG}"; | 
| 64 | 4 |  |  |  |  | 28 | foreach (keys %h) { | 
| 65 | 56 |  |  |  |  | 97 | $self->{$_} = $h{$_}; | 
| 66 |  |  |  |  |  |  | } | 
| 67 |  |  |  |  |  |  | } | 
| 68 |  |  |  |  |  |  |  | 
| 69 | 1 |  |  | 1 | 0 | 594 | sub apache_gid    { return $_[0]->{APACHE_GID};    } | 
| 70 | 1 |  |  | 1 | 0 | 632 | sub apache_uid    { return $_[0]->{APACHE_UID};    } | 
| 71 | 1 |  |  | 1 | 0 | 664 | sub code_path     { return $_[0]->{CODE_PATH};     } | 
| 72 | 8 |  |  | 8 | 0 | 933 | sub conf_file     { return $_[0]->{CONF_FILE};     } | 
| 73 | 1 |  |  | 1 | 0 | 699 | sub conf_path     { return $_[0]->{CONF_PATH};     } | 
| 74 | 14 |  |  | 14 | 0 | 647 | sub install_path  { return $_[0]->{INSTALL_PATH};  } | 
| 75 | 1 |  |  | 1 | 0 | 585 | sub prefix        { return $_[0]->{PREFIX};        } | 
| 76 | 1 |  |  | 1 | 0 | 584 | sub session_path  { return $_[0]->{SESSION_PATH};  } | 
| 77 | 7 |  |  | 7 | 0 | 675 | sub tmpl_path     { return $_[0]->{TMPL_PATH};     } | 
| 78 | 1 |  |  | 1 | 0 | 625 | sub updates_path  { return $_[0]->{UPDATES_PATH};  } | 
| 79 | 4 |  |  | 4 | 0 | 607 | sub debug_dbd     { return $_[0]->{DEBUG_DBD};     } | 
| 80 | 4 |  |  | 4 | 0 | 807 | sub debug_path    { return $_[0]->{DEBUG_PATH};    } | 
| 81 | 4 |  |  | 4 | 0 | 702 | sub use_log4perl  { return $_[0]->{USE_LOG4PERL};  } | 
| 82 | 4 |  |  | 4 | 0 | 693 | sub log4perl_conf { return $_[0]->{LOG4PERL_CONF}; } | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | 1; | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | ################################################################################ | 
| 87 |  |  |  |  |  |  | # Copyright (c) 2005-2010 Steven Edwards (maverick@smurfbane.org). | 
| 88 |  |  |  |  |  |  | # All rights reserved. | 
| 89 |  |  |  |  |  |  | # | 
| 90 |  |  |  |  |  |  | # You may use and distribute Apache::Voodoo under the terms described in the | 
| 91 |  |  |  |  |  |  | # LICENSE file include in this package. The summary is it's a legalese version | 
| 92 |  |  |  |  |  |  | # of the Artistic License :) | 
| 93 |  |  |  |  |  |  | # | 
| 94 |  |  |  |  |  |  | ################################################################################ |