Tumblr/Authentication/OAuth.pm

filter: Statementstmt 62.5% 20 / 32 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 50.0% 4 / 8 Podpod n/a totaltotal 38.1% 24 / 63 CC 9 SCAR 33.0
CC
9
Cov
40%
_get_token
56.0
__ANON__
12.0
__ANON__
1.1
CRAP 27.1
« Tumblr/ResponseError.pm ↑ Summary Tumblr/Test.pm »
1 package WWW::Tumblr::Authentication::OAuth;
2  
3 16 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 16 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 16 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 16 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # Note: Extends WWW::Tumblr which already uses WWW::Tumblr::Authentication
10 16 extends 'WWW::Tumblr';
11  
12 0 ▶has 'authorize_url', is => 'rw', isa => 'Str', lazy => 1, default => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
13 0 my $self = shift;
14 0 ▶ croak "The consumer_key and secret_key must be defined!"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->consumer_key and $self->secret_key 0 0 0
Condition0%0/3
$self->consumer_key and $self->secret_key
!ll&&!rl&&r
000
MC/DC0%0/2
$self->consumer_key and $self->secret_key
$self->consumer_key $self->secret_key
Truth table0%0/3
A and B
A= $self->consumer_keyB= $self->secret_key
ABresult
0X0
100
111
15 unless $self->consumer_key && $self->secret_key;
16  
17 0 return $self->oauth->authorize_url();
18 16 };
19  
20 16 has 'oauth_token', is => 'rw', isa => 'Str';
21 16 has 'oauth_verifier', is => 'rw', isa => 'Str';
22  
23 0 ▶has 'token', is => 'rw', isa => 'Str', lazy => 1, default => sub{ shift->_get_token() };
Subroutine __ANON__: not called CC=1 SCAR=1.2
24 0 ▶has 'token_secret', is => 'rw', isa => 'Str', lazy => 1, default => sub { shift->_get_token('secret') };
Subroutine __ANON__: not called CC=1 SCAR=1.2
25  
26 16 has '_access_token', is => 'rw';
27  
28 0 ▶sub _get_token {
Subroutine _get_token: not called CC=7 SCAR=40.3
29 0 my $self = shift;
30 0 ▶ my $type = shift || 'token';
Condition0%0/2
shift() || 'token'
l!l
00
MC/DC0%0/1
shift() || 'token'
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
31  
32 0 ▶ croak "Cannot get OAuth token without 'oauth_token' and 'oauth_verifier' defined!"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->oauth_token and $self->oauth_verifier 0 0 0
Condition0%0/3
$self->oauth_token and $self->oauth_verifier
!ll&&!rl&&r
000
MC/DC0%0/2
$self->oauth_token and $self->oauth_verifier
$self->oauth_token $self->oauth_verifier
Truth table0%0/3
A and B
A= $self->oauth_tokenB= $self->oauth_verifier
ABresult
0X0
100
111
33 unless $self->oauth_token && $self->oauth_verifier;
34  
35 warn "Session looks empty, _get_token will fall, probably"
36 0 ▶ unless keys %{ $self->_session };
Branch: 1 branch
BranchTrueFalseTotal
unless keys %{$self->_session;} 0 0 0
37  
38 0 ▶ $self->_access_token( $self->oauth->get_access_token( $self->oauth_token, $self->oauth_verifier ) )
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_access_token 0 0 0
39 unless $self->_access_token;
40  
41 0 ▶ return $type eq 'secret' ? $self->_access_token->token_secret : $self->_access_token->token;
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'secret' ? : 0 0 0
42 }
43  
44 16 1;
« Tumblr/ResponseError.pm ↑ Summary Tumblr/Test.pm »