Google.pm

filter: Statementstmt 38.4% 15 / 39 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 37.5% 3 / 8 Podpod 0.0% 0 / 1 totaltotal 31.0% 18 / 58 CC 6 SCAR 25.8
CC
6
Cov
31%
request
30.0
AUTOLOAD
6.0
__ANON__
2.0
CRAP 13.2
« Google/Util.pm ↑ Summary Google/AuthStorage.pm »
1 package Moo::Google;
2 1 $Moo::Google::VERSION = '0.03';
3  
4 # ABSTRACT: Server-side client library for any Google App API. Based on Moose
5  
6  
7 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Moo::Google::Client;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 has 'debug' => ( is => 'rw', default => 0, lazy => 1 );
12 has 'client' => (
13 is => 'ro',
14 0 ▶ default => sub { Moo::Google::Client->new( debug => shift->debug ) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
15 1 handles => [qw(access_token user auth_storage do_autorefresh api_query)],
16 lazy => 1
17 );
18 has 'util' => (
19 is => 'ro',
20 0 ▶ default => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
21 0 require Moo::Google::Util;
22 0 Moo::Google::Util->new( debug => shift->debug );
23 },
24 1 handles => [qw(substitute_placeholders)],
25 lazy => 1
26 );
27 has 'discovery' => (
28 is => 'ro',
29 0 ▶ default => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
30 0 require Moo::Google::Discovery;
31 0 Moo::Google::Discovery->new( debug => shift->debug );
32 },
33 1 handles => [qw(getMethodMeta)],
34 lazy => 1
35 );
36  
37 0 ▶sub request {
Subroutine request: not called CC=5 SCAR=34.0
Pod undocumented
38 0 my ( $self, $caller, $params ) = @_;
39  
40 # my $caller = (caller(0))[3];
41 0 ▶ warn "Caller: " . $caller
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
42 if ( $self->debug ); # like Moo::Google::Calendar::Events::list
43 0 ▶ warn "request PARAMETERS: " . Dumper $params if ( $self->debug );
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
44  
45 0 my $api_q_data = $self->getMethodMeta($caller);
46 0 $api_q_data->{options} = $params->{options};
47 0 delete $params->{options};
48  
49 0 ▶ warn 'API query data: ' . Dumper $api_q_data if ( $self->debug );
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
50  
51 # get $params from $caller object
52 # proxying $self->Service->Resource attributes
53  
54 $api_q_data->{path} =
55 0 $self->substitute_placeholders( $api_q_data->{path}, $params ); # util
56 0 ▶ warn 'API query data: ' . Dumper $api_q_data if ( $self->debug );
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
57 0 $self->api_query($api_q_data); # path, httpMethod
58 }
59  
60 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=2 SCAR=17.9
61 0 my $self = shift;
62 0 our $AUTOLOAD;
63 0 my $unknown_resource =
64 ( split( /::/, $AUTOLOAD ) )[-1]; # $unknown_method_name = API
65 0 ▶ warn $unknown_resource if ( $self->debug );
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
66 0 require Moo::Google::Services;
67 0 my $a = Moo::Google::Services->new;
68 0 $a->debug( $self->debug );
69 0 $a->generate_one( $self, lcfirst $unknown_resource );
70 0 $self->$unknown_resource;
71 }
72  
73  
74  
75 1 1;
76  
77 __END__
« Google/Util.pm ↑ Summary Google/AuthStorage.pm »