blib/lib/Net/Blogger/Engine/Slash/slashcode.pm

filter: Statementstmt 41.3% 24 / 58 Branchbran 0.0% 0 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 42.8% 6 / 14 Podpod 100% 7 / 7 totaltotal 38.1% 37 / 97 SCAR 37.4
CC
10
Cov
32%
add_entry
12.0
modify_entry
12.0
Proxy
6.0
CRAP 42.0
« blib/lib/Net/Blogger/Engine/Userland.pm ↑ Summary blib/lib/Net/Blogger/Engine/Movabletype.pm »
1 {
2
3 1 =head1 NAME
4
5 Net::Blogger::Engine::Slash::slashcode - Adds support for the Slashcode SOAP API.
6
7 =head1 SYNOPSIS
8
9 There is none since this is the black box you're not supposed to look in.
10
11 Please docs for consult L<Net::Blogger::Engine::Slash>.
12
13 =head1 DESCRIPTION
14
15 Adds support for the Slashcode SOAP API.
16
17 =cut
18
19 package Net::Blogger::Engine::Slash::slashcode;
20 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
21
22 1 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Digest::MD5 'md5_hex';
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use HTTP::Cookies;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
26
27 1 ▶use Net::Blogger::Engine::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
28
29 1 $Net::Blogger::Engine::Slash::slashcode::VERSION = '1.0';
30
31 1 @Net::Blogger::Engine::Slash::slashcode::ISA = qw ( Net::Blogger::Engine::Base );
32 1 @Net::Blogger::Engine::Slash::slashcode::EXPORT = qw ();
33 1 @Net::Blogger::Engine::Slash::slashcode::EXPORT_OK = qw ();
34
35 sub Transport {
36 0 ▶ return "SOAP";
Subroutine Transport: not called CC=1 SCAR=6.9
Pod documented
37 }
38
39 sub Proxy {
40 0 ▶ my $self = shift;
Subroutine Proxy: not called CC=2 SCAR=17.9
Pod documented
41 0 my $proxy = shift;
42
43 0 ▶ if ($proxy) {
Branch: 1 branch
BranchTrueFalseTotal
if ($proxy) 0 0 0
44 0 $self->{'_cookie'} = undef;
45 0 $self->{'_client'} = undef;
46
47 0 $self->{'_Proxy'} = $proxy;
48 }
49
50 return (
51 0 $self->{'_Proxy'},
52 cookie_jar => $self->_setUserCookie(),
53 );
54 }
55
56 =head1 OBJECT METHODS
57
58 =head2 $pkg->Proxy()
59
60 Return the URI of the Slashcode XML-RPC proxy
61
62 =head2 $pkg->Transport
63
64 Just returns SOAP by default
65
66 =head1 SLASHCODE SOAP METHODS
67
68 =head2 $pkg->add_entry(\%args)
69
70 Valid arguments are
71
72 =over
73
74 =item *
75
76 B<subject>
77
78 =item *
79
80 B<body>
81
82 =back
83
84 Releases prior to Net::Blogger 0.85 accepted a list of arguments
85 rather than a reference. Version 0.85+ are backwards compatible.
86
87 Returns a postid or false.
88
89 =cut
90
91 sub add_entry {
92 0 ▶ my $self = shift;
Subroutine add_entry: not called CC=3 SCAR=24.8
Pod documented
93 0 ▶ my $args = (ref($_[0]) eq "HASH") ? shift : { @_ };
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
94
95 my $call = $self->_Client()->call(
96 "add_entry",
97 $self->_Type(string=>$args->{"subject"}),
98 0 $self->_Type(string=>$args->{"body"}),
99 );
100
101 0 ▶ return ($call) ? $call->result() : return 0;
Branch: 1 branch
BranchTrueFalseTotal
$call ? : 0 0 0
102 }
103
104 =head2 $pkg->get_entry($id)
105
106 Returns a hash ref whose keys are :
107
108 =over 4
109
110 =item *
111
112 B<body>
113
114 =item *
115
116 B<discussion_id>
117
118 =item *
119
120 B<subject>
121
122 =item *
123
124 B<url>
125
126 =item *
127
128 B<posttype>
129
130 =item *
131
132 B<id>
133
134 =item *
135
136 B<date>
137
138 =item *
139
140 B<tid>
141
142 =item *
143
144 B<nickname>
145
146 =item *
147
148 B<uid>
149
150 =back
151
152 =cut
153
154 sub get_entry {
155 0 ▶ my $self = shift;
Subroutine get_entry: not called CC=2 SCAR=17.9
Pod documented
156
157 0 my $call = $self->_Client()->call(
158 "get_entry",
159 $self->_Type(int=>$_[0]),
160 );
161
162 0 ▶ return ($call) ? $call->result() : return 0;
Branch: 1 branch
BranchTrueFalseTotal
$call ? : 0 0 0
163 }
164
165 =head2 $pkg->get_entries($offset)
166
167 Returns an array of hashrefs (see docs for I<get_entry>), or false.
168
169 =cut
170
171 sub get_entries {
172 0 ▶ my $self = shift;
Subroutine get_entries: not called CC=2 SCAR=17.9
Pod documented
173
174 0 my $call = $self->_Client()->call("get_entries",
175 $self->_Type(string=>$self->Username()),
176 $self->_Type(int=>$_[0]),
177 );
178
179 0 ▶ return ($call) ? $call->result() : return 0;
Branch: 1 branch
BranchTrueFalseTotal
$call ? : 0 0 0
180 }
181
182 =head2 $pkg->modify_entry($id,\%args)
183
184 Returns a postid or false.
185
186 =cut
187
188 sub modify_entry {
189 0 ▶ my $self = shift;
Subroutine modify_entry: not called CC=3 SCAR=24.8
Pod documented
190 0 my $postid = shift;
191 0 ▶ my $args = (ref($_[0]) eq "HASH") ? shift : { @_ };
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
192
193 my $call = $self->_Client()->call("modify_entry",
194 $self->_Type(int=>$postid),
195 $self->_Type(string=>$args->{"subject"}),
196 0 $self->_Type(string=>$args->{"body"}),
197 );
198
199 0 ▶ return ($call) ? $call->result() : return 0;
Branch: 1 branch
BranchTrueFalseTotal
$call ? : 0 0 0
200 }
201
202 =head2 $pkg->delete_entry($id)
203
204 Returns true or false.
205
206 =cut
207
208 sub delete_entry {
209 0 ▶ my $self = shift;
Subroutine delete_entry: not called CC=2 SCAR=17.9
Pod documented
210
211 0 my $call = $self->_Client()->call("delete_entry",
212 $self->_Type(int=>$_[0]),
213 );
214
215 0 ▶ return ($call) ? $call->result() : return 0;
Branch: 1 branch
BranchTrueFalseTotal
$call ? : 0 0 0
216 }
217
218 sub _setUserCookie {
219 0 ▶ my $self = shift;
Subroutine _setUserCookie: not called CC=2 SCAR=17.9
220
221 0 ▶ if (! $self->{'_cookie'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_cookie"}) 0 0 0
222 0 my $cookie = join("::",$self->Username(),md5_hex($self->Password()));
223
224 0 $cookie =~ s/(.)/sprintf("%%%02x", ord($1))/ge;
225 0 $cookie =~ s/%/%25/g;
226 $self->{'_cookie'} = HTTP::Cookies->new()->set_cookie(0,
227 user=>$cookie,
228 '/',
229 0 URI->new($self->{'_Proxy'})->host(),
230 ),
231 }
232
233 0 return $self->{'_cookie'};
234 }
235
236 =head1 VERSION
237
238 1.0
239
240 =head1 DATE
241
242 $Date: 2005/03/26 19:29:08 $
243
244 =head1 AUTHOR
245
246 Aaron Straup Cope
247
248 =head1 TO DO
249
250 =over 4
251
252 =item *
253
254 Add full support for arguments that may be passed to I<add_entry> and I<modify_entry>
255
256 =back
257
258 =head1 SEE ALSO
259
260 L<Net::Blogger::Engine::Slash>
261
262 http://use.perl.org/~pudge/journal/3294
263
264 =head1 LICENSE
265
266 Copyright (c) 2002-2005, Aaron Straup Cope. All Rights Reserved.
267
268 This is free software, you may use it and distribute it under the same terms as Perl itself.
269
270 =cut
271
272 1 return 1;
273
274 }
« blib/lib/Net/Blogger/Engine/Userland.pm ↑ Summary blib/lib/Net/Blogger/Engine/Movabletype.pm »