DS/Transformer/Opaque.pm

filter: Statementstmt 84.0% 37 / 44 Branchbran 75.0% 6 / 8 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 69.2% 9 / 13 Podpod 50.0% 3 / 6 totaltotal 70.3% 57 / 81 CC 7 SCAR 9.0
CC
7
Cov
78%
source
4.2
target
4.1
validate_source
2.0
CRAP 2.5
« DS/Importer.pm ↑ Summary DS/Transformer/TabStreamWriter.pm »
1 #!perl
2
3 # ########################################################################## #
4 # Title: Opaque transformer
5 # Creation date: 2007-03-05
6 # Author: Michael Zedeler
7 # Description: Provides opaque bindings between some internal transformers
8 # and external transformers
9 # Data Stream class
10 # Data transformer
11 # File: $Source: /data/cvs/lib/DSlib/lib/DS/Transformer/Opaque.pm,v $
12 # Repository: kronhjorten
13 # State: $State: Exp $
14 # Documentation: inline
15 # Recepient: -
16 # ########################################################################## #
17
18 package DS::Transformer::Opaque;
19
20 1 ▶use base qw{ DS::Transformer };
Subroutine BEGIN: called CC=1 SCAR=0.0
21
22 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Carp qw{ confess croak };
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use Carp::Assert;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use DS::Source::Push;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use DS::Target::Sub;
Subroutine BEGIN: called CC=1 SCAR=0.0
27
28 1 our ($VERSION) = $DS::VERSION;
29 1 our ($REVISION) = '$Revision: 1.1 $' =~ /(\d+\.\d+)/;
30
31
32 3 ▶sub source {
Subroutine source: called CC=4 SCAR=14.3
Pod documented
33 3 my( $self, $source ) = @_;
34
35 3 my $result = $self->SUPER::source( $source );
36 3 ▶ if( $source ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source) 1 2 3
37 1 ▶ $self->{internal_source} = new DS::Source::Push( $source->out_type )
Branch: 1 branch
BranchTrueFalseTotal
$self->{"internal_source"} = "DS::Source::Push"->new($source->out_type) or confess("Fatal error while trying to create source proxy object.") 1 0 1
38 or confess("Fatal error while trying to create source proxy object.");
39 1 ▶ $result &&= $self->attach_source_internal( $self->{internal_source} );
Condition33%1/3
$result &&= $self->attach_source_internal($self->{"internal_source"})
!ll&&!rl&&r
001
MC/DC0%0/2
$result &&= $self->attach_source_internal($self->{"internal_source"})
$result $self->attach_source_internal($self->{"internal_source"})
Truth table33%1/3
A &&= B
A= $resultB= $self->attach_source_internal($self->{"internal_source"})
ABresult
0X0
100
111
40 }
41 3 return $result;
42 }
43
44 30 ▶sub target {
Subroutine target: called CC=4 SCAR=14.2
Pod documented
45 30 my( $self, $target ) = @_;
46
47 30 my $result = $self->SUPER::target( $target );
48 30 ▶ if( $target ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target) 1 29 30
49 $self->{internal_target} = new DS::Target::Sub(
50 13 ▶ sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
51 13 my( undef, $row ) = @_;
52 13 $self->pass_row( $row );
53 },
54 1 ▶ $target->in_type
Branch: 1 branch
BranchTrueFalseTotal
$self->{"internal_target"} = "DS::Target::Sub"->new(sub { my(undef, $row) = @_; $self->pass_row($row); } , $target->in_type) or confess("Fatal error while trying to create target proxy object.") 1 0 1
55 ) or confess("Fatal error while trying to create target proxy object.");
56 1 ▶ $result &&= $self->attach_target_internal( $self->{internal_target} );
Condition33%1/3
$result &&= $self->attach_target_internal($self->{"internal_target"})
!ll&&!rl&&r
001
MC/DC0%0/2
$result &&= $self->attach_target_internal($self->{"internal_target"})
$result $self->attach_target_internal($self->{"internal_target"})
Truth table33%1/3
A &&= B
A= $resultB= $self->attach_target_internal($self->{"internal_target"})
ABresult
0X0
100
111
57 }
58 30 return $result;
59 }
60
61 0 ▶sub validate_source {
Subroutine validate_source: not called CC=1 SCAR=6.9
Pod undocumented
62 # In DS::Transformer::Stack validation is done elsewhere.
63 # Proxies causes validation to happen at two places:
64 # (1) top-of-stack and target and (2) bottom-of-stack and source
65 0 return 1;
66 }
67
68 0 ▶sub receive_row {
Subroutine receive_row: not called CC=1 SCAR=6.9
Pod documented
69 0 my( $self, $row ) = @_;
70
71 0 assert( $self->{internal_source}, 'Cannot receive rows from undefined source' );
72 0 $self->{internal_source}->receive_row( $row );
73
74 0 return;
75 }
76
77 # The following methods are delegated to the internal object
78 1 foreach my $internal_method ( qw{ target source } ) {
79 0 ▶ eval <<"END_METHOD"; ## no critic
Subroutine attach_source_internal: not called CC=1 SCAR=2.6
Subroutine attach_target_internal: not called CC=1 SCAR=2.6
Pod undocumented
Pod undocumented
80 sub attach_${internal_method}_internal {
81 croak("This method must be overridden. You probably want to proxy it to the internal object that needs to be hidden from the outside.");
82
83 }
84 END_METHOD
85 }
86
87 1 1;
« DS/Importer.pm ↑ Summary DS/Transformer/TabStreamWriter.pm »