File Coverage

blib/lib/Win32/SqlServer/DTS/AssignmentTypes.pm
Criterion Covered Total %
statement 16 17 94.1
branch 1 2 50.0
condition 2 6 33.3
subroutine 5 5 100.0
pod 1 1 100.0
total 25 31 80.6


line stmt bran cond sub pod time code
1             package Win32::SqlServer::DTS::AssignmentTypes;
2            
3             =head1 NAME
4            
5             Win32::SqlServer::DTS::AssigmentTypes - a Perl abstract class that knows all DynamicPropertiesTaskAssignment objects types.
6            
7             =head1 SYNOPSIS
8            
9             use Win32::SqlServer::DTS::AssignmentTypes;
10            
11             # assuming that $assignment is a DTS Dynamic Property assignment object
12             my $type = Win32::SqlServer::DTS::AssignmentTypes->get_class_name($assignment->SourceType);
13            
14             =head1 DESCRIPTION
15            
16             C is a simple abstract class that knows all existing types of DTS Dynamic Properties assignments
17             types and how to convert those types to Win32::SqlServer::DTS::Assignment subclasses names.
18            
19             This abstract class should be used only if one wants to extend the C API.
20            
21             =head2 EXPORT
22            
23             None by default.
24            
25             =cut
26            
27 2     2   31841 use strict;
  2         4  
  2         70  
28 2     2   20 use warnings;
  2         2  
  2         68  
29 2     2   11 use Carp qw(confess);
  2         4  
  2         180  
30            
31             =head2 METHODS
32            
33             =head3 get_class_name
34            
35             C is an B that converts the numeric type code from DTS API constant
36             C to a proper string that represents a subclass of C class.
37             Returns one of the following strings, depending on the numeric code received as a parameter:
38            
39             =over
40            
41             =item *
42             INI
43            
44             =item *
45             Query
46            
47             =item *
48             GlobalVar
49            
50             =item *
51             EnvVar
52            
53             =item *
54             Constant
55            
56             =item *
57             DataFile
58            
59             =back
60            
61             The valid types are:
62            
63             =begin text
64            
65             Symbol Value Description
66             ---------------------------------------------------------------------------------------------------------------
67             DTSDynamicPropertiesSourceType_Constant 4 Source is a constant.
68             DTSDynamicPropertiesSourceType_DataFile 5 Source is the contents of a data file.
69             DTSDynamicPropertiesSourceType_EnvironmentVariable 3 Source is the value of a system environment variable.
70             DTSDynamicPropertiesSourceType_GlobalVariable 2 Source is the value of a DTS global variable within
71             the package.
72             DTSDynamicPropertiesSourceType_IniFile 0 Source is the value of a key within an .ini file.
73             DTSDynamicPropertiesSourceType_Query 1 Source is a value returned by an SQL query.
74            
75             =end text
76            
77             =begin html
78            
79            
80            
81             SymbolValueDescription
82            
83             DTSDynamicPropertiesSourceType_Constant
84             4
85             Source is a constant
86            
87            
88             DTSDynamicPropertiesSourceType_DataFile
89             5
90             Source is the contents of a data file
91            
92            
93             DTSDynamicPropertiesSourceType_EnvironmentVariable
94             3
95             Source is the value of a system environment variable
96            
97            
98             DTSDynamicPropertiesSourceType_GlobalVariable
99             2
100             Source is the value of a DTS global variable within the package
101            
102            
103             DTSDynamicPropertiesSourceType_IniFile
104             0
105             Source is the value of a key within an .ini file
106            
107            
108             DTSDynamicPropertiesSourceType_Query
109             1
110             Source is a value returned by an SQL query
111            
112            
113            
114             =end html
115            
116             =cut
117            
118 2     2   12 use constant CLASSES => qw(INI Query GlobalVar EnvVar Constant DataFile);
  2         4  
  2         487  
119            
120             sub get_class_name {
121            
122 6     6 1 3550 my $type_code = $_[1];
123            
124 6 50 33     56 if ( ( defined($type_code) )
  6   33     33  
125             and ( $type_code =~ /^\d$/ )
126             and ( $type_code <= scalar( @{ [CLASSES] } ) ) )
127             {
128            
129 6         39 return (CLASSES)[$type_code];
130            
131             }
132             else {
133            
134 0           confess "Invalid type code received: $type_code\n";
135            
136             }
137            
138             }
139            
140             1;
141            
142             __END__