| 1 | package Catmandu::Fix::uri_status_code; | ||
| 2 | |||
| 3 | 1 | our $VERSION = '0.15'; | |
| 4 | |||
| 5 | 1 | ▶ | use Catmandu::Sane; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 1 | ▶ | use LWP::UserAgent; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 1 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 1 | ▶ | use Catmandu::Fix::Has; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 1 | with 'Catmandu::Fix::Base'; | |
| 11 | |||
| 12 | 1 | has path => (fix_arg => 1); | |
| 13 | |||
| 14 | 1 | ▶ | sub emit { |
|
Subroutine
emit: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 15 | 1 | my ($self, $fixer) = @_; | |
| 16 | 1 | my $path = $fixer->split_path($self->path); | |
| 17 | |||
| 18 | $fixer->emit_create_path( | ||
| 19 | $fixer->var, | ||
| 20 | $path, | ||
| 21 | 1 | ▶ | sub { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 22 | 1 | my $var = shift; | |
| 23 | 1 | "${var} = LWP::UserAgent->new->get(${var})->code if is_value(${var}) && length(${var});"; | |
| 24 | } | ||
| 25 | 1 | ); | |
| 26 | } | ||
| 27 | |||
| 28 | =head1 NAME | ||
| 29 | |||
| 30 | Catmandu::Fix::uri_status_code - check the HTTP status of a uri | ||
| 31 | |||
| 32 | =head1 SYNOPSIS | ||
| 33 | |||
| 34 | copy_field(url,status) | ||
| 35 | uri_status_code(status) # status => '200' | ||
| 36 | |||
| 37 | =head1 SEE ALSO | ||
| 38 | |||
| 39 | L<Catmandu::Fix> | ||
| 40 | |||
| 41 | =cut | ||
| 42 | |||
| 43 | 1 | 1; | |