9 my $config = Chado::Config->new;
10 my $db_name = $config->{'database'}{'db_name'};
14 This module is a simple interface to the Chado installation
15 configuration information.
24 use File
::Spec
::Functions
;
27 use constant DEFAULT_FILENAME
=> catfile
( $Bin, 'load', 'etc', 'load.conf' );
29 # ---------------------------------------------------------
34 Instantiates a new object. Takes an optional (but preferred)
35 argument of the configuration file's path. The filename should be
36 indicated as a key/value pair, but, if only one argument is passed
37 in, it is assumed to be the filename.
39 my $conf = Chado::Config->new;
40 my $conf = Chado::Config->new( <filename> );
41 my $conf = Chado::Config->new( filename => <filename> );
47 my $args = defined $_[0] && UNIVERSAL
::isa
( $_[0], 'HASH' ) ?
shift
48 : scalar @_ == 1 ?
{ filename
=> shift }
50 my $self = bless {}, $class;
52 if ( $args->{'filename'} ) {
53 $self->filename( $args->{'filename'} );
59 # ---------------------------------------------------------
64 Gets/sets the location of the configuration file.
66 my $file = $conf->filename( <filename> );
71 my ( $self, $arg ) = @_;
73 if ( ! defined $self->{'filename'} && ! $arg ) {
74 $arg = DEFAULT_FILENAME
if -e DEFAULT_FILENAME
;
78 if ( -e
$arg && -r _
) {
79 $self->{'filename'} = $arg;
82 croak
("The file '$arg' does not exist or is not readable");
86 return $self->{'filename'};
89 # ---------------------------------------------------------
94 Returns the configuration information as parsed by XML::Simple.
96 my $options = $conf->config;
102 unless ( defined $self->{'config'} ) {
103 my $file = $self->filename;
104 $self->{'config'} = XMLin
(
106 # ForceArray => [ qw( template token path file) ],
107 # KeyAttr => [ qw( token name file) ],
108 ContentKey
=> '-value',
111 return $self->{'config'};
114 # ---------------------------------------------------------
123 Ken Y. Clark E<lt>kclark@cshl.orgE<gt>.