| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# This file is part of MooseX-Role-XMLRPC-Client |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# This software is Copyright (c) 2011 by Chris Weyl. |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# This is free software, licensed under: |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
# The GNU Lesser General Public License, Version 2.1, February 1999 |
|
9
|
|
|
|
|
|
|
# |
|
10
|
|
|
|
|
|
|
package MooseX::Role::XMLRPC::Client; |
|
11
|
|
|
|
|
|
|
{ |
|
12
|
|
|
|
|
|
|
$MooseX::Role::XMLRPC::Client::VERSION = '0.06'; |
|
13
|
|
|
|
|
|
|
} |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# ABSTRACT: Provide provide the needed bits to be a XML-RPC client |
|
16
|
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
22719
|
use MooseX::Role::Parameterized; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use MooseX::AttributeShortcuts; |
|
20
|
|
|
|
|
|
|
use MooseX::Types::Moose qw{ Str Bool }; |
|
21
|
|
|
|
|
|
|
use MooseX::Types::URI ':all'; |
|
22
|
|
|
|
|
|
|
use MooseX::Types::Path::Class ':all'; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use HTTP::Cookies; |
|
25
|
|
|
|
|
|
|
use RPC::XML::Client; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
use namespace::clean -except => 'meta'; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
parameter name => (is => 'ro', isa => Str, default => 'xmlrpc' ); |
|
30
|
|
|
|
|
|
|
parameter uri => (is => 'ro', isa => Uri, coerce => 1, predicate => 'has_uri'); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
parameter login_info |
|
33
|
|
|
|
|
|
|
=> (is => 'ro', isa => Bool, predicate => 'has_login_info', default => 1); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
parameter cookie_jar |
|
36
|
|
|
|
|
|
|
=> (is => 'ro', isa => File, predicate => 'has_cookie_jar', coerce => 1); |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# traits, if any, for our attributes |
|
39
|
|
|
|
|
|
|
parameter traits => ( |
|
40
|
|
|
|
|
|
|
traits => ['Array'], |
|
41
|
|
|
|
|
|
|
is => 'ro', |
|
42
|
|
|
|
|
|
|
isa => 'ArrayRef[Str]', |
|
43
|
|
|
|
|
|
|
default => sub { [] }, |
|
44
|
|
|
|
|
|
|
handles => { all_traits => 'elements' }, |
|
45
|
|
|
|
|
|
|
); |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
role { |
|
48
|
|
|
|
|
|
|
my $p = shift @_; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my $name = $p->name; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my $traits = [ Shortcuts, $p->all_traits ]; |
|
53
|
|
|
|
|
|
|
my @defaults = (traits => $traits, is => 'rw', lazy_build => 1); |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# generate our attribute & builder names... nicely sequential tho :) |
|
56
|
|
|
|
|
|
|
my $a = sub { $name . '_' . shift @_ }; |
|
57
|
|
|
|
|
|
|
my $b = sub { '_build_' . $name . '_' . shift @_ }; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
if ($p->login_info) { |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
has $a->('userid') => (@defaults, isa => Str); |
|
62
|
|
|
|
|
|
|
has $a->('passwd') => (@defaults, isa => Str); |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
requires $b->('userid'); |
|
65
|
|
|
|
|
|
|
requires $b->('passwd'); |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
requires $name . '_login'; |
|
68
|
|
|
|
|
|
|
requires $name . '_logout'; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
has $a->('uri') => (@defaults, isa => Uri, coerce => 1); |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# if we have a uri, use it; otherwise require its builder |
|
74
|
|
|
|
|
|
|
if ($p->has_uri) { method $b->('uri') => sub { $p->uri } } |
|
75
|
|
|
|
|
|
|
else { requires $b->('uri') } |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
has $a->('cookie_jar') => ( |
|
78
|
|
|
|
|
|
|
traits => $traits, |
|
79
|
|
|
|
|
|
|
is => 'ro', |
|
80
|
|
|
|
|
|
|
isa => File, |
|
81
|
|
|
|
|
|
|
coerce => 1, |
|
82
|
|
|
|
|
|
|
predicate => 1, |
|
83
|
|
|
|
|
|
|
( $p->has_cookie_jar ? (default => $p->cookie_jar) : () ), |
|
84
|
|
|
|
|
|
|
); |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
has $a->('rpc') => (@defaults, isa => 'RPC::XML::Client'); |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my $uri_method = $a->('uri'); |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# create our RPC::XML::Client appropriately |
|
91
|
|
|
|
|
|
|
method $b->('rpc') => sub { |
|
92
|
|
|
|
|
|
|
my $self = shift @_; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# twice to keep warnings from complaining... |
|
95
|
|
|
|
|
|
|
local $RPC::XML::ENCODING; |
|
96
|
|
|
|
|
|
|
$RPC::XML::ENCODING = 'UTF-8'; |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
my $rpc = RPC::XML::Client->new($self->$uri_method); |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# error bits - FIXME - we could probably do this better... |
|
101
|
|
|
|
|
|
|
$rpc->error_handler(sub { confess shift }); |
|
102
|
|
|
|
|
|
|
$rpc->fault_handler(sub { confess shift->string }); |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
$rpc->useragent->cookie_jar({}); |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
return $rpc; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
}; |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
1; |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=pod |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=encoding utf-8 |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 NAME |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
MooseX::Role::XMLRPC::Client - Provide provide the needed bits to be a XML-RPC client |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 VERSION |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This document describes version 0.06 of MooseX::Role::XMLRPC::Client - released April 03, 2012 as part of MooseX-Role-XMLRPC-Client. |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
package MultipleWiths; |
|
129
|
|
|
|
|
|
|
use Moose; |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# ... |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
# we don't want to keep any login information here |
|
134
|
|
|
|
|
|
|
with 'MooseX::Role::XMLRPC::Client' => { |
|
135
|
|
|
|
|
|
|
name => 'bugzilla', |
|
136
|
|
|
|
|
|
|
uri => 'https://bugzilla.redhat.com/xmlrpc.cgi', |
|
137
|
|
|
|
|
|
|
login_info => 0, |
|
138
|
|
|
|
|
|
|
}; |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# basic info |
|
141
|
|
|
|
|
|
|
with 'MooseX::Role::XMLRPC::Client' => { |
|
142
|
|
|
|
|
|
|
name => 'foo', |
|
143
|
|
|
|
|
|
|
uri => 'http://foo.org/a/b/c', |
|
144
|
|
|
|
|
|
|
}; |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub _build_foo_userid { 'userid' } |
|
147
|
|
|
|
|
|
|
sub _build_foo_passwd { 'passw0rd' } |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub foo_login { 'do login magic here..' } |
|
150
|
|
|
|
|
|
|
sub foo_logout { 'do logout magic here...' } |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
This is a L<Moose> role that provides methods and attributes needed to enable |
|
155
|
|
|
|
|
|
|
a class to serve as an XML-RPC client. It is parameterized through |
|
156
|
|
|
|
|
|
|
L<MooseX::Role::Parameterized>, so you can customize how it embeds in your |
|
157
|
|
|
|
|
|
|
class. You can even embed it multiple times with different parameterization, |
|
158
|
|
|
|
|
|
|
if it strikes your fancy :-) |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=for stopwords uri xmlrpc rpc |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 ROLE PARAMETERS |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
This role generates methods and attributes depending on these parameters. |
|
165
|
|
|
|
|
|
|
None of them are required. |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head2 name |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
This parameter defaults to "xmlrpc". It serves as a prefix to all generated |
|
170
|
|
|
|
|
|
|
methods and attributes. File and URI types are coerced. |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head2 uri (Uri) |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head2 login_info (Bool) |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 cookie_jar (File) |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head2 traits (ArrayRef[Str]) |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
An arrayref of traits to apply to the attributes. |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head1 METHODS/ATTRIBUTES |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
Right now, the best documentation can be found in the tests. |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Please see those modules/websites for more information related to this module. |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=over 4 |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=item * |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
L<RPC::XML::Client> |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=back |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head1 SOURCE |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
The development version is on github at L<http://github.com/RsrchBoy/moosex-role-xmlrpc-client> |
|
201
|
|
|
|
|
|
|
and may be cloned from L<git://github.com/RsrchBoy/moosex-role-xmlrpc-client.git> |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head1 BUGS |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website |
|
206
|
|
|
|
|
|
|
https://github.com/RsrchBoy/moosex-role-xmlrpc-client/issues |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
|
209
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
|
210
|
|
|
|
|
|
|
feature. |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 AUTHOR |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Chris Weyl <cweyl@alumni.drew.edu> |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
This software is Copyright (c) 2011 by Chris Weyl. |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
This is free software, licensed under: |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
The GNU Lesser General Public License, Version 2.1, February 1999 |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=cut |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
__END__ |
|
228
|
|
|
|
|
|
|
|