File Coverage

blib/lib/WWW/Link/Reporter/LongList.pm
Criterion Covered Total %
statement 15 39 38.4
branch 0 10 0.0
condition 0 6 0.0
subroutine 5 7 71.4
pod 1 2 50.0
total 21 64 32.8


line stmt bran cond sub pod time code
1             =head1 NAME
2              
3             WWW::Link::Reporter::LongList - Long list files which contain broken links
4              
5             =head1 SYNOPSIS
6              
7             use WWW::Link;
8             use WWW::Link::Reporter::LongList;
9              
10             $link=new WWW::Link;
11              
12             #over time do things to the link ......
13              
14             $reporter = new WWW::Link::Reporter::LongList \*STDOUT, $index;
15             $reporter->examine($link)
16              
17             or see WWW::Link::Selector for a way to recurse through all of the links.
18              
19             =head1 DESCRIPTION
20              
21             This is a WWW::Link::Reporter very similar to WWW::Link::Reporter::Text, but
22             when it detects a broken link in a local file it will list that file
23             in C format. This can be used to allow easy editing, for
24             example by C in C
25              
26             =cut
27              
28             package WWW::Link::Reporter::LongList;
29             $REVISION=q$Revision: 1.10 $ ; $VERSION = sprintf ( "%d.%02d", $REVISION =~ /(\d+).(\d+)/ );
30              
31 1     1   638 use WWW::Link::Reporter::Text;
  1         1  
  1         30  
32             @ISA = qw(WWW::Link::Reporter::Text);
33 1     1   4 use warnings;
  1         2  
  1         31  
34 1     1   11 use strict;
  1         1  
  1         28  
35 1     1   970 use Data::Dumper;
  1         7589  
  1         71  
36 1     1   8 use Carp;
  1         2  
  1         368  
37              
38             sub new {
39 0     0 1   my $proto=shift;
40 0           my $url_to_file=shift;
41 0 0 0       croak "usage ->new(,)"
42             unless ref $url_to_file and @_;
43 0   0       my $class = ref($proto) || $proto;
44 0           my $self = $class->SUPER::new(@_);
45 0           $self->{"url_to_file"}=$url_to_file;
46              
47 0 0         if ( $self->{"verbose"} & 128) {
48 0           my $dump=Dumper($self);
49 0           $dump =~ s/[^[:graph:]\s]/_/g;
50 0           print "self\n" . $dump . "\n";
51             }
52              
53 0           return $self;
54             }
55              
56             sub page_list {
57 0     0 0   my $self=shift;
58 0           my @worklist=();
59 0           my @unresolve=();
60 0           my $url_to_file=$self->{"url_to_file"};
61 0           foreach my $url (@_) {
62 0           my $file = &$url_to_file($url);
63 0 0         if ($file) {
64 0           push @worklist, quotemeta ($file);
65             } else {
66 0           push @unresolve, $url;
67             }
68             }
69 0 0         if ( @worklist ) {
70 0           my $workfile=join ' ', @worklist;
71 0           print `ls -l $workfile`;
72             }
73 0 0         print 'unresolved:- ', join ("\nunresolved:- ", @unresolve), "\n"
74             if @unresolve;
75             }
76