Ticker.pm

filter: Statementstmt 20.7% 50 / 241 Branchbran 10.2% 10 / 98 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 21.4% 9 / 42 Podpod 94.4% 17 / 18 totaltotal 21.5% 88 / 409 CC 53 SCAR 28.5
CC
53
Cov
18%
cool_nodes
56.0
time_since
56.0
node_heaven
30.0
CRAP 17.3
« E2Node.pm ↑ Summary Search.pm »
1 # E2::Ticker
2 # Jose M. Weeks <jose@joseweeks.com>
3 # 17 June 2003
4 #
5 # See bottom for pod documentation.
6  
7 package E2::Ticker;
8  
9 2 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use E2::Interface;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 our @ISA = ("E2::Interface");
16 2 our $VERSION = "0.32";
17 2 our $DEBUG; *DEBUG = *E2::Interface::DEBUG;
18  
19 2 our %xml_title = (
20 interfaces => "XML Interfaces Ticker",
21 clientversions => "Client Version XML Ticker",
22 messages => "Universal Message XML Ticker",
23 session => "Personal Session XML Ticker",
24 search => "E2 XML Search Interface",
25 scratch => "Scratch Pad XML Ticker",
26 vars => "Raw VARS XML Ticker",
27 timesince => "Time Since XML Ticker",
28 usersearch => "User Search XML Ticker II",
29 heaven => "Node Heaven XML Ticker",
30 bestusers => "Everything's Best Users XML Ticker",
31 coolnodes => "Cool Nodes XML Ticker II",
32 edcools => "Editor Cools XML Ticker",
33 random => "Random Nodes XML Ticker",
34 rooms => "Available Rooms XML Ticker",
35 otherusers => "Other Users XML Ticker II",
36 newwriteups => "New Writeups XML Ticker"
37 );
38  
39 # Prototypes
40  
41 sub new;
42  
43 sub new_writeups;
44 sub other_users;
45 sub random_nodes;
46 sub cool_nodes;
47 sub editor_cools;
48 sub time_since;
49  
50 sub random_nodes_wit;
51 sub time_since_now;
52  
53 # Private
54  
55 sub parse;
56  
57 # Methods
58  
59 1 ▶sub new {
Subroutine new: called CC=2 SCAR=7.1
Pod documented
60 1 my $arg = shift;
61 1 ▶ my $class = ref( $arg ) || $arg;
Condition33%1/3
ref $arg || $arg
l!l&&r!l&&!r
010
MC/DC0%0/2
ref $arg || $arg
ref $arg $arg
Truth table33%1/3
A || B
A= ref $argB= $arg
ABresult
1X1
011
000
62 1 my $self = $class->SUPER::new();
63  
64 1 $self->{xml_interfaces} = \%xml_title;
65  
66 1 $self->{ticker_string} = undef;
67
68 1 bless( $self, $class );
69 1 return $self;
70 }
71  
72 1 ▶sub use_string {
Subroutine use_string: called CC=2 SCAR=7.1
Pod documented
73 1 ▶ my $self = shift or croak "Usage: use_string E2TICKER, STRING";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: use_string E2TICKER, STRING") 1 0 1
74 1 my $string = shift;
75  
76 1 $self->{ticker_string} = $string;
77 }
78  
79 # This method is private (undocumented). It should not be called from
80 # anywhere except internally or in derived classes.
81 #
82 # It takes the following parameters:
83 # E2TICKER - $self
84 # TYPE - Type of ticker to load
85 # HANDLERS - a reference to a hash of twig parsers
86 # LISTREF - a reference to the list we want to return
87 # OPTIONS - set of attr, val pairs used in the POST request
88  
89 1 ▶sub parse {
Subroutine parse: called CC=8 SCAR=25.2
Pod undocumented
90 1 ▶ croak "Usage: parse E2TICKER, TYPE, HANDLERS, LISTREF, [ OPTIONS ]"
Branch: 1 branch
BranchTrueFalseTotal
if @_ < 4 0 1 1
91 if @_ < 4;
92
93 1 my $self = shift;
94 1 my $type = shift;
95 1 my $handlers = shift;
96 1 my $listref = shift;
97  
98 1 ▶ warn "E2::Ticker::parse\n" if $DEBUG > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $E2::Ticker::DEBUG > 1 0 1 1
99 1 ▶ warn "Parsing $type ticker:\n" . Dumper( $handlers )
Branch: 1 branch
BranchTrueFalseTotal
if $E2::Ticker::DEBUG > 2 0 1 1
100 if $DEBUG > 2;
101  
102 # Sanity check
103  
104 1 ▶ if( ref $handlers ne 'HASH' || ref $listref ne 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $handlers ne "HASH" or ref $listref ne "ARRAY") 0 1 1
Condition33%1/3
ref $handlers ne "HASH" or ref $listref ne "ARRAY"
l!l&&r!l&&!r
001
MC/DC0%0/2
ref $handlers ne "HASH" or ref $listref ne "ARRAY"
ref $handlers ne "HASH" ref $listref ne "ARRAY"
Truth table33%1/3
A or B
A= ref $handlers ne "HASH"B= ref $listref ne "ARRAY"
ABresult
1X1
011
000
105 0 croak "Usage: parse E2TICKER, TYPE, HANDLERS, LISTREF, " .
106 "[ OPTIONS ]";
107 }
108  
109 # Note: The exception below will only be raised if there are
110 # bugs in e2interface, unless applications are calling
111 # E2::Ticker::parse on their own, which they shouldn't be
112 # doing. This exception is undocumented (it is not
113 # thrown by any documented methods).
114  
115 1 my $title = $self->{xml_interfaces}->{$type};
116 1 ▶ if( !$title ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($title) 0 1 1
117 0 croak "Invalid ticker type: $type";
118 }
119  
120 # This is here in case (for some oddball reason) someone wants
121 # to load a ticker from a text string. This is used for the test
122 # cases, and probably for cacheing and so on...
123  
124 1 ▶ if( my $s = $self->{ticker_string} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $s = $self->{"ticker_string"}) 1 0 1
125 1 $self->{ticker_string} = undef;
126 1 $self->parse_twig( $s, $handlers );
127 0 return @$listref;
128 }
129
130 # Otherwise, do the normal thing, which is to load the
131 # node from e2.
132  
133 return $self->thread_then(
134 [
135 \&E2::Interface::process_request,
136 $self,
137 node => $title,
138 @_
139 ],
140 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
141 0 $self->parse_twig(shift, $handlers);
142 0 return @$listref;
143 }
144 0 );
145 }
146  
147 0 ▶sub load_interfaces {
Subroutine load_interfaces: not called CC=4 SCAR=30.0
Pod documented
148 0 ▶ my $self = shift or croak "Usage: interfaces E2TICKER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: interfaces E2TICKER") 0 0 0
149  
150 0 ▶ warn "E2::Ticker::load_interfaces\n" if $DEBUG > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $E2::Ticker::DEBUG > 1 0 0 0
151
152 my $handlers = {
153 0 ▶ 'this' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
154 0 (my $a, my $b) = @_;
155 $self->{xml_interfaces}->{interfaces} =
156 0 $b->text;
157 },
158 0 ▶ 'xmlexport' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
159 0 (my $a, my $b) = @_;
160 0 my $c = $b->{att}->{iface};
161 0 $self->{xml_interfaces}->{$c} = $b->text;
162 }
163 0 };
164  
165 # Since we're loading a URL instead of a node or node_id,
166 # we're going to have to do this one without the help
167 # of E2::Interface::process_request, and therefore without
168 # E2::Ticker::parse.
169  
170 # If we're working threaded, we have to do it the hard way
171  
172 0 ▶ if( $self->{threads} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"threads"}) 0 0 0
173 return thread_then(
174 [
175 \&E2::Interface::start_job,
176 $self,
177 'POST',
178 "http://$self->{domain}/interfaces.xml",
179 $self->{cookie},
180 $self->{agentstring},
181 links_noparse => $self->{links_noparse},
182 ],
183 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
184 0 my $response = shift;
185  
186 0 $self->{xml_interfaces} = {};
187
188 0 $self->parse_twig( $response, $handlers );
189
190 0 return 1;
191  
192 0 });
193 }
194  
195 # Otherwise, do the same as above, but without passing the work off
196 # to another thread.
197  
198 my $response = process_request_raw(
199 'POST',
200 "http://$self->{domain}/interfaces.xml",
201 $self->{cookie},
202 $self->{agentstring},
203 links_noparse => $self->{links_noparse},
204 0 );
205  
206 0 $self->cookie( extract_cookie( $response ) );
207  
208 0 my $xml = post_process( $response );
209
210 0 $self->{xml_interfaces} = {};
211  
212 0 $self->parse_twig( $xml, $handlers );
213  
214 0 return 1;
215 }
216  
217 1 ▶sub new_writeups {
Subroutine new_writeups: called CC=4 SCAR=20.4
Pod documented
218 1 ▶ my $self = shift or croak "Usage: new_writeups E2TICKER [, COUNT ]";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: new_writeups E2TICKER [, COUNT ]") 1 0 1
219 1 my $count = shift;
220  
221 1 my %opt;
222  
223 my @writeups;
224  
225 1 ▶ warn "E2::Ticker::new_writeups" if $DEBUG > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $E2::Ticker::DEBUG > 1 0 1 1
226  
227 1 ▶ $opt{count} = $count if $count;
Branch: 1 branch
BranchTrueFalseTotal
if $count 0 1 1
228  
229 my $handlers = {
230 0 ▶ 'wu' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
231 0 (my $a, my $b) = @_;
232 0 my $wu = {};
233
234 0 $wu->{type} = $b->{att}->{wrtype};
235  
236 0 my $c = $b->first_child('e2link');
237
238 0 $wu->{title} = $c->text;
239 0 $wu->{id} = $c->{att}->{node_id};
240  
241 0 $c = $b->first_child('author')->first_child('e2link');
242 0 $wu->{author} = $c->text;
243 0 $wu->{author_id} = $c->{att}->{node_id};
244
245 0 $c = $b->first_child('parent')->first_child('e2link');
246 0 $wu->{parent} = $c->text;
247 0 $wu->{parent_id} = $c->{att}->{node_id};
248
249 0 push @writeups, $wu;
250 }
251 1 };
252  
253 1 return $self->parse( 'newwriteups', $handlers, \@writeups, %opt );
254 }
255  
256 0 ▶sub other_users {
Subroutine other_users: not called CC=4 SCAR=30.0
Pod documented
257 0 ▶ my $self = shift or croak "Usage: other_users E2TICKER [, ROOM_ID ]";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: other_users E2TICKER [, ROOM_ID ]") 0 0 0
258 0 my $room = shift;
259  
260 0 my @users;
261
262 0 ▶ warn "E2::Ticker::other_users" if $DEBUG > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $E2::Ticker::DEBUG > 1 0 0 0
263  
264 0 my %opt = ( nosort => 1 );
265 0 ▶ $opt{in_room} = $room if $room;
Branch: 1 branch
BranchTrueFalseTotal
if $room 0 0 0
266
267 my $handlers = {
268 0 ▶ 'user' => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
269 0 (my $a, my $b) = @_;
270 0 my $user = {};
271
272 0 $user->{god} = $b->{att}->{e2god};
273 0 $user->{editor} = $b->{att}->{ce};
274 0 $user->{edev} = $b->{att}->{edev};
275 0 $user->{xp} = $b->{att}->{xp};
276 0 $user->{borged} = $b->{att}->{borged};
277  
278 0 my $c = $b->first_child('e2link');
279 0 $user->{name} = $c->text;
280 0 $user->{id} = $c->{att}->{node_id};
281  
282 0 ▶ if( $c = $b->first_child('room' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c = $b->first_child("room")) 0 0 0
283 0 $user->{room} = $c->text;
284 0 $user->{room_id} = $c->{att}->{node_id};
285 }
286  
287 0 push @users, $user;
288 }
289 0 };
290  
291 0 return $self->parse( 'otherusers', $handlers, \@users, %opt );
292 }
293  
294 0 ▶sub random_nodes {
Subroutine random_nodes: not called CC=3 SCAR=24.8
Pod documented
295 0 ▶ my $self = shift or croak "Usage: random_nodes E2TICKER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: random_nodes E2TICKER") 0 0 0
296  
297 0 my @random;
298  
299 0 ▶ warn "E2::Ticker::random_nodes" if $DEBUG > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $E2::Ticker::DEBUG > 1 0 0 0
300  
301 my $handlers = {
302 0 ▶ 'e2link' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
303 0 (my $a, my $b) = @_;
304 push @random, {
305 title => $b->text,
306 id => $b->{att}->{node_id}
307 0 };
308 },
309 0 ▶ 'wit' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
310 0 (my $a, my $b) = @_;
311 0 $self->{wit} = $b->text;
312 }
313 0 };
314  
315 0 return $self->parse( 'random', $handlers, \@random );
316 }
317  
318 0 ▶sub cool_nodes {
Subroutine cool_nodes: not called CC=7 SCAR=40.3
Pod documented
319 0 ▶ my $self = shift or croak "Usage: cool_nodes E2TICKER [, WRITTEN_BY ] [, COOLED_BY ] [, COUNT ] [, OFFSET ]";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: cool_nodes E2TICKER [, WRITTEN_BY ] [, COOLED_BY ] [, COUNT ] [, OFFSET ]") 0 0 0
320 0 my $written_by = shift;
321 0 my $cooled_by = shift;
322 0 my $count = shift;
323 0 my $offset = shift;
324  
325 0 my @cools;
326  
327 0 ▶ warn "E2::Ticker::cool_nodes" if $DEBUG > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $E2::Ticker::DEBUG > 1 0 0 0
328  
329 0 my %opt;
330  
331 0 ▶ $opt{writtenby} = $written_by if $written_by;
Branch: 1 branch
BranchTrueFalseTotal
if $written_by 0 0 0
332 0 ▶ $opt{cooledby} = $cooled_by if $cooled_by;
Branch: 1 branch
BranchTrueFalseTotal
if $cooled_by 0 0 0
333 0 ▶ $opt{limit} = $count if $count;
Branch: 1 branch
BranchTrueFalseTotal
if $count 0 0 0
334 0 ▶ $opt{startat} = $offset if $offset;
Branch: 1 branch
BranchTrueFalseTotal
if $offset 0 0 0
335  
336 my $handlers = {
337 0 ▶ 'cool' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
338 0 (my $a, my $b) = @_;
339 0 my $cool = {};
340 0 my $c = $b->first_child('writeup')->first_child('e2link');
341  
342 0 $cool->{title} = $c->text;
343 0 $cool->{id} = $c->{att}->{node_id};
344  
345 0 $c = $b->first_child('author')->first_child('e2link');
346  
347 0 $cool->{author} = $c->text;
348 0 $cool->{author_id} = $c->{att}->{node_id};
349  
350 0 $c = $b->first_child('cooledby')->first_child('e2link');
351  
352 0 $cool->{cooledby} = $c->text;
353 0 $cool->{cooledby_id} = $c->{att}->{node_id};
354  
355 0 push @cools, $cool;
356 }
357 0 };
358  
359 0 return $self->parse( 'coolnodes', $handlers, \@cools, %opt );
360 }
361  
362 0 ▶sub editor_cools {
Subroutine editor_cools: not called CC=4 SCAR=30.0
Pod documented
363 0 ▶ my $self = shift or croak "Usage: editor_cools E2TICKER [, COUNT ]";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: editor_cools E2TICKER [, COUNT ]") 0 0 0
364 0 my $count = shift;
365  
366 0 my @edcools;
367
368 0 ▶ warn "E2::Ticker::editor_cools" if $DEBUG > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $E2::Ticker::DEBUG > 1 0 0 0
369  
370 0 my %opt;
371  
372 0 ▶ $opt{count} = $count if $count;
Branch: 1 branch
BranchTrueFalseTotal
if $count 0 0 0
373  
374 my $handlers = {
375 0 ▶ 'edselection' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
376 0 (my $a, my $b) = @_;
377 0 my $cool = {};
378 0 my $c = $b->first_child('endorsed');
379  
380 0 $cool->{editor} = $c->text;
381 0 $cool->{editor_id} = $c->{att}->{node_id};
382  
383 0 $c = $b->first_child('e2link');
384  
385 0 $cool->{title} = $c->text;
386 0 $cool->{id} = $c->{att}->{node_id};
387  
388 0 push @edcools, $cool;
389 }
390 0 };
391  
392 0 return $self->parse( 'edcools', $handlers, \@edcools, %opt );
393 }
394  
395 0 ▶sub time_since {
Subroutine time_since: not called CC=7 SCAR=40.3
Pod documented
396 0 ▶ my $self = shift or croak "Usage: time_since E2TICKER [, USER1 [, USER2 [, ... ] ] ]";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: time_since E2TICKER [, USER1 [, USER2 [, ... ] ] ]") 0 0 0
397 0 my @users = @_;
398 0 my $string = undef;
399  
400 0 my @timesince;
401
402 my %opt;
403  
404 0 ▶ warn "E2::Ticker::time_since" if $DEBUG > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $E2::Ticker::DEBUG > 1 0 0 0
405  
406 my $handlers = {
407 0 ▶ 'now' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
408 0 (my $a, my $b) = @_;
409 0 $self->{now} = $b->text;
410 },
411 0 ▶ 'user' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
412 0 (my $a, my $b) = @_;
413 0 my $user = {};
414  
415 0 my $c = $b->first_child( 'e2link' );
416  
417 0 $user->{time} = $b->{att}->{lasttime};
418 0 $user->{name} = $c->text;
419 0 $user->{id} = $c->{att}->{node_id};
420  
421 0 push @timesince, $user;
422 }
423 0 };
424  
425 # If they've passed a list of users, determine
426 # whether the list is of usernames or user_ids
427 # and set %opt accordingly.
428  
429 0 ▶ if( @users ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@users) 0 0 0
430 0 foreach my $u (@users) {
431 0 ▶ if( ! int $u ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (int $u) 0 0 0
432 0 $string = 1;
433 }
434 }
435  
436 0 ▶ my $key = $string ? 'node' : 'node_id';
Branch: 1 branch
BranchTrueFalseTotal
$string ? : 0 0 0
437 0 %opt = ( $key => join ',', @users );
438 }
439  
440 0 return $self->parse( 'timesince', $handlers, \@timesince, %opt );
441 }
442  
443 0 ▶sub available_rooms {
Subroutine available_rooms: not called CC=3 SCAR=24.8
Pod documented
444 0 ▶ my $self = shift or croak "Usage: available_rooms E2TICKER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: available_rooms E2TICKER") 0 0 0
445  
446 0 my @rooms = ( { title => 'outside', id => undef } );
447
448 0 ▶ warn "E2::Ticker::available_rooms" if $DEBUG > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $E2::Ticker::DEBUG > 1 0 0 0
449  
450 my $handlers = {
451 0 ▶ 'outside/e2link' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
452 0 (my $a, my $b) = @_;
453 $rooms[0] = {
454 title => $b->text,
455 id => $b->{att}->{node_id}
456 0 };
457 },
458 0 ▶ 'roomlist/e2link' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
459 0 (my $a, my $b) = @_;
460 push @rooms, {
461 title => $b->text,
462 id => $b->{att}->{node_id}
463 0 };
464 }
465 0 };
466  
467 0 return $self->parse( 'rooms', $handlers, \@rooms );
468 }
469  
470 0 ▶sub best_users {
Subroutine best_users: not called CC=4 SCAR=30.0
Pod documented
471 0 ▶ my $self = shift or croak "Usage: best_users E2TICKER [, NOGODS ]";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: best_users E2TICKER [, NOGODS ]") 0 0 0
472 0 my $nogods = shift;
473  
474 0 my @bestusers;
475
476 0 ▶ warn "E2::Ticker::best_users" if $DEBUG > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $E2::Ticker::DEBUG > 1 0 0 0
477  
478 0 my %opt;
479 0 ▶ $opt{ebu_noadmins} = 1 if $nogods;
Branch: 1 branch
BranchTrueFalseTotal
if $nogods 0 0 0
480  
481 my $handlers = {
482 0 ▶ 'bestuser' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
483 0 (my $a, my $b) = @_;
484 0 my $exp = $b->first_child( 'experience' );
485 0 my $wri = $b->first_child( 'writeups' );
486 0 my $usr = $b->first_child( 'e2link' );
487 0 my $lvl = $b->first_child( 'level' );
488
489 push @bestusers, {
490 experience => $exp->text,
491 writeups => $wri->text,
492 id => $usr->{att}->{node_id},
493 user => $usr->text,
494 level => $lvl->{att}->{value},
495 0 level_string => $lvl->text
496 };
497 }
498 0 };
499  
500 0 return $self->parse( 'bestusers', $handlers, \@bestusers, %opt );
501 }
502  
503 0 ▶sub node_heaven {
Subroutine node_heaven: not called CC=5 SCAR=34.0
Pod documented
504 0 ▶ my $self = shift or croak "Usage: node_heaven E2TICKER [, NODE_ID ]";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: node_heaven E2TICKER [, NODE_ID ]") 0 0 0
505 0 my $node_id = shift;
506  
507 0 my @heaven;
508  
509 0 ▶ warn "E2::Ticker::node_heaven" if $DEBUG > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $E2::Ticker::DEBUG > 1 0 0 0
510  
511 0 ▶ if( !$self->logged_in ) { return undef; }
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->logged_in) 0 0 0
512  
513 0 my %opt;
514  
515 0 ▶ $opt{visitnode_id} = $node_id if $node_id;
Branch: 1 branch
BranchTrueFalseTotal
if $node_id 0 0 0
516  
517 my $handlers = {
518 0 ▶ 'nodeangel' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
519 0 (my $a, my $b) = @_;
520 push @heaven, {
521 title => $b->{att}->{title},
522 id => $b->{att}->{node_id},
523 reputation => $b->{att}->{reputation},
524 createtime => $b->{att}->{createtime},
525 0 text => $b->text
526 };
527 }
528 0 };
529  
530 0 return $self->parse( 'heaven', $handlers, \@heaven, %opt );
531 }
532  
533 0 ▶sub maintenance_nodes {
Subroutine maintenance_nodes: not called CC=3 SCAR=24.8
Pod documented
534 0 ▶ my $self = shift or croak "Usage: maintenance_nodes E2TICKER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: maintenance_nodes E2TICKER") 0 0 0
535  
536 0 my @maintenance;
537
538 0 ▶ warn "E2::Ticker::maintenance_nodes" if $DEBUG > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $E2::Ticker::DEBUG > 1 0 0 0
539  
540 my $handlers = {
541 0 ▶ 'e2link' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
542 0 (my $a, my $b) = @_;
543 push @maintenance, {
544 title => $b->text,
545 id => $b->{att}->{node_id}
546 0 };
547 }
548 0 };
549  
550 0 return $self->parse( 'maintenance', $handlers, \@maintenance );
551 }
552  
553 0 ▶sub raw_vars {
Subroutine raw_vars: not called CC=3 SCAR=24.8
Pod documented
554 0 ▶ my $self = shift or croak "Usage: raw_vars E2TICKER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: raw_vars E2TICKER") 0 0 0
555  
556 0 my $vars = {};
557
558 0 ▶ warn "E2::Ticker::raw_vars" if $DEBUG > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $E2::Ticker::DEBUG > 1 0 0 0
559  
560 # Another method that doesn't return a list. Again, we'll have
561 # to thread_then
562  
563 my $handlers = {
564 0 ▶ 'key' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
565 0 (my $a, my $b) = @_;
566 0 $vars->{$b->{att}->{name}} = $b->text;
567 }
568 0 };
569  
570 return $self->thread_then(
571 [
572 \&parse,
573 $self,
574 'vars',
575 $handlers,
576 [] # dummy value for array
577 ],
578 0 ▶ sub { return $vars }
Subroutine __ANON__: not called CC=1 SCAR=6.9
579 0 );
580 }
581  
582 0 ▶sub interfaces {
Subroutine interfaces: not called CC=2 SCAR=17.9
Pod documented
583 0 ▶ my $self = shift or croak "Usage: interfaces E2TICKER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: interfaces E2TICKER") 0 0 0
584  
585 0 return $self->{xml_interfaces};
586 }
587
588 0 ▶sub random_nodes_wit {
Subroutine random_nodes_wit: not called CC=2 SCAR=17.9
Pod documented
589 0 ▶ my $self = shift or croak "Usage: random_wit_now E2TICKER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: random_wit_now E2TICKER") 0 0 0
590 0 return $self->{wit};
591 }
592  
593 0 ▶sub time_since_now {
Subroutine time_since_now: not called CC=2 SCAR=17.9
Pod documented
594 0 ▶ my $self = shift or croak "Usage: time_since_now E2TICKER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: time_since_now E2TICKER") 0 0 0
595 0 return $self->{now};
596 }
597  
598 2 1;
599 __END__
« E2Node.pm ↑ Summary Search.pm »