| 1 | =head1 NAME | ||||||||||
| 2 | |||||||||||
| 3 | WWW::Link::Reporter::Text - Report on status of links in plain text | ||||||||||
| 4 | |||||||||||
| 5 | =head1 SYNOPSIS | ||||||||||
| 6 | |||||||||||
| 7 | use WWW::Link; | ||||||||||
| 8 | use WWW::Link::Reporter::Text; | ||||||||||
| 9 | |||||||||||
| 10 | $link=new WWW::Link; | ||||||||||
| 11 | |||||||||||
| 12 | #over time do things to the link ...... | ||||||||||
| 13 | |||||||||||
| 14 | $reporter = new WWW::Link::Reporter::Text | ||||||||||
| 15 | $reporter->examine($link) | ||||||||||
| 16 | |||||||||||
| 17 | =head1 DESCRIPTION | ||||||||||
| 18 | |||||||||||
| 19 | This is a very simple class derived from WWW::Link::Reporter which provides | ||||||||||
| 20 | a report on the status of links in text for easy reading. Nothing | ||||||||||
| 21 | much can be done other than read it. | ||||||||||
| 22 | |||||||||||
| 23 | =cut | ||||||||||
| 24 | |||||||||||
| 25 | package WWW::Link::Reporter::Text; | ||||||||||
| 26 | 2 | $REVISION=q$Revision: 1.9 $ ; $VERSION = sprintf ( "%d.%02d", $REVISION =~ /(\d+).(\d+)/ ); | |||||||||
| 27 | |||||||||||
| 28 | 2 | @ISA = qw(WWW::Link::Reporter); | |||||||||
| 29 | |||||||||||
| 30 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 31 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 32 | |||||||||||
| 33 | 2 | ▶ | use WWW::Link::Reporter; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 34 | 2 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 35 | |||||||||||
| 36 | 0 | ▶ | sub broken { | ||||||||
|
Subroutine
broken: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 37 | 0 | my $self=shift; | |||||||||
| 38 | 0 | my $link=shift; | |||||||||
| 39 | 0 | my $redir=shift; | |||||||||
| 40 | 0 | my $url=$link->url(); | |||||||||
| 41 | 0 | print "broken:- $url\n"; | |||||||||
| 42 | 0 | ▶ | $redir && $self->redirections($link); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 0 | $self->suggestions($link); | |||||||||
| 44 | 0 | ▶ | if ($self->{"index"}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | 0 | my $page_array=$self->{"index"}->lookup_second($url); | |||||||||
| 46 | 0 | $self->page_list ( @$page_array ); | |||||||||
| 47 | } | ||||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 0 | ▶ | sub not_found { | ||||||||
|
Subroutine
not_found: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 51 | 0 | my $self=shift; | |||||||||
| 52 | 0 | my $url=shift; | |||||||||
| 53 | 0 | print "Sorry, the link $url is not in the database.\n"; | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | 0 | ▶ | sub okay { | ||||||||
|
Subroutine
okay: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 57 | 0 | my $self=shift; | |||||||||
| 58 | 0 | my $link=shift; | |||||||||
| 59 | 0 | my $redir=shift; | |||||||||
| 60 | 0 | my $url=$link->url(); | |||||||||
| 61 | 0 | print "tested okay:- $url\n"; | |||||||||
| 62 | 0 | ▶ | $redir && $self->redirections($link); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | 0 | $self->suggestions($link); | |||||||||
| 64 | 0 | ▶ | if ($self->{"index"}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 65 | 0 | my $page_array=$self->{"index"}->lookup_second($url); | |||||||||
| 66 | 0 | $self->page_list ( @$page_array ); | |||||||||
| 67 | } | ||||||||||
| 68 | 0 | return 1; | |||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | 0 | ▶ | sub damaged { | ||||||||
|
Subroutine
damaged: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 72 | 0 | my $self=shift; | |||||||||
| 73 | 0 | my $link=shift; | |||||||||
| 74 | 0 | my $redir=shift; | |||||||||
| 75 | 0 | my $url=$link->url(); | |||||||||
| 76 | 0 | print "could be broken:- $url\n"; | |||||||||
| 77 | 0 | ▶ | $redir && $self->redirections($link); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 78 | 0 | $self->suggestions($link); | |||||||||
| 79 | 0 | ▶ | if ($self->{"index"}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 80 | 0 | my $page_array=$self->{"index"}->lookup_second($url); | |||||||||
| 81 | 0 | $self->page_list ( @$page_array ); | |||||||||
| 82 | } | ||||||||||
| 83 | 0 | return 1; | |||||||||
| 84 | } | ||||||||||
| 85 | |||||||||||
| 86 | 0 | ▶ | sub not_checked { | ||||||||
|
Subroutine
not_checked: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 87 | 0 | my $self=shift; | |||||||||
| 88 | 0 | my $link=shift; | |||||||||
| 89 | 0 | my $url=$link->url(); | |||||||||
| 90 | 0 | print "not yet checked:- $url\n"; | |||||||||
| 91 | 0 | $self->suggestions($link); | |||||||||
| 92 | 0 | ▶ | if ($self->{"index"}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 93 | 0 | my $page_array=$self->{"index"}->lookup_second($url); | |||||||||
| 94 | 0 | $self->page_list ( @$page_array ); | |||||||||
| 95 | } | ||||||||||
| 96 | } | ||||||||||
| 97 | |||||||||||
| 98 | 0 | ▶ | sub disallowed { | ||||||||
|
Subroutine
disallowed: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 99 | 0 | my $self=shift; | |||||||||
| 100 | 0 | my $link=shift; | |||||||||
| 101 | 0 | my $url=$link->url(); | |||||||||
| 102 | 0 | print "checking disallowed:- $url\n"; | |||||||||
| 103 | 0 | $self->suggestions($link); | |||||||||
| 104 | 0 | ▶ | if ($self->{"index"}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 105 | 0 | my $page_array=$self->{"index"}->lookup_second($url); | |||||||||
| 106 | 0 | $self->page_list ( @$page_array ); | |||||||||
| 107 | } | ||||||||||
| 108 | } | ||||||||||
| 109 | |||||||||||
| 110 | 0 | ▶ | sub unsupported { | ||||||||
|
Subroutine
unsupported: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 111 | 0 | my $self=shift; | |||||||||
| 112 | 0 | my $link=shift; | |||||||||
| 113 | 0 | my $url=$link->url(); | |||||||||
| 114 | 0 | print "unsupported protocol:- $url\n"; | |||||||||
| 115 | 0 | $self->suggestions($link); | |||||||||
| 116 | 0 | ▶ | if ($self->{"index"}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 117 | 0 | my $page_array=$self->{"index"}->lookup_second($url); | |||||||||
| 118 | 0 | $self->page_list ( @$page_array ); | |||||||||
| 119 | } | ||||||||||
| 120 | } | ||||||||||
| 121 | |||||||||||
| 122 | 0 | ▶ | sub unknown { | ||||||||
|
Subroutine
unknown: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 123 | 0 | my $self=shift; | |||||||||
| 124 | 0 | my $link=shift; | |||||||||
| 125 | 0 | my $url=$link->url(); | |||||||||
| 126 | 0 | print "unknown status (error?):- $url"; | |||||||||
| 127 | 0 | $self->suggestions($link); | |||||||||
| 128 | 0 | ▶ | if ($self->{"index"}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 129 | 0 | my $page_array=$self->{"index"}->lookup_second($url); | |||||||||
| 130 | 0 | $self->page_list ( @$page_array ); | |||||||||
| 131 | } | ||||||||||
| 132 | } | ||||||||||
| 133 | |||||||||||
| 134 | |||||||||||
| 135 | 2 | ▶ | sub redirections { | ||||||||
|
Subroutine
redirections: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 136 | 2 | my $self=shift; | |||||||||
| 137 | 2 | my $link=shift; | |||||||||
| 138 | 2 | my @redirects=$link->redirect_urls(); | |||||||||
| 139 | 2 | foreach my $redir ( @redirects ) { | |||||||||
| 140 | 2 | print "redirected to\t$redir\n"; | |||||||||
| 141 | } | ||||||||||
| 142 | } | ||||||||||
| 143 | |||||||||||
| 144 | |||||||||||
| 145 | 0 | ▶ | sub suggestions { | ||||||||
|
Subroutine
suggestions: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 146 | 0 | my $self=shift; | |||||||||
| 147 | 0 | my $link=shift; | |||||||||
| 148 | 0 | my $suggestions=$link->fix_suggestions(); | |||||||||
| 149 | 0 | ▶ | if ($suggestions) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 150 | 0 | foreach my $suggest ( @{$suggestions} ) { | |||||||||
| 151 | 0 | print "suggest $suggest\n"; | |||||||||
| 152 | } | ||||||||||
| 153 | } | ||||||||||
| 154 | 0 | return 1; | |||||||||
| 155 | } | ||||||||||
| 156 | |||||||||||
| 157 | |||||||||||
| 158 | 0 | ▶ | sub page_list { | ||||||||
|
Subroutine
page_list: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 159 | 0 | my $self=shift; | |||||||||
| 160 | 0 | foreach (@_) { | |||||||||
| 161 | 0 | print " $_\n"; | |||||||||
| 162 | } | ||||||||||
| 163 | } | ||||||||||
| 164 | |||||||||||
| 165 | 2 | 1; | |||||||||
| 166 | |||||||||||
| 167 | |||||||||||
| 168 | |||||||||||