DS/Transformer/Multiplexer.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 46 CC 3 SCAR 16.7
CC
3
Cov
0%
source
12.0
new
2.0
process
2.0
CRAP 5.3
1 #!perl
2
3 # ########################################################################## #
4 # Title: Multiplex stream to multiple targets
5 # Creation date: 2007-03-05
6 # Author: Michael Zedeler
7 # Description: Sends stream to a series of transformers
8 # Data Stream class
9 # Data transformer
10 # File: $Source: /data/cvs/lib/DSlib/lib/DS/Transformer/Multiplexer.pm,v $
11 # Repository: kronhjorten
12 # State: $State: Exp $
13 # Documentation: inline
14 # Recepient: -
15 # ########################################################################## #
16
17 package DS::Transformer::Multiplexer;
18
19 use base qw{ DS::Transformer };
20
21 use strict;
22 use Carp::Assert;
23
24 our ($VERSION) = $DS::VERSION;
25 our ($REVISION) = '$Revision: 1.1 $' =~ /(\d+\.\d+)/;
26
27 require DS::TypeSpec;
28
29 sub new {
30 my( $class, $transformers, $in_type, $out_type, $source, $target ) = @_;
31
32 my $self = $class->SUPER::new( $in_type, $out_type, $source, $target );
33
34 return $self;
35 }
36
37 sub process {
38 my( $self, $row ) = @_;
39
40 foreach my $field (keys %{$self->{rewrite_rules}}) {
41 my( $from, $to) = @{${$self->{rewrite_rules}}{$field}};
42 $row->{$field} =~ /$from/;
43 $row->{$field} = eval("\"$to\""); ## no critic
44 }
45
46 return $row;
47 }
48
49 sub source {
50 my( $self, $source ) = @_;
51 if( defined( $source ) ) {
52 if( defined( $source->out_type ) ) {
53 $self->out_type( $source->out_type );
54 } else {
55 cluck("Can't determine what type to use as out_type, since sink $source has no out_type");
56 }
57 }
58 return $self->SUPER::source( @_ );
59 }
60
61 1;
62
63