Google/AuthStorage.pm

filter: Statementstmt 39.0% 16 / 41 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 40.0% 4 / 10 Podpod 60.0% 3 / 5 totaltotal 35.9% 23 / 64 CC 5 SCAR 20.1
CC
5
Cov
33%
setup
20.0
file_exists
6.0
__ANON__
2.0
CRAP 7.4
« Google.pm ↑ Summary Google/Discovery.pm »
1 package Moo::Google::AuthStorage;
2 1 $Moo::Google::AuthStorage::VERSION = '0.03';
3  
4 # ABSTRACT: Provide universal methods to fetch tokens from different types of data sources. Default is jsonfile
5  
6 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Moo::Google::AuthStorage::ConfigJSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Moo::Google::AuthStorage::DBI;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Moo::Google::AuthStorage::MongoDB;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 has 'storage' =>
13 0 ▶ ( is => 'rw', default => sub { Moo::Google::AuthStorage::ConfigJSON->new } )
Subroutine __ANON__: not called CC=1 SCAR=6.9
14 1 ; # by default
15 1 has 'is_set' => ( is => 'rw', default => 0 );
16  
17  
18 0 ▶sub setup {
Subroutine setup: not called CC=4 SCAR=30.0
Pod documented
19 0 my ( $self, $params ) = @_;
20 0 ▶ if ( $params->{type} eq 'jsonfile' ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($params->{'type'} eq 'jsonfile') { } 0 0 0
elsif ($params->{'type'} eq 'dbi') { } 0 0 0
elsif ($params->{'type'} eq 'mongo') { } 0 0 0
21 0 $self->storage->pathToTokensFile( $params->{path} );
22 0 $self->storage->setup;
23 0 $self->is_set(1);
24 }
25 elsif ( $params->{type} eq 'dbi' ) {
26 0 $self->storage( Moo::Google::AuthStorage::DBI->new );
27 0 $self->storage->dbi( $params->{path} );
28 0 $self->storage->setup;
29 0 $self->is_set(1);
30 }
31 elsif ( $params->{type} eq 'mongo' ) {
32 0 $self->storage( Moo::Google::AuthStorage::MongoDB->new );
33 0 $self->storage->mongo( $params->{path} );
34 0 $self->storage->setup;
35 0 $self->is_set(1);
36 }
37 else {
38 0 die "Unknown storage type. Allowed types are jsonfile, dbi and mongo";
39 }
40 }
41  
42  
43 0 ▶sub file_exists {
Subroutine file_exists: not called CC=2 SCAR=17.9
Pod documented
44 0 my ( $self, $filename ) = @_;
45 0 ▶ if ( -e $filename ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $filename) { } 0 0 0
46 0 return 1;
47 }
48 else {
49 0 return 0;
50 }
51 }
52  
53 ### Below are list of methods that each Storage subclass must provide
54  
55  
56 0 ▶sub get_credentials_for_refresh {
Subroutine get_credentials_for_refresh: not called CC=1 SCAR=6.9
Pod documented
57 0 my ( $self, $user ) = @_;
58 0 $self->storage->get_credentials_for_refresh($user);
59 }
60  
61 0 ▶sub get_access_token_from_storage {
Subroutine get_access_token_from_storage: not called CC=1 SCAR=6.9
Pod undocumented
62 0 my ( $self, $user ) = @_;
63 0 $self->storage->get_access_token_from_storage($user);
64 }
65  
66 0 ▶sub set_access_token_to_storage {
Subroutine set_access_token_to_storage: not called CC=1 SCAR=6.9
Pod undocumented
67 0 my ( $self, $user, $access_token ) = @_;
68 0 $self->storage->set_access_token_to_storage( $user, $access_token );
69 }
70  
71 1 1;
72  
73 __END__
« Google.pm ↑ Summary Google/Discovery.pm »