File Coverage

blib/lib/SSH/RPC/Result.pm
Criterion Covered Total %
statement 20 20 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod 6 6 100.0
total 34 34 100.0


line stmt bran cond sub pod time code
1             package SSH::RPC::Result;
2             $SSH::RPC::Result::VERSION = '1.204';
3 2     2   1197 use strict;
  2         4  
  2         59  
4 2     2   290 use Class::InsideOut qw(private id register);
  2         4634  
  2         15  
5              
6             =head1 NAME
7              
8             SSH::RPC::Result - Provides methods for the response from a SSH::RPC::Client run() method request.
9              
10             =head1 VERSION
11              
12             version 1.204
13              
14             =head1 DESCRIPTION
15              
16             This module is never used directly by you. Instead you'll ge a reference to this object as it's created by L.
17              
18             =head1 METHODS
19              
20             The following methods are accessible from this class.
21              
22             =cut
23              
24             private response => my %response;
25              
26             #-------------------------------------------------------------------
27              
28             =head2 getError ()
29              
30             Returns the human readable error message (if any).
31              
32             =cut
33              
34             sub getError {
35 2     2 1 3 my $self = shift;
36 2         11 return $response{id $self}{error};
37             }
38              
39             #-------------------------------------------------------------------
40              
41             =head2 getResponse ()
42              
43             Returns the return value(s) from the RPC, whether that be a scalar value, or a hash reference or array reference.
44              
45             =cut
46              
47             sub getResponse {
48 5     5 1 66 my $self = shift;
49 5         25 return $response{id $self}{response};
50             }
51              
52             #-------------------------------------------------------------------
53              
54             =head2 getShellVersion ()
55              
56             Returns the $VERSION from the shell. This is useful if you have different versions of your shell running on different machines, and you need to do something differently to account for that.
57              
58             =cut
59              
60             sub getShellVersion {
61 1     1 1 2 my $self = shift;
62 1         5 return $response{id $self}{version};
63             }
64              
65             #-------------------------------------------------------------------
66              
67             =head2 getStatus ()
68              
69             Returns a status code for the RPC. The built in status codes are:
70              
71             200 - Success.
72             400 - Malform request received by shell.
73             405 - RPC called a method that doesn't exist.
74             406 - Error transmitting RPC.
75             408 - Connection error.
76             500 - An undefined error occured in the shell.
77             510 - Error translating return document in client.
78             511 - Error translating return document in shell.
79              
80             =cut
81              
82             sub getStatus {
83 4     4 1 69 my $self = shift;
84 4         21 return $response{id $self}{status};
85             }
86              
87             #-------------------------------------------------------------------
88              
89             =head2 isSuccess ()
90              
91             Returns true if the request was successful, or false if it wasn't.
92              
93             =cut
94              
95             sub isSuccess {
96 2     2 1 4 my $self = shift;
97 2         5 return ($self->getStatus == 200);
98             }
99              
100             #-------------------------------------------------------------------
101              
102             =head2 new ( result )
103              
104             Constructor.
105              
106             =head3 result
107              
108             Result hash ref data structure generated by SSH::RPC::Client.
109              
110             =cut
111              
112             sub new {
113 4     4 1 411 my ($class, $result) = @_;
114 4         10 my $self = register($class);
115 4         59 $response{id $self} = $result;
116 4         11 return $self;
117             }
118              
119             =head1 PREREQS
120              
121             This package requires the following modules:
122              
123             L
124              
125             =head1 AUTHOR
126              
127             JT Smith
128              
129             =head1 LEGAL
130              
131             -------------------------------------------------------------------
132             SSH::RPC::Result is Copyright 2008-2009 Plain Black Corporation
133             and is licensed under the same terms as Perl itself.
134             -------------------------------------------------------------------
135             http://www.plainblack.com info@plainblack.com
136             -------------------------------------------------------------------
137              
138             =cut
139              
140              
141             1;