IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7830


Ignore:
Timestamp:
Jul 6, 2006, 11:49:28 AM (20 years ago)
Author:
jhoblitt
Message:

fix MULTI METADATA support

Location:
trunk/PS-IPP-Metadata-Config
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/PS-IPP-Metadata-Config/lib/PS/IPP/Metadata/Config.pm

    r3843 r7830  
    11# Copyright (c) 2005  Joshua Hoblitt
    22#
    3 # $Id: Config.pm,v 1.16 2005-05-04 22:09:28 jhoblitt Exp $
     3# $Id: Config.pm,v 1.17 2006-07-06 21:49:27 jhoblitt Exp $
    44
    55package PS::IPP::Metadata::Config;
     
    208208            } else {
    209209                $return = undef;
     210            }
     211
     212            if ( defined $thisparser->{local}{name}{ $item{metadata_name} } ) {
     213                $return->{multi}++
     214                    if $thisparser->{local}{name}{ $item{metadata_name} } =~ /MULTI/;
     215            } else {
     216                $thisparser->{local}{name}{ $item{metadata_name} }++;
    210217            }
    211218        }
  • trunk/PS-IPP-Metadata-Config/t/06_multi.t

    r3496 r7830  
    33# Copyright (C) 2005  Joshua Hoblitt
    44#
    5 # $Id: 06_multi.t,v 1.5 2005-03-24 22:32:55 jhoblitt Exp $
     5# $Id: 06_multi.t,v 1.6 2006-07-06 21:49:28 jhoblitt Exp $
    66
    77use strict;
     
    1515use PS::IPP::Metadata::Config;
    1616
    17 my $config_parser = PS::IPP::Metadata::Config->new;
    18 
    1917{
    2018my $example = q{
     
    2422foo BOOL    T
    2523};
    26     my $config = $config_parser->parse( $example );
     24    my $config = PS::IPP::Metadata::Config->new->parse( $example );
    2725    ok( defined( $config ), "basic MULTI");
    2826}
     
    3533foo BOOL    T           #
    3634};
    37     my $config = $config_parser->parse( $example );
     35    my $config = PS::IPP::Metadata::Config->new->parse( $example );
    3836    ok( defined( $config ), "MULTI with comments");
    3937}
     
    5250END
    5351};
    54     my $config = $config_parser->parse( $example );
     52    my $config = PS::IPP::Metadata::Config->new->parse( $example );
    5553    ok( defined( $config ), "MULTI not visible in lower scopes");
    5654}
     
    6664END
    6765};
    68     my $config = $config_parser->parse( $example );
    69     ok( defined( $config ), "MULTI METADATA");
    70 }
    71 
    72 {
    73 my $example = q{
    74 foo METADATA
    75     bar BOOL    T
    76 END
    77 foo METADATA
    78     bar BOOL    T
    79 END
    80 };
    81     my $config = $config_parser->parse( $example );
     66    my $config = PS::IPP::Metadata::Config->new->parse( $example );
    8267
    8368    my $tree = [
     
    9277                        }],
    9378        },
     79        {
     80            name    => 'foo',
     81            class   => 'metadata',
     82            value   => [{
     83                            name    => 'bar',
     84                            class   => 'scalar',
     85                            type    => 'BOOL',
     86                            value   => 1,
     87                        }],
     88        },
    9489    ];
    9590
     91    is_deeply( $config, $tree, "MULTI METADATA structure, declared" );
     92}
     93
     94{
     95my $example = q{
     96foo METADATA
     97    bar BOOL    T
     98END
     99foo METADATA
     100    bar BOOL    T
     101END
     102};
     103    my $config = PS::IPP::Metadata::Config->new->parse( $example );
     104
     105    my $tree = [
     106        {
     107            name    => 'foo',
     108            class   => 'metadata',
     109            value   => [{
     110                            name    => 'bar',
     111                            class   => 'scalar',
     112                            type    => 'BOOL',
     113                            value   => 1,
     114                        }],
     115        },
     116    ];
     117
    96118    is_deeply( $config, $tree, "MULTI METADATA structure, not declared" );
    97119}
     
    104126foo  bar x y z
    105127};
    106     my $config = $config_parser->parse( $example );
     128    my $config = PS::IPP::Metadata::Config->new->parse( $example );
    107129    ok( defined( $config ), "MULTI TYPE");
    108130}
     
    115137foo  bar x y z
    116138};
    117     my $config = $config_parser->parse( $example );
     139    my $config = PS::IPP::Metadata::Config->new->parse( $example );
    118140
    119141    ok( defined( $config ), "MULTI TYPE");
     
    126148foo  bar x y z
    127149};
    128     my $config = $config_parser->parse( $example );
     150    my $config = PS::IPP::Metadata::Config->new->parse( $example );
    129151
    130152    my $tree = [
     
    166188END
    167189};
    168     my $config = $config_parser->parse( $example );
     190    my $config = PS::IPP::Metadata::Config->new->parse( $example );
    169191    # ok because of overwrite
    170192    ok( defined( $config ), "MULTI not in scope");
     
    179201foo STR     bar baz
    180202};
    181     my $config = $config_parser->parse( $example );
     203    my $config = PS::IPP::Metadata::Config->new->parse( $example );
    182204    # ok because of overwrite
    183205    ok( defined( $config ), "MULTI not in scope");
     
    193215END
    194216};
    195     my $config = $config_parser->parse( $example );
     217    my $config = PS::IPP::Metadata::Config->new->parse( $example );
    196218    # ok because of overwrite
    197219    ok( defined( $config ), "MULTI not in scope");
     
    204226foo S8      -1
    205227};
    206     my $config = $config_parser->parse( $example );
     228    my $config = PS::IPP::Metadata::Config->new->parse( $example );
    207229    ok( !defined( $config ), "MULTI redeclaration");
    208230}
     
    213235foo STR     bar baz
    214236};
    215     my $config = $config_parser->parse( $example );
     237    my $config = PS::IPP::Metadata::Config->new->parse( $example );
    216238    # ok because of overwrite
    217239    ok( defined( $config ), "missing MULTI declaration");
Note: See TracChangeset for help on using the changeset viewer.