File Coverage

blib/lib/Win32/SqlServer/DTS/Package/Step/Result.pm
Criterion Covered Total %
statement 13 15 86.6
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 18 20 90.0


line stmt bran cond sub pod time code
1             package Win32::SqlServer::DTS::Package::Step::Result;
2            
3             =head1 NAME
4            
5             Win32::SqlServer::DTS::Package::Step::Result - a Perl class to represent a DTS Package Step execution result.
6            
7             =head1 SYNOPSIS
8            
9             use Win32::SqlServer::DTS::Package::Step::Result;
10            
11             =head1 DESCRIPTION
12            
13             C does not exists in the regular MS SQL Server DTS 2000 API.
14            
15             =head2 EXPORT
16            
17             Nothing.
18            
19             =cut
20            
21 1     1   13504 use strict;
  1         1  
  1         32  
22 1     1   5 use warnings;
  1         1  
  1         36  
23 1     1   4 use base qw(Class::Accessor);
  1         1  
  1         468  
24 1     1   1316 use Carp qw(confess);
  1         2  
  1         60  
25 1     1   151 use XML::Simple;
  0            
  0            
26             use Params::Validate qw(validate :types);
27             use Hash::Util qw(lock_keys);
28            
29             __PACKAGE__->follow_best_practice();
30             __PACKAGE__->mk_ro_accessors(
31             qw(exec_status step_name error_code source description));
32            
33             =head2 METHODS
34            
35             =head3 new
36            
37             Instantiates a new C. Expects as a parameter a hash reference with the following keys:
38            
39             =over
40            
41             =item *
42             error_code: scalar value.
43            
44             =item *
45             source: scalar value.
46            
47             =item *
48             description: scalar value.
49            
50             =item *
51             step_name: scalar value.
52            
53             =item *
54             is_success: "boolean". Accepts 0 or 1.
55            
56             =item *
57             exec_status: scalar value.
58            
59             =back
60            
61             =cut
62            
63             sub new {
64            
65             my $class = shift;
66            
67             validate(
68             @_,
69             {
70             error_code => { type => SCALAR },
71             source => { type => SCALAR },
72             description => { type => SCALAR },
73             step_name => { type => SCALAR },
74             is_success => { type => SCALAR, regex => qr/[10]{1}/ },
75             exec_status => { type => SCALAR }
76             }
77             );
78            
79             my $self = shift;
80            
81             bless $self, $class;
82            
83             lock_keys( %{$self} );
84            
85             return $self;
86            
87             }
88            
89             =head3 to_string
90            
91             Returns the C as a pure text content. Useful for simple reports.
92            
93             =cut
94            
95             sub to_string {
96            
97             my $self = shift;
98            
99             my @attrib_names = keys( %{$self} );
100            
101             my $string;
102            
103             foreach my $attrib_name (@attrib_names) {
104            
105             $string .= "$attrib_name => $self->{$attrib_name}\n";
106            
107             }
108            
109             return $string;
110            
111             }
112            
113             =head3 to_xml
114            
115             Returns the C as an XML content.
116            
117             =cut
118            
119             sub to_xml {
120            
121             my $self = shift;
122            
123             my $xs = XML::Simple->new();
124            
125             return $xs->XMLout($self);
126            
127             }
128            
129             =head3 is_success
130            
131             Returns true if the step was executed successfully.
132            
133             =cut
134            
135             sub is_success {
136            
137             my $self = shift;
138            
139             return $self->{is_success};
140            
141             }
142            
143             1;
144            
145             __END__