lib/Egg/Plugin/LWP.pm

filter: Statementstmt 93.3% 42 / 45 Branchbran 37.5% 3 / 8 Conditioncond 57.1% 8 / 14 MC/DCmcdc 14.2% 1 / 7 Subroutinesub 92.3% 12 / 13 Podpod 100% 1 / 1 totaltotal 76.1% 67 / 88 CC 12 SCAR 11.7
CC
12
Cov
79%
simple_request
6.0
_get_args
5.4
_setup
4.3
CRAP 3.2
↑ Summary
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"} ||= {}
l!l
01
MC/DC0%0/1
$e->config->{"plugin_lwp"} ||= {}
$e->config->{"plugin_lwp"}
Truth table50%1/2
A
A= $e->config->{"plugin_lwp"}
Aresult
11
00
15 1 ▶ $conf->{timeout} ||= 10;
Condition50%1/2
$conf->{"timeout"} ||= 10
l!l
01
MC/DC0%0/1
$conf->{"timeout"} ||= 10
$conf->{"timeout"}
Truth table50%1/2
A
A= $conf->{"timeout"}
Aresult
11
00
16 1 ▶ $conf->{agent} ||= __PACKAGE__. " v$VERSION";
Condition50%1/2
$conf->{"agent"} ||= 'Egg::Plugin::LWP' . " v$Egg::Plugin::LWP::VERSION"
l!l
01
MC/DC0%0/1
$conf->{"agent"} ||= 'Egg::Plugin::LWP' . " v$Egg::Plugin::LWP::VERSION"
$conf->{"agent"}
Truth table50%1/2
A
A= $conf->{"agent"}
Aresult
11
00
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
BranchTrueFalseTotal
$method =~ /POST/ ? : 0 1 1
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
BranchTrueFalseTotal
$method =~ /POST/ ? : 0 0 0
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
BranchTrueFalseTotal
$_[1] ? : 0 4 4
Condition50%1/2
$_[0] or {}
l!l
04
MC/DC0%0/1
$_[0] or {}
$_[0]
Truth table50%1/2
A
A= $_[0]
Aresult
11
00
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'
l!l
20
MC/DC0%0/1
uc shift() || 'GET'
uc shift()
Truth table50%1/2
A
A= uc shift()
Aresult
11
00
52 2 ▶ my $url = shift || die qq{ I want 'url' };
Condition50%1/2
shift() || die(q[ I want 'url' ])
l!l
20
MC/DC0%0/1
shift() || die(q[ I want 'url' ])
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
53 2 ▶ ($self, $meth, $url, ($_[1] ? {@_}: ($_[0] || {})));
Branch: 1 branch
BranchTrueFalseTotal
$_[1] ? : 0 2 2
Condition100%2/2
$_[0] or {}
l!l
11
MC/DC100%1/1
$_[0] or {}
$_[0]
Truth table100%2/2
A
A= $_[0]
Aresult
11
00
54 }
55  
56 3 1;
57  
58 __END__
↑ Summary