renamed _set_rec to _set_ds (because it's a data_structure actually)
and added symetric public get_ds to get whole data_structure as
hash to manually traverse in normalization
git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@983
07558da8-63fa-0310-ba24-
9fe276d99e06
package WebPAC::Normalize;
use Exporter 'import';
our @EXPORT = qw/
package WebPAC::Normalize;
use Exporter 'import';
our @EXPORT = qw/
+ _set_ds _set_lookup
+ get_ds
_set_load_row
_get_ds _clean_ds
_debug
_set_load_row
_get_ds _clean_ds
_debug
no strict 'subs';
_set_lookup( $arg->{lookup} ) if defined($arg->{lookup});
no strict 'subs';
_set_lookup( $arg->{lookup} ) if defined($arg->{lookup});
- _set_rec( $arg->{row} );
+ _set_ds( $arg->{row} );
_set_config( $arg->{config} ) if defined($arg->{config});
_clean_ds( %{ $arg } );
$load_row_coderef = $arg->{load_row_coderef};
_set_config( $arg->{config} ) if defined($arg->{config});
_clean_ds( %{ $arg } );
$load_row_coderef = $arg->{load_row_coderef};
$rec = shift or die "no record hash";
}
$rec = shift or die "no record hash";
}
+=head2 get_ds
+
+Access to original record from input module
+
+ my $ds = get_rec;
+
+=cut
+
+sub get_ds {
+ return $rec;
+}
+
=head2 _set_config
Set current config hash
=head2 _set_config
Set current config hash
-use Test::More tests => 351;
+use Test::More tests => 352;
BEGIN {
use_ok( 'WebPAC::Test' );
BEGIN {
use_ok( 'WebPAC::Test' );
ok(! _set_lookup( undef ), "set_lookup(undef)");
ok(! _set_lookup( undef ), "set_lookup(undef)");
+ _set_ds( $rec1 );
+
+ is_deeply( get_ds, $rec1, 'get_ds' );
cmp_ok( join(",", rec2('200','a') ), 'eq', '200a,200a*2', 'join rec2' );
cmp_ok( join(",", rec2('200','a'), rec2('200','b') ), 'eq', '200a,200a*2,200b', 'join rec2 rec2' );
cmp_ok( join(",", rec2('200','a') ), 'eq', '200a,200a*2', 'join rec2' );
cmp_ok( join(",", rec2('200','a'), rec2('200','b') ), 'eq', '200a,200a*2,200b', 'join rec2 rec2' );
#ok(! lookup('non-existent'), 'lookup non-existant' );
#ok(! lookup('non-existent'), 'lookup non-existant' );
test_s(qq{
search_display('Title',
test_s(qq{
search_display('Title',
my $rules = qq{ search('mixed', rec('200') ) };
_clean_ds();
my $rules = qq{ search('mixed', rec('200') ) };
_clean_ds();
test_s( $rules );
ok($ds = _get_ds(), "get_ds");
is_deeply( $ds, {
test_s( $rules );
ok($ds = _get_ds(), "get_ds");
is_deeply( $ds, {
# wird and non-valid structure which is supported anyway
_clean_ds();
# wird and non-valid structure which is supported anyway
_clean_ds();
'200' => [{
'a' => '200a',
},
'200' => [{
'a' => '200a',
},
my ($msg, $rec, $rules, $struct) = @_;
_clean_ds();
my ($msg, $rec, $rules, $struct) = @_;
_clean_ds();
foreach my $r (split(/;/, $rules)) {
$r =~ s/[\s\n\r]+/ /gs;
foreach my $r (split(/;/, $rules)) {
$r =~ s/[\s\n\r]+/ /gs;
sub test_rule {
my ($msg, $rec, $rule, $struct) = @_;
_clean_ds();
sub test_rule {
my ($msg, $rec, $rule, $struct) = @_;
_clean_ds();
$rule =~ s/\\/\\/gs;
my $r = test_s( $rule );
diag "for ", dump($rec), " got:\n", dump($r), "\nexpect:\n" if ($debug > 1);
$rule =~ s/\\/\\/gs;
my $r = test_s( $rule );
diag "for ", dump($rec), " got:\n", dump($r), "\nexpect:\n" if ($debug > 1);