| 1 | package Egg::Plugin::LWP; | ||||||||||||||||||||
| 2 | # | ||||||||||||||||||||
| 3 | # Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt> | ||||||||||||||||||||
| 4 | # | ||||||||||||||||||||
| 5 | # $Id: LWP.pm 319 2008-04-17 12:20:20Z lushe $ | ||||||||||||||||||||
| 6 | # | ||||||||||||||||||||
| 7 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 3 | our $VERSION = '3.01'; | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 1 | ▶ | sub _setup { | ||||||||||||||||||
|
Subroutine
_setup: called CC=4 SCAR=14.6
| |||||||||||||||||||||
| 13 | 1 | my($e)= @_; | |||||||||||||||||||
| 14 | 1 | ▶ | my $conf= $e->config->{plugin_lwp} ||= {}; | ||||||||||||||||||
|
Condition50%1/2
$e->config->{"plugin_lwp"} ||= {}
MC/DC0%0/1
$e->config->{"plugin_lwp"} ||= {}
$e->config->{"plugin_lwp"}
Truth table50%1/2
A
A= $e->config->{"plugin_lwp"}
| |||||||||||||||||||||
| 15 | 1 | ▶ | $conf->{timeout} ||= 10; | ||||||||||||||||||
|
Condition50%1/2
$conf->{"timeout"} ||= 10
MC/DC0%0/1
$conf->{"timeout"} ||= 10
$conf->{"timeout"}
Truth table50%1/2
A
A= $conf->{"timeout"}
| |||||||||||||||||||||
| 16 | 1 | ▶ | $conf->{agent} ||= __PACKAGE__. " v$VERSION"; | ||||||||||||||||||
|
Condition50%1/2
$conf->{"agent"} ||= 'Egg::Plugin::LWP' . " v$Egg::Plugin::LWP::VERSION"
MC/DC0%0/1
$conf->{"agent"} ||= 'Egg::Plugin::LWP' . " v$Egg::Plugin::LWP::VERSION"
$conf->{"agent"}
Truth table50%1/2
A
A= $conf->{"agent"}
| |||||||||||||||||||||
| 17 | 1 | $e->next::method; | |||||||||||||||||||
| 18 | } | ||||||||||||||||||||
| 19 | 4 | ▶ | sub ua { Egg::Plugin::LWP::handler->new(@_) } | ||||||||||||||||||
|
Subroutine
ua: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | package Egg::Plugin::LWP::handler; | ||||||||||||||||||||
| 22 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 23 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 24 | 3 | ▶ | use LWP::UserAgent; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 25 | 3 | ▶ | use HTTP::Request::Common qw/ GET POST /; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | { | ||||||||||||||||||||
| 28 | 3 | ▶ | no strict 'refs'; ## no critic | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 29 | 1 | ▶ | sub request { | ||||||||||||||||||
|
Subroutine
request: called CC=2 SCAR=7.1
| |||||||||||||||||||||
| 30 | 1 | my($self, $method, $url, $args)= _get_args(@_); | |||||||||||||||||||
| 31 | $self->{ua}->request | ||||||||||||||||||||
| 32 | 1 | ▶ | ( &{$method}($url, ($method=~m{POST} ? [%$args]: %$args) ) ); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 33 | } | ||||||||||||||||||||
| 34 | 0 | ▶ | sub simple_request { | ||||||||||||||||||
|
Subroutine
simple_request: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 35 | 0 | my($self, $method, $url, $args)= _get_args(@_); | |||||||||||||||||||
| 36 | $self->{ua}->simple_request | ||||||||||||||||||||
| 37 | 0 | ▶ | ( &{$method}($url, ($method=~m{POST} ? [%$args]: %$args) ) ); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | 3 | }; | |||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 4 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.3
| |||||||||||||||||||||
| 42 | 4 | my($class, $e)= splice @_, 0, 2; | |||||||||||||||||||
| 43 | my $ua= LWP::UserAgent->new( | ||||||||||||||||||||
| 44 | 4 | %{$e->config->{plugin_lwp}}, | |||||||||||||||||||
| 45 | 4 | ▶ | %{$_[1] ? {@_}: ($_[0] || {})}, | ||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$_[0] or {}
MC/DC0%0/1
$_[0] or {}
$_[0]
Truth table50%1/2
A
A= $_[0]
| |||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||
| 47 | 4 | bless { e=> $e, ua=> $ua }, $class; | |||||||||||||||||||
| 48 | } | ||||||||||||||||||||
| 49 | 2 | ▶ | sub _get_args { | ||||||||||||||||||
|
Subroutine
_get_args: called CC=5 SCAR=16.8
| |||||||||||||||||||||
| 50 | 2 | my $self= shift; | |||||||||||||||||||
| 51 | 2 | ▶ | my $meth= uc(shift) || 'GET'; | ||||||||||||||||||
|
Condition50%1/2
uc shift() || 'GET'
MC/DC0%0/1
uc shift() || 'GET'
uc shift()
Truth table50%1/2
A
A= uc shift()
| |||||||||||||||||||||
| 52 | 2 | ▶ | my $url = shift || die qq{ I want 'url' }; | ||||||||||||||||||
|
Condition50%1/2
shift() || die(q[ I want 'url' ])
MC/DC0%0/1
shift() || die(q[ I want 'url' ])
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||
| 53 | 2 | ▶ | ($self, $meth, $url, ($_[1] ? {@_}: ($_[0] || {}))); | ||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$_[0] or {}
MC/DC100%1/1
$_[0] or {}
$_[0]
Truth table100%2/2
A
A= $_[0]
| |||||||||||||||||||||
| 54 | } | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | 3 | 1; | |||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | __END__ | ||||||||||||||||||||