DS/Importer/Factory.pm untested

filter: Statementstmt 0.0% 0 / 33 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 51 CC 5 SCAR 25.5
CC
5
Cov
0%
factory
30.0
BEGIN
2.0
BEGIN
2.0
CRAP 12.8
1 #!perl
2
3 # ########################################################################## #
4 # Title: Data stream importer factory
5 # Creation date: 2007-03-05
6 # Author: Michael Zedeler
7 # Description:
8 # File: $Source: /data/cvs/lib/DSlib/lib/DS/Importer/Factory.pm,v $
9 # Repository: kronhjorten
10 # State: $State: Exp $
11 # Documentation: inline
12 # Recepient: -
13 # #TODO Importers should not by default be constructed with an explicit typespec, since this may be derived from the data source
14 # ########################################################################## #
15
16 package DS::Importer::Factory;
17
18 use base qw{ DS };
19
20 use strict;
21 use Carp::Assert;
22
23 our ($VERSION) = $DS::VERSION;
24 our ($REVISION) = '$Revision: 1.1 $' =~ /(\d+\.\d+)/;
25
26 require DS::Transformer;
27 require DS::Importer::Hash;
28 require DS::Importer::Sub;
29 require DS::Importer::TabStream;
30 require DS::Importer::Sth;
31
32
33 sub factory {
34 my($class, $data_source) = @_;
35
36 if(ref($data_source) eq 'HASH') {
37 return new DS::Importer::Hash(@_);
38 } elsif(ref($data_source) eq 'CODE') {
39 return new DS::Importer::Sub( @_ );
40 } elsif($data_source->isa('IO::handle')) {
41 return new DS::Importer::TabStream( @_ );
42 } elsif($data_source->isa('DBI::st')) {
43 return new DS::Importer::Sth( @_ );
44 }
45 # TODO This wouldn't work: Needs some kind of IOC-component. A subclass of Transformer::Buffer could do the trick.
46 # elsif($data_source->isa('DS::Source')) {
47 # return new DS::Transformer( @_ );
48 # }
49
50 return;
51
52 }
53
54 1;