| 1 | package WWW::EZTV::UA; | ||||||||||||
| 2 | { | ||||||||||||
| 3 | 2 | $WWW::EZTV::UA::VERSION = '0.05'; | |||||||||||
| 4 | } | ||||||||||||
| 5 | 2 | ▶ | use Moose::Role; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 2 | ▶ | use Mojo::UserAgent; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | # ABSTRACT: User agent for EZTV scrapper. | ||||||||||||
| 9 | |||||||||||||
| 10 | 2 | ▶ | has ua => ( is => 'ro', lazy => 1, default => sub { $EZTV::Global::UA || ($EZTV::Global::UA = Mojo::UserAgent->new) } ); | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||
| 11 | |||||||||||||
| 12 | sub get_response { | ||||||||||||
| 13 | 2 | ▶ | my ($self, $url) = (shift, shift); | ||||||||||
|
Subroutine
get_response: called CC=4 SCAR=24.2
Pod
documented
| |||||||||||||
| 14 | |||||||||||||
| 15 | 2 | my $tx = $self->ua->get( $url ); | |||||||||||
| 16 | 2 | ▶ | if ( my $res = $tx->success ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 17 | 0 | return $res; | |||||||||||
| 18 | } | ||||||||||||
| 19 | else { | ||||||||||||
| 20 | 0 | my ($err, $code) = $tx->error; | |||||||||||
| 21 | 0 | ▶ | my $message = shift || 'User agent error'; | ||||||||||
|
Condition0%0/2
shift() || 'User agent error'
MC/DC0%0/1
shift() || 'User agent error'
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||
| 22 | 0 | ▶ | confess sprintf('%s: %s (%s)', $message, $err, $code||'no error code'); | ||||||||||
|
Condition0%0/2
$code || 'no error code'
MC/DC0%0/1
$code || 'no error code'
$code
Truth table0%0/2
A
A= $code
| |||||||||||||
| 23 | } | ||||||||||||
| 24 | } | ||||||||||||
| 25 | |||||||||||||
| 26 | 2 | 1; | |||||||||||
| 27 | |||||||||||||
| 28 | __END__ | ||||||||||||
| 29 | =pod | ||||||||||||
| 30 | |||||||||||||
| 31 | =encoding UTF-8 | ||||||||||||
| 32 | |||||||||||||
| 33 | =head1 NAME | ||||||||||||
| 34 | |||||||||||||
| 35 | WWW::EZTV::UA - User agent for EZTV scrapper. | ||||||||||||
| 36 | |||||||||||||
| 37 | =head1 VERSION | ||||||||||||
| 38 | |||||||||||||
| 39 | version 0.05 | ||||||||||||
| 40 | |||||||||||||
| 41 | =head1 METHODS | ||||||||||||
| 42 | |||||||||||||
| 43 | =head2 get_response | ||||||||||||
| 44 | |||||||||||||
| 45 | =head1 AUTHOR | ||||||||||||
| 46 | |||||||||||||
| 47 | Diego Kuperman <diego@freekeylabs.com> | ||||||||||||
| 48 | |||||||||||||
| 49 | =head1 COPYRIGHT AND LICENSE | ||||||||||||
| 50 | |||||||||||||
| 51 | This software is copyright (c) 2012 by Diego Kuperman. | ||||||||||||
| 52 | |||||||||||||
| 53 | This is free software; you can redistribute it and/or modify it under | ||||||||||||
| 54 | the same terms as the Perl 5 programming language system itself. | ||||||||||||
| 55 | |||||||||||||
| 56 | =cut | ||||||||||||
| 57 | |||||||||||||