summaryrefslogtreecommitdiff
path: root/libpiny
diff options
context:
space:
mode:
Diffstat (limited to 'libpiny')
-rw-r--r--libpiny/lib/Piny/Config.pm41
1 files changed, 29 insertions, 12 deletions
diff --git a/libpiny/lib/Piny/Config.pm b/libpiny/lib/Piny/Config.pm
index b949198..aaa415a 100644
--- a/libpiny/lib/Piny/Config.pm
+++ b/libpiny/lib/Piny/Config.pm
@@ -88,7 +88,12 @@ sub _build__conf {
my $conf;
if ( $s->has_confpath and -e $s->confpath ) {
- $conf = Config::Simple->new( $s->confpath )->vars;
+ $conf = Config::Simple->new( $s->confpath );
+ if ( defined $conf ) {
+ $conf = $conf->vars;
+ } else {
+ $conf = { };
+ };
} else {
$conf = { };
};
@@ -97,11 +102,15 @@ sub _build__conf {
if ( -s $home ) {
- my $userconf = Config::Simple->new( $home )->vars;
+ my $userconf = Config::Simple->new( $home );
+
+ if ( defined $userconf ) {
+ $userconf = $userconf->vars;
- foreach my $key ( keys %$userconf ) {
- if ( not exists $conf->{$key} ) {
- $conf->{$key} = $userconf->{$key};
+ foreach my $key ( keys %$userconf ) {
+ if ( not exists $conf->{$key} ) {
+ $conf->{$key} = $userconf->{$key};
+ };
};
};
@@ -109,11 +118,15 @@ sub _build__conf {
if ( -s "/etc/piny-default.conf" ) {
- my $default = Config::Simple->new( "/etc/piny-default.conf" )->vars;
+ my $default = Config::Simple->new( "/etc/piny-default.conf" );
- foreach my $key ( keys %$default ) {
- if ( not exists $conf->{$key} ) {
- $conf->{$key} = $default->{$key};
+ if ( defined $default ) {
+ $default = $default->vars;
+
+ foreach my $key ( keys %$default ) {
+ if ( not exists $conf->{$key} ) {
+ $conf->{$key} = $default->{$key};
+ };
};
};
@@ -121,10 +134,14 @@ sub _build__conf {
if ( -s "/etc/piny-override.conf" ) {
- my $override = Config::Simple->new( "/etc/piny-override.conf" )->vars;
+ my $override = Config::Simple->new( "/etc/piny-override.conf" );
+
+ if ( defined $override ) {
+ $override = $override->vars;
- foreach my $key ( keys %$override ) {
- $conf->{$key} = $override->{$key};
+ foreach my $key ( keys %$override ) {
+ $conf->{$key} = $override->{$key};
+ };
};
};