Result.pm

filter: Statementstmt 100% 23 / 23 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 6 / 6 totaltotal 100% 37 / 37 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
getError
1.0
CRAP 1.0
« Shell.pm ↑ Summary
1 package SSH::RPC::Result;
2 2 $SSH::RPC::Result::VERSION = '1.203';
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Class::InsideOut qw(private id register);
Subroutine BEGIN: called CC=1 SCAR=0.0
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.203
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<SSH::RPC::Client>.
17  
18 =head1 METHODS
19  
20 The following methods are accessible from this class.
21  
22 =cut
23  
24 2 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 ▶ my $self = shift;
Subroutine getError: called CC=1 SCAR=0.0
Pod documented
36 2 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 ▶ my $self = shift;
Subroutine getResponse: called CC=1 SCAR=0.0
Pod documented
49 5 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 ▶ my $self = shift;
Subroutine getShellVersion: called CC=1 SCAR=0.0
Pod documented
62 1 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 ▶ my $self = shift;
Subroutine getStatus: called CC=1 SCAR=0.0
Pod documented
84 4 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 ▶ my $self = shift;
Subroutine isSuccess: called CC=1 SCAR=0.0
Pod documented
97 2 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 ▶ my ($class, $result) = @_;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
114 4 my $self = register($class);
115 4 $response{id $self} = $result;
116 4 return $self;
117 }
118  
119 =head1 PREREQS
120  
121 This package requires the following modules:
122  
123 L<Class::InsideOut>
124  
125 =head1 AUTHOR
126  
127 JT Smith <jt_at_plainblack_com>
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 2 1;
« Shell.pm ↑ Summary