2006-12-05 22:58:38 +03:00
|
|
|
#
|
|
|
|
# Config object for release automation
|
|
|
|
#
|
|
|
|
|
|
|
|
package Bootstrap::Config;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
# shared static config
|
|
|
|
my %config;
|
|
|
|
|
|
|
|
# single shared instance
|
|
|
|
my $singleton = undef;
|
|
|
|
|
|
|
|
sub new {
|
|
|
|
my $proto = shift;
|
|
|
|
my $class = ref($proto) || $proto;
|
|
|
|
|
|
|
|
return $singleton if defined $singleton;
|
|
|
|
|
|
|
|
my $this = {};
|
|
|
|
bless($this, $class);
|
|
|
|
$this->Parse();
|
|
|
|
$singleton = $this;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub Parse {
|
|
|
|
my $this = shift;
|
|
|
|
|
|
|
|
open (CONFIG, "< bootstrap.cfg")
|
2007-02-08 01:14:24 +03:00
|
|
|
|| die("Can't open config file bootstrap.cfg");
|
2006-12-05 22:58:38 +03:00
|
|
|
|
|
|
|
while (<CONFIG>) {
|
|
|
|
chomp; # no newline
|
|
|
|
s/#.*//; # no comments
|
|
|
|
s/^\s+//; # no leading white
|
|
|
|
s/\s+$//; # no trailing white
|
|
|
|
next unless length; # anything left?
|
|
|
|
my ($var, $value) = split(/\s*=\s*/, $_, 2);
|
|
|
|
$config{$var} = $value;
|
|
|
|
}
|
|
|
|
close CONFIG;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub Get {
|
|
|
|
my $this = shift;
|
|
|
|
|
|
|
|
my %args = @_;
|
|
|
|
my $var = $args{'var'};
|
|
|
|
|
|
|
|
if ($config{$var}) {
|
|
|
|
return $config{$var};
|
|
|
|
} else {
|
|
|
|
die("No such config variable: $var\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-09 04:23:34 +03:00
|
|
|
sub Exists {
|
|
|
|
my $this = shift;
|
|
|
|
my %args = @_;
|
|
|
|
|
|
|
|
my $var = $args{'var'};
|
|
|
|
return exists($config{$var});
|
|
|
|
}
|
|
|
|
|
2006-12-05 22:58:38 +03:00
|
|
|
1;
|