cvsuser 03/12/03 08:19:36
Modified: App-Context/lib/App/Conf File.pm
Log:
options
Revision Changes Path
1.4 +21 -21 p5ee/App-Context/lib/App/Conf/File.pm
Index: File.pm
===================================================================
RCS file: /cvs/public/p5ee/App-Context/lib/App/Conf/File.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -r1.3 -r1.4
--- File.pm 19 May 2003 17:41:12 -0000 1.3
+++ File.pm 3 Dec 2003 16:19:36 -0000 1.4
@@ -1,10 +1,10 @@
#############################################################################
-## $Id: File.pm,v 1.3 2003/05/19 17:41:12 spadkins Exp $
+## $Id: File.pm,v 1.4 2003/12/03 16:19:36 spadkins Exp $
#############################################################################
package App::Conf::File;
-$VERSION = do { my @r=(q$Revision: 1.3 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r};
+$VERSION = do { my @r=(q$Revision: 1.4 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r};
use App;
use App::Conf;
@@ -15,20 +15,20 @@
sub create {
my $self = shift;
- my ($initconf);
+ my ($options);
if ($#_ >= 0 && ref($_[0]) eq "HASH") {
- $initconf = $_[0];
+ $options = $_[0];
}
elsif ($#_ >= 0 && $#_ % 2 == 1) {
- $initconf = { @_ };
+ $options = { @_ };
}
else {
- $initconf = {};
+ $options = {};
}
my @conf_file = ();
- my ($conf_tag, $conf_type, $conf_file);
- $conf_file = $initconf->{conf_file};
+ my ($app, $conf_type, $conf_file);
+ $conf_file = $options->{conf_file};
if (defined $conf_file) {
if ($conf_file) {
@conf_file = ( $conf_file );
@@ -65,18 +65,18 @@
# 4. find the base "prefix" directory for the entire
# software installation.
#################################################################
- my $prefix = $initconf->{prefix};
+ my $prefix = $options->{prefix};
#################################################################
# 5. Define the standard places to look for a conf file
#################################################################
- $conf_tag = $initconf->{conf_tag} || "app";
- $conf_type = $initconf->{conf_type} || "pl";
- push(@conf_file, "$ENV{HOME}/.app/$conf_tag.$conf_type") if ($ENV{HOME} &&
$conf_tag ne "app");
+ $app = $options->{app} || "app";
+ $conf_type = $options->{conf_type} || "pl";
+ push(@conf_file, "$ENV{HOME}/.app/$app.$conf_type") if ($ENV{HOME} && $app
ne "app");
push(@conf_file, "$ENV{HOME}/.app/app.$conf_type") if ($ENV{HOME});
- push(@conf_file, "$prog_dir/$conf_tag.$conf_type") if ($conf_tag ne "app");
+ push(@conf_file, "$prog_dir/$app.$conf_type") if ($app ne "app");
push(@conf_file, "$prog_dir/app.$conf_type");
- push(@conf_file, "$prefix/etc/app/$conf_tag.$conf_type") if ($conf_tag ne
"app");
+ push(@conf_file, "$prefix/etc/app/$app.$conf_type") if ($app ne "app");
push(@conf_file, "$prefix/etc/app/app.$conf_type");
}
@@ -89,9 +89,9 @@
my $conf = {};
while ($#conf_file > -1) {
$conf_file = shift(@conf_file);
- print STDERR "Looking for conf_file [$conf_file]\n" if
($initconf->{debugconf});
+ print STDERR "Looking for conf_file [$conf_file]\n" if
($options->{debugconf});
if (open(App::FILE, "< $conf_file")) {
- print STDERR "Found conf_file [$conf_file]\n" if
($initconf->{debugconf});
+ print STDERR "Found conf_file [$conf_file]\n" if
($options->{debugconf});
@conf_file = (); # don't look any farther
@text = <App::FILE>;
close(App::FILE);
@@ -99,11 +99,11 @@
#$text =~ /^(.*)/s;
#$text = $1;
- # Now do substitutions for {:var:} or {:var=default:} in the config
file to the value in the initconf file
+ # Now do substitutions for {:var:} or {:var=default:} in the config
file to the value in the options file
# (we really should do this only for text file types)
- $text =~ s/\{:([a-zA-Z0-9_]+)(=?)([^:\{\}]*):\}/(defined
$initconf->{$1} ? $initconf->{$1} : ($2 ? $3 : $1))/eg;
+ $text =~ s/\{:([a-zA-Z0-9_]+)(=?)([^:\{\}]*):\}/(defined $options->{$1}
? $options->{$1} : ($2 ? $3 : $1))/eg;
- $serializer_class = $initconf->{conf_serializer_class} ||
"App::Serializer";
+ $serializer_class = $options->{conf_serializer_class} ||
"App::Serializer";
if (!$serializer_class) {
if ($conf_type eq "pl") {
@@ -170,8 +170,8 @@
}
}
- if ($initconf->{conf} && ref($initconf->{conf}) eq "HASH") {
- App::Reference->overlay($conf, $initconf->{conf});
+ if ($options->{conf} && ref($options->{conf}) eq "HASH") {
+ App::Reference->overlay($conf, $options->{conf});
}
$conf;