lib/Net/Travis/API/Auth/GitHub.pm

filter: Statementstmt 61.5% 24 / 39 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 70.0% 7 / 10 Podpod 100% 2 / 2 totaltotal 54.1% 33 / 61 CC 6 SCAR 24.3
CC
6
Cov
49%
get_token_for
30.0
get_authorised_ua_for
6.0
_get_token_for
2.0
CRAP 11.4
« blib/lib/Net/Travis/API/Auth/GitHub.pm ↑ Summary blib/lib/Net/Travis/API/UA.pm »
1 1 ▶use 5.008; # utf8
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 package Net::Travis::API::Auth::GitHub;
7 1 $Net::Travis::API::Auth::GitHub::VERSION = '0.001001';
8 # ABSTRACT: Authorize with Travis using a GitHub token
9  
10 1 our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
11  
12 1 ▶use Moo qw( with );
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 with 'Net::Travis::API::Role::Client';
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30 sub _get_token_for {
31 0 ▶ my ( $self, $gh_token ) = @_;
Subroutine _get_token_for: not called CC=1 SCAR=6.9
32 0 return $self->http_engine->post_form( '/auth/github', { github_token => $gh_token } );
33 }
34  
35  
36  
37  
38  
39  
40  
41  
42  
43 sub get_token_for {
44 0 ▶ my ( $self, $gh_token ) = @_;
Subroutine get_token_for: not called CC=5 SCAR=34.0
Pod documented
45 0 ▶ if ( not blessed $self ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($self)) 0 0 0
46 0 $self = $self->new();
47 }
48 0 my $result = $self->_get_token_for($gh_token);
49 0 ▶ return if not '200' eq $result->status;
Branch: 1 branch
BranchTrueFalseTotal
unless 200 eq $result->status 0 0 0
50 0 ▶ return if not length $result->content;
Branch: 1 branch
BranchTrueFalseTotal
unless length $result->content 0 0 0
51 0 ▶ return unless my $json = $result->content_json;
Branch: 1 branch
BranchTrueFalseTotal
unless my $json = $result->content_json 0 0 0
52 0 return $json->{access_token};
53 }
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66 sub get_authorised_ua_for {
67 0 ▶ my ( $self, $gh_token ) = @_;
Subroutine get_authorised_ua_for: not called CC=2 SCAR=17.9
Pod documented
68 0 ▶ $self = $self->new() if not blessed $self;
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($self) 0 0 0
69 0 my $token = $self->get_token_for($gh_token);
70 0 $self->http_engine->authtokens( [$token] );
71 0 return $self->http_engine;
72 }
73  
74 1 ▶no Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
75  
76 1 1;
77  
78 __END__
« blib/lib/Net/Travis/API/Auth/GitHub.pm ↑ Summary blib/lib/Net/Travis/API/UA.pm »