From e56c89621a7560160848c8fb6b51a66f13493f33 Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Wed, 28 Aug 2013 10:56:06 +1200 Subject: [PATCH] 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 --- lib/NCIP/Configuration.pm | 35 +++++++++++++++++++++++++++++++++++ t/NCIP_Configuration.t | 32 ++++++++++++++++++++++++++++++++ t/config_sample/NCIP.xml | 24 ++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 lib/NCIP/Configuration.pm create mode 100644 t/NCIP_Configuration.t create mode 100644 t/config_sample/NCIP.xml 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 @@ + + + + + + + + + + + + + + + + + + -- 2.43.2