Plagger/Plugin/CustomFeed/Frepa/FriendStatus.pm untested

filter: Statementstmt 0.0% 0 / 26 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 40 CC 2 SCAR 10.6
CC
2
Cov
0%
get_list
6.0
title
2.0
start_url
2.0
CRAP 2.9
1 package Plagger::Plugin::CustomFeed::Frepa::FriendStatus;
2 use strict;
3 use warnings;
4 use HTML::Entities;
5 use Encode;
6  
7 sub title { 'フレ友の最新ひとこと' }
8  
9 sub start_url { 'http://www.frepa.livedoor.com/friend_status' }
10  
11 sub get_list {
12 my ($self, $mech) = @_;
13  
14 my @msgs = ();
15 my $res = $mech->get($self->start_url);
16 return @msgs unless $mech->success;
17  
18 my $html = decode('euc-jp', $mech->content);
19 my $reg = decode('utf-8', $self->_list_regexp());
20 while ($html =~ m|$reg|igs) {
21 my $time = "$1/$2/$3 $4:$5";
22 my ($subject, $link, $name) =
23 (decode_entities($6), decode_entities($7), decode_entities($8));
24  
25 push(@msgs, +{
26 subject => $subject,
27 name => $name,
28 link => $link,
29 user_link => $link,
30 time => $time,
31 });
32 }
33 return @msgs;
34 }
35  
36 sub _list_regexp {
37 return <<'RE';
38 <tr>
39 <th>(\d\d\d\d)\.(\d\d)\.(\d\d) (\d\d):(\d\d)</th>
40 <td>(.+?)\(<a href="([^"]+)">(.+?)</a>\)</td>
41 </tr>
42 RE
43 }
44  
45 1;