File Coverage

blib/lib/QualysGuard/Response/GenericReturn.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package QualysGuard::Response::GenericReturn;
2              
3 1     1   4313 use warnings;
  1         5  
  1         55  
4 1     1   8 use strict;
  1         4  
  1         49  
5              
6 1     1   6 use base qw( QualysGuard::Response );
  1         2  
  1         130  
7              
8             our $VERSION = '0.01';
9              
10              
11             # =============================================================
12             # - new
13             # =============================================================
14             sub new {
15             my ( $class, $xml ) = @_;
16              
17             my $self = __PACKAGE__->SUPER::new( $xml );
18              
19             bless $self, $class;
20              
21             # -- extract the response status
22              
23             $self->{status} = $self->findvalue('/GENERIC_RETURN/RETURN/@status')->value();
24             $self->{status_text} = $self->getNodeText('/GENERIC_RETURN/RETURN')->value();
25             $self->{status_text} =~ s/^\s+(.*)\s+$/$1/m;
26              
27             if ( $self->exists('/GENERIC_RETURN/RETURN/@number') ) {
28             $self->{status_code} = $self->findvalue('/GENERIC_RETURN/RETURN/@number')->value();
29             }
30              
31             if ( $self->{status} eq "FAILED" ) {
32             $self->{error_text} = $self->{status_text};
33             $self->{error_code} = $self->{status_code};
34             }
35              
36             return $self;
37             }
38              
39              
40              
41             # =============================================================
42             # - is_success
43             # =============================================================
44             sub is_success {
45             my $self = shift;
46             return ( $self->{status} eq "SUCCESS" ) ? 1 : 0;
47             }
48              
49              
50              
51             # =============================================================
52             # - is_warning
53             # =============================================================
54             sub is_warning {
55             my $self = shift;
56             return ( $self->{status} eq "WARNING" ) ? 1 : 0;
57             }
58              
59              
60              
61             # =============================================================
62             # - status_line
63             # =============================================================
64             sub status_line {
65             my $self = shift;
66             return $self->{status_text};
67             }
68              
69              
70              
71             1;
72              
73             __END__