FollowLinks/Parser/Text.pm untested

filter: Statementstmt 0.0% 0 / 22 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 31 CC 2 SCAR 12.0
CC
2
Cov
0%
parse
6.0
new
2.0
BEGIN
2.0
CRAP 3.3
1 # $Id: /mirror/perl/GunghoX-FollowLinks/trunk/lib/GunghoX/FollowLinks/Parser/Text.pm 39011 2008-01-16T15:31:39.350176Z daisuke $
2 #
3 # Copyright (c) 2007 Daisuke Maki <daisuke@endeworks.jp>
4 # All rights reserved.
5  
6 package GunghoX::FollowLinks::Parser::Text;
7 use strict;
8 use warnings;
9 use base qw(GunghoX::FollowLinks::Parser);
10  
11 sub new
12 {
13 my $class = shift;
14 $class->SUPER::new( content_type => 'text/plain', @_ );
15 }
16  
17 sub parse
18 {
19 my ($self, $c, $response) = @_;
20  
21 my $base = $response->request->uri;
22 my $content = $response->content;
23  
24 my $count = 0;
25 while ( $content =~ m{\b(?:[^:/?#]+:)?(?://[^/?#]*)?[^?#]*(?:\?[^#]*)?(?:#.*?))\b}gsm ) {
26 my $uri = URI->new_abs( $1, $base );
27 $self->apply_filters($c, $uri);
28 if ($self->follow_if_allowed( $c, $response, $uri )) {
29 $count++;
30 }
31 }
32 return $count;
33 }
34  
35 1;
36  
37 __END__