diff options
Diffstat (limited to 'libpiny')
-rw-r--r-- | libpiny/debian/control | 2 | ||||
-rw-r--r-- | libpiny/lib/Piny/Config.pm | 57 |
2 files changed, 20 insertions, 39 deletions
diff --git a/libpiny/debian/control b/libpiny/debian/control index 4328fc3..16f606a 100644 --- a/libpiny/debian/control +++ b/libpiny/debian/control @@ -8,7 +8,7 @@ Standards-version: 3.9.1 Package: libpiny-perl Architecture: all -Depends: ${perl:Depends}, ${misc:Depends}, libconfig-simple-perl, libdigest-hmac-perl, libdigest-sha1-perl | libdigest-sha-perl, libemail-valid-loose-perl, libmath-gmp-perl, libmoose-perl, libmoosex-singleton-perl, libmoosex-strictconstructor-perl +Depends: ${perl:Depends}, ${misc:Depends}, libconfig-gitlike-perl, libdigest-hmac-perl, libdigest-sha1-perl | libdigest-sha-perl, libemail-valid-loose-perl, libmath-gmp-perl, libmoose-perl, libmoosex-singleton-perl, libmoosex-strictconstructor-perl Description: Perl interface for the piny infrastructure This is a set of modules for accomplishing administrative tasks in the piny.be infrastructure. diff --git a/libpiny/lib/Piny/Config.pm b/libpiny/lib/Piny/Config.pm index f179d98..bb72536 100644 --- a/libpiny/lib/Piny/Config.pm +++ b/libpiny/lib/Piny/Config.pm @@ -11,7 +11,7 @@ use Moose::Util::TypeConstraints; use MooseX::StrictConstructor; use Carp; -use Config::Simple qw( -lc ); +use Config::GitLike; use Piny::Environment; @@ -87,13 +87,8 @@ sub _build__conf { my $conf; - if ( $s->has_confpath and -e $s->confpath ) { - $conf = Config::Simple->new( $s->confpath ); - if ( defined $conf ) { - $conf = $conf->vars; - } else { - $conf = { }; - }; + if ( $s->has_confpath and -s $s->confpath ) { + $conf = Config::GitLike->load_file( $s->confpath ); } else { $conf = { }; }; @@ -102,15 +97,11 @@ sub _build__conf { if ( -s $home ) { - my $userconf = Config::Simple->new( $home ); + my $userconf = Config::GitLike->load_file( $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}; }; }; @@ -118,15 +109,11 @@ sub _build__conf { if ( -s "/etc/piny-default.conf" ) { - my $default = Config::Simple->new( "/etc/piny-default.conf" ); - - if ( defined $default ) { - $default = $default->vars; + my $default = Config::GitLike->load_file( "/etc/piny-default.conf" ); - foreach my $key ( keys %$default ) { - if ( not exists $conf->{$key} ) { - $conf->{$key} = $default->{$key}; - }; + foreach my $key ( keys %$default ) { + if ( not exists $conf->{$key} ) { + $conf->{$key} = $default->{$key}; }; }; @@ -134,14 +121,10 @@ sub _build__conf { if ( -s "/etc/piny-override.conf" ) { - my $override = Config::Simple->new( "/etc/piny-override.conf" ); + my $override = Config::GitLike->load_file( "/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}; }; }; @@ -165,17 +148,17 @@ sub save { my ( $override, $userconf, $default ) = ( {}, {}, {} ); if ( -s "/etc/piny-override.conf" ) { - $override = Config::Simple->new( "/etc/piny-override.conf" )->vars; + $override = Config::GitLike->load_file( "/etc/piny-override.conf" ); }; my $home = Piny::Environment->instance->user->home . "/.gitconfig"; if ( $s->confpath ne $home and -s $home ) { - $userconf = Config::Simple->new( $home )->vars; + $userconf = Config::GitLike->load_file( $home ); }; if ( -s "/etc/piny-default.conf" ) { - $default = Config::Simple->new( "/etc/piny-default.conf" )->vars; + $default = Config::GitLike->load_file( "/etc/piny-default.conf" ); }; foreach my $key ( keys %{$s->_conf} ) { @@ -189,14 +172,12 @@ sub save { }; }; - my $cs = Config::Simple->new( syntax => "ini" ); + my $cs = Config::GitLike->new( confname => 'blank' ); foreach my $key ( keys %{$s->_conf} ) { - $cs->param( $key, $s->_conf->{$key} ); + $cs->set( key => $key, value => $s->_conf->{$key}, filename => $s->confpath ); }; - $cs->write( $s->confpath ); - $s->clear_conf; }; |