| 1 | use strict; | ||
| 2 | use warnings; | ||
| 3 | package Rubric::CLI::Command::linkcheck 0.157; | ||
| 4 | # ABSTRACT: check validity of links in the database | ||
| 5 | |||
| 6 | use parent qw(Rubric::CLI::Command); | ||
| 7 | |||
| 8 | use LWP::Simple (); | ||
| 9 | use Rubric::DBI::Setup; | ||
| 10 | |||
| 11 | sub run { | ||
| 12 | my ($self, $opt, $args) = @_; | ||
| 13 | |||
| 14 | my $links = Rubric::Link->retrieve_all; | ||
| 15 | |||
| 16 | while (my $link = $links->next) { | ||
| 17 | my $uri = $link->uri; | ||
| 18 | if ($uri->scheme ne 'http') { | ||
| 19 | print "unknown scheme on link $link\n"; | ||
| 20 | next; | ||
| 21 | } | ||
| 22 | |||
| 23 | unless (LWP::Simple::head($uri)) { | ||
| 24 | print "couldn't get headers for $uri\n"; | ||
| 25 | } | ||
| 26 | } | ||
| 27 | } | ||
| 28 | |||
| 29 | 1; | ||
| 30 | |||
| 31 | __END__ |