diff options
author | Julian Blake Kongslie <jblake@omgwallhack.org> | 2010-10-11 22:06:54 -0700 |
---|---|---|
committer | jblake+piny@omgwallhack.org <jblake@omgwallhack.org> | 2010-10-11 22:06:54 -0700 |
commit | 4971af424d8780d1d01059374a061b90da34cebf (patch) | |
tree | 448da21cd6f920c8a9d563385aae134cea268c84 /usr | |
parent | 9386bbb8972a6c7f0e974f395bcc5553df32b441 (diff) | |
download | piny-code-4971af424d8780d1d01059374a061b90da34cebf.tar.gz piny-code-4971af424d8780d1d01059374a061b90da34cebf.zip |
A few correctness changes.
Diffstat (limited to 'usr')
-rw-r--r-- | usr/src/libpiny/lib/Piny/Config.pm | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/usr/src/libpiny/lib/Piny/Config.pm b/usr/src/libpiny/lib/Piny/Config.pm index 6cca2f6..0ac441b 100644 --- a/usr/src/libpiny/lib/Piny/Config.pm +++ b/usr/src/libpiny/lib/Piny/Config.pm @@ -24,6 +24,7 @@ has '_conf' => ( is => 'ro' , isa => 'HashRef[Str]' , lazy_build => 1 + , clearer => 'clear_conf' , init_arg => undef ); @@ -85,6 +86,30 @@ sub save { croak "Can't save a Piny::Config if the confpath is not set!"; }; + if ( -e "/etc/piny-override.conf" ) { + + my $override = Config::Simple->new( "/etc/piny-override.conf" )->vars; + + foreach my $key ( keys %$override ) { + if ( exists $s->_conf->{$key} and $s->_conf->{$key} eq $override->{$key} ) { + delete $s->_conf->{$key}; + }; + }; + + }; + + if ( -e "/etc/piny-default.conf" ) { + + my $default = Config::Simple->new( "/etc/piny-default.conf" )->vars; + + foreach my $key ( keys %$default ) { + if ( exists $s->_conf->{$key} and $s->_conf->{$key} eq $default->{$key} ) { + delete $s->_conf->{$key}; + }; + }; + + }; + my $cs = Config::Simple->new( syntax => "ini" ); foreach my $key ( keys %{$s->_conf} ) { @@ -113,10 +138,10 @@ sub tweakable { if ( $s->has_confpath ) { $s->save; - $s->clear__conf; + $s->clear_conf; } else { carp "Attribute $attrname modification ignored!"; - $s->clear__conf; + $s->clear_conf; my $clearer = "clear_$attr"; $s->$clearer; }; |