File Coverage

blib/lib/Win32/SqlServer/DTS/TaskFactory.pm
Criterion Covered Total %
statement 12 20 60.0
branch 0 2 0.0
condition n/a
subroutine 4 5 80.0
pod 1 1 100.0
total 17 28 60.7


line stmt bran cond sub pod time code
1             package Win32::SqlServer::DTS::TaskFactory;
2            
3             =head1 NAME
4            
5             Win32::SqlServer::DTS::TaskFactory - a Perl abstract class to create DTS Package Tasks in a polymorphic way
6            
7             =head1 SYNOPSIS
8            
9             use Win32::SqlServer::DTS::TaskFactory;
10            
11             # $task is a unknow DTS Task object
12             my $new_task = Win32::SqlServer::DTS::TaskFactory::create($task);
13             print $new_task->to_string, "\n";
14            
15             =head1 DESCRIPTION
16            
17             C creates C subclasses objects depending on the type of the DTS Package Task object
18             passed as a reference.
19            
20             =head2 EXPORT
21            
22             Nothing.
23            
24             =cut
25            
26 1     1   14287 use strict;
  1         1  
  1         27  
27 1     1   3 use warnings;
  1         1  
  1         23  
28 1     1   4 use Carp;
  1         1  
  1         57  
29 1     1   292 use Win32::SqlServer::DTS::TaskTypes;
  1         2  
  1         76  
30            
31             =head2 METHODS
32            
33             =head3 create
34            
35             Expects a C object passed as a parameter.
36            
37             Returns a object from a subclass of C depending on the C property from the C
38             object passed as a parameter.
39            
40             =cut
41            
42             sub create {
43            
44 0     0 1   my $task = shift;
45 0           my $type_converted = Win32::SqlServer::DTS::TaskTypes::convert( $task->CustomTaskID );
46            
47 0 0         if ( defined($type_converted) ) {
48            
49             # using DOS directory separator
50 0           my $location = 'Win32\\SqlServer\\DTS\\Task\\' . $type_converted . '.pm';
51 0           my $new_class = 'Win32::SqlServer::DTS::Task::' . $type_converted;
52            
53 0           require $location;
54            
55 0           return $new_class->new( $task );
56            
57             }
58             else {
59            
60 0           croak $task->CustomTaskID . ' is not a implemented Win32::SqlServer::DTS::Task subclass';
61            
62             }
63            
64             }
65            
66             1;
67            
68             __END__