Spinn3r/link.pm untested

filter: Statementstmt 0.0% 0 / 42 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 58 CC 5 SCAR 27.7
CC
5
Cov
0%
new
30.0
link
2.0
BEGIN
2.0
CRAP 16.0
1 package WWW::Spinn3r::link;
2 use base WWW::Spinn3r::Common;
3 use XML::Twig;
4 use Data::Dumper;
5 use utf8;
6  
7 my @SCALAR_FIELDS = qw(
8 title link guid pubDate description
9 weblog:tier weblog:inranking weblong:indegree weblog:publisher_type weblog:title
10 post:date_found post:content_extract
11 dc:source dc:lang
12 feed:url
13 atom:published
14 );
15  
16 my @ARRAY_FIELDS = qw(
17 category
18 );
19  
20 my %ATTRS = (
21 'atom:author' => ['atom:name', 'atom:link', 'atom:email'],
22 );
23  
24 sub new {
25  
26 my ($class, %args) = @_;
27 my $self = bless { %args }, $class;
28  
29 my $twig = new XML::Twig (
30 expand_external_ents => 0,
31 twig_roots => {
32 'link' => sub { $self->link(@_) },
33 }
34 );
35  
36 $self->{results}->{link} = [];
37  
38 my $start = $self->start_timer;
39 $self->debug("$class: parsing XML...");
40  
41 eval {
42  
43 if ($args{path}) {
44 $twig->parsefile($args{path});
45 } elsif ($args{string}) {
46 $twig->parse($args{string});
47 } elsif ($args{stringref}) {
48 $twig->parse(${$args{stringref}});
49 }
50  
51 };
52  
53 if ($@) {
54 return;
55 }
56  
57 my $howlong = $self->howlong($start);
58 $self->debug("$class: parse complete in $howlong seconds");
59  
60 $twig->purge;
61  
62 return $self->{results};
63  
64 }
65  
66  
67 sub link {
68  
69 my ($self, $twig, $root) = @_;
70 my $link = $root->text;
71 push @{ $self->{results}->{link} }, $url;
72 $twig->purge;
73  
74 }
75  
76 1;
77