From 4971af424d8780d1d01059374a061b90da34cebf Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Mon, 11 Oct 2010 22:06:54 -0700 Subject: A few correctness changes. --- usr/src/libpiny/lib/Piny/Config.pm | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'usr/src/libpiny/lib/Piny') 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; }; -- cgit v1.2.3