r8884@llin: dpavlin | 2005-11-15 14:46:07 +0100
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 15 Nov 2005 14:31:12 +0000 (14:31 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 15 Nov 2005 14:31:12 +0000 (14:31 +0000)
 fix small warnings

git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@62 07558da8-63fa-0310-ba24-9fe276d99e06

lib/WebPAC/Normalize/XML.pm
lib/WebPAC/Output/TT.pm
t/3-normalize-xml.t

index ff7ff98..9da782f 100644 (file)
@@ -14,11 +14,11 @@ WebPAC::Normalize::XML - apply XML normalisaton rules
 
 =head1 VERSION
 
-Version 0.01
+Version 0.02
 
 =cut
 
-our $VERSION = '0.01';
+our $VERSION = '0.02';
 
 =head1 SYNOPSIS
 
@@ -44,6 +44,8 @@ C<tag> defines tag to use within C<xml_file>
 
 C<xml_file> defines path to normalize XML.
 
+C<tags> define additional tags that can be forced (and an be array).
+
 =cut
 
 sub open {
@@ -66,8 +68,11 @@ sub open {
 
        $self->{'import_xml_file'} = $xml_file;
 
+       my @force_array = [ $self->{'tag'}, 'config', 'format' ];
+       push @force_array, $self->{'tags'} if ($self->{'tags'});
+
        $self->{'import_xml'} = XMLin($xml_file,
-               ForceArray => [ $self->{'tag'}, $self->{'tags'}, 'config', 'format' ],
+               ForceArray => @force_array,
                ForceContent => 1,
        );
 
index e165e8e..77eb897 100644 (file)
@@ -110,6 +110,8 @@ filter to return values of specified from @ds
                        my ($name,$join) = @_;
 
                        die "no data array" unless ($data->{'data'} && ref($data->{'data'}) eq 'ARRAY');
+                       # Hm? Should we die here?
+                       return unless ($name);
 
                        my $item = first { $_->{'name'} eq $name } @{ $data->{'data'} };
 
index 7f5222a..eed3a4b 100755 (executable)
@@ -5,6 +5,7 @@ use Test::Exception;
 use Cwd qw/abs_path/;
 use blib;
 use strict;
+use Data::Dumper;
 
 BEGIN {
 use_ok( 'WebPAC::Normalize::XML' );
@@ -21,7 +22,7 @@ ok(my $n = new WebPAC::Normalize::XML( debug => 0 ), "new");
 
 throws_ok { $n->open() } qr/tag/, "open without tag";
 throws_ok { $n->open( tag => 'isis' ) } qr/xml_file/, "open without xml_file";
-throws_ok { $n->open( tag => 'isis', xml_file => 'foo' ) } qr/file.*doesn't exist/, "open with invalid xml_file";
+throws_ok { $n->open( tag => 'isis', xml_file => '/foo/bar/baz' ) } qr/file.*doesn't exist/, "open with invalid xml_file";
 ok( $n->open(
        tag => 'isis',
        xml_file => "$abs_path../conf/normalize/isis.xml",
@@ -35,3 +36,4 @@ my $rec = {
 
 ok(my @ds = $n->data_structure( $rec ), "data_structure");
 
+#diag Dumper(@ds);