From: Chris Cormack Date: Tue, 27 Aug 2013 22:56:06 +0000 (+1200) Subject: Starting work on the configuration module X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=e56c89621a7560160848c8fb6b51a66f13493f33;p=working%2FNCIPServer.git Starting work on the configuration module Based on Config::Merge because Grant who I work with and who is the author of XML::Simple will hassle me mercilessly if it start writing new code using XML::Simple Signed-off-by: Jason Stephenson --- diff --git a/lib/NCIP/Configuration.pm b/lib/NCIP/Configuration.pm new file mode 100644 index 0000000..74eee3a --- /dev/null +++ b/lib/NCIP/Configuration.pm @@ -0,0 +1,35 @@ +package NCIP::Configuration; +# +#=============================================================================== +# +# FILE: Configuration.pm +# +# DESCRIPTION: +# +# FILES: --- +# BUGS: --- +# NOTES: --- +# AUTHOR: Chris Cormack (rangi), chrisc@catalyst.net.nz +# ORGANIZATION: Koha Development Team +# VERSION: 1.0 +# CREATED: 28/08/13 10:16:55 +# REVISION: --- +#=============================================================================== + +=head1 NAME + + NCIP::Configuration + +=head1 SYNOPSIS + + use NCIP::Configuration; + my $config = NCIP::Configuration->new($config_dir); + +=cut + +use Modern::Perl; + +use base qw(Config::Merge); + +1; + diff --git a/t/NCIP_Configuration.t b/t/NCIP_Configuration.t new file mode 100644 index 0000000..bba7fce --- /dev/null +++ b/t/NCIP_Configuration.t @@ -0,0 +1,32 @@ +# +#=============================================================================== +# +# FILE: NCIP_Configuration.t +# +# DESCRIPTION: +# +# FILES: --- +# BUGS: --- +# NOTES: --- +# AUTHOR: Chris Cormack (rangi), chrisc@catalyst.net.nz +# ORGANIZATION: Koha Development Team +# VERSION: 1.0 +# CREATED: 28/08/13 10:35:44 +# REVISION: --- +#=============================================================================== + +use strict; +use warnings; + +use Test::More tests => 4; # last test to print + +use_ok('NCIP::Configuration'); + +ok( my $config = NCIP::Configuration->new('../t/config_sample'), + 'Creating a config object' ); + +# because the file is called NCIP.xml we now have that namespace +ok( my $server_params = $config->('NCIP.server-params'), 'Get server-params' ); + +is( $server_params->{'min_servers'}, 1, 'Do we have a minimum of one server' ); + diff --git a/t/config_sample/NCIP.xml b/t/config_sample/NCIP.xml new file mode 100644 index 0000000..7fc02e2 --- /dev/null +++ b/t/config_sample/NCIP.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + +