Code/Issue/Base.pm

filter: Statementstmt 75.0% 24 / 32 Branchbran 37.5% 3 / 8 Conditioncond 22.2% 2 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 83.3% 5 / 6 Podpod 100% 3 / 3 totaltotal 58.7% 37 / 63 CC 8 SCAR 18.9
CC
8
Cov
59%
get_token
12.0
ua
7.7
BEGIN
1.0
CRAP 6.6
« Code/Role/Predefined.pm ↑ Summary Code/Issue/Attachment.pm »
1 package Net::Google::Code::Issue::Base;
2  
3 9 ▶use Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 9 has 'project' => (
7 isa => 'Str',
8 is => 'rw',
9 );
10  
11 9 has 'token' => (
12 isa => 'Str',
13 is => 'rw',
14 );
15  
16 9 ▶no Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 9 __PACKAGE__->meta->make_immutable;
18  
19 3 ▶sub feeds_issues_url {
Subroutine feeds_issues_url: called CC=1 SCAR=0.0
Pod documented
20 3 my $self = shift;
21 return
22 3 'http://code.google.com/feeds/issues/p/'
23 . $self->project
24 . '/issues';
25 }
26  
27 3 ▶sub ua {
Subroutine ua: called CC=6 SCAR=20.5
Pod documented
28 3 my $self = shift;
29 3 my $skip_auth = shift;
30 3 require Net::Google::Code;
31 3 my $ua = LWP::UserAgent->new( agent => 'net-google-code-issue/'
32 . $Net::Google::Code::VERSION );
33 3 ▶ return $ua if $skip_auth;
Branch: 1 branch
BranchTrueFalseTotal
if $skip_auth 0 3 3
34  
35 3 $ua->default_header( 'Content-Type' => 'application/atom+xml' );
36  
37 # get auth token
38 3 ▶ if ( $self->email && $self->password && !$self->token ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->email and $self->password and not $self->token) 0 3 3
Condition33%2/6
$self->email and $self->password and not $self->token
!ll&&!rl&&r
300
$self->email and $self->password
!ll&&!rl&&r
300
MC/DC0%0/3
$self->email and $self->password and not $self->token
$self->email $self->password not $self->token
Truth table25%1/4
A and B and not(C)
A= $self->emailB= $self->passwordC= not $self->token
ABCresult
0XX0
10X0
1100
1111
39 0 $self->get_token();
40 }
41  
42 3 ▶ $ua->default_header( Authorization => 'GoogleLogin auth=' . $self->token )
Branch: 1 branch
BranchTrueFalseTotal
if $self->token 0 3 3
43 if $self->token;
44 3 return $ua;
45 }
46  
47 0 ▶sub get_token {
Subroutine get_token: not called CC=3 SCAR=24.8
Pod documented
48 0 my $self = shift;
49 0 my $ua = $self->ua(1); # don't need auth
50 0 my $response = $ua->post(
51 'https://www.google.com/accounts/ClientLogin',
52 {
53 Email => $self->email,
54 Passwd => $self->password,
55 service => 'code',
56 }
57 );
58 0 ▶ if ( $response->is_success && $response->content =~ /Auth=(\S+)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->is_success and $response->content =~ /Auth=(\S+)/) { } 0 0 0
Condition0%0/3
$response->is_success and $response->content =~ /Auth=(\S+)/
!ll&&!rl&&r
000
MC/DC0%0/2
$response->is_success and $response->content =~ /Auth=(\S+)/
$response->is_success $response->content =~ /Auth=(\S+)/
Truth table0%0/3
A and B
A= $response->is_successB= $response->content =~ /Auth=(\S+)/
ABresult
0X0
100
111
59 0 $self->token($1);
60 }
61 else {
62 0 warn "failed to get auth token: "
63 . $response->status_line . "\n"
64 . $response->content;
65 0 return;
66 }
67 }
68  
69 9 1;
70  
71 __END__
« Code/Role/Predefined.pm ↑ Summary Code/Issue/Attachment.pm »