File Coverage

blib/lib/DS/Importer.pm
Criterion Covered Total %
statement 16 16 100.0
branch 4 4 100.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 26 26 100.0


line stmt bran cond sub pod time code
1             #!perl
2            
3             # ########################################################################## #
4             # Title: Data stream importer
5             # Creation date: 2007-03-05
6             # Author: Michael Zedeler
7             # Description: Generates data stream data
8             # Data Stream class
9             # File: $Source: /data/cvs/lib/DSlib/lib/DS/Importer.pm,v $
10             # Repository: kronhjorten
11             # State: $State: Exp $
12             # Documentation: inline
13             # Recepient: -
14             # #TODO Importers should not by default be constructed with an explicit typespec, since this may be derived from the data source
15             # ########################################################################## #
16            
17             package DS::Importer;
18            
19 5     5   37570 use base qw{ DS::Source };
  5         11  
  5         2011  
20            
21 5     5   27 use strict;
  5         11  
  5         155  
22 5     5   26 use Carp qw{ croak cluck };
  5         7  
  5         1071  
23             require Carp::Assert;
24            
25             our ($VERSION) = $DS::VERSION;
26             our ($REVISION) = '$Revision: 1.2 $' =~ /(\d+\.\d+)/;
27            
28             #TODO Add $row to to constructor
29            
30             # This method fetches
31             sub execute {
32 18     18 1 25317 my( $self, $rows ) = @_;
33 18 100       63 $rows = -1 unless $rows;
34 18         66 while( $rows-- != 0 ) {
35 63         169 my $result = $self->_fetch();
36 62         610 $self->pass_row( $result );
37             # Exit if we just passed end of stream.
38 61 100       14625 last if not defined( $result );
39             }
40             }
41            
42             # Fetches one row from underlying data source and returns it to caller.
43             # When end of data source has been reached, this method MUST return undef on
44             # all subsequent calls.
45             # Note that this method doesn't pass anything on to any attached
46             # target.
47             # When writing importers, this is the method you will want to override.
48             # This method is private.
49             sub _fetch {
50 1     1   229 croak("This method must be overridden.");
51             }
52            
53             1;
54            
55             __END__