Google/tool.pm

filter: Statementstmt 37.5% 18 / 48 Branchbran 6.2% 1 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 42.8% 3 / 7 Podpod 0.0% 0 / 4 totaltotal 29.3% 22 / 75 CC 9 SCAR 19.2
CC
9
Cov
30%
_queries
12.0
init
7.2
queries_exhausted
6.0
CRAP 6.8
« Google/Spelling.pm ↑ Summary Google/Response.pm »
1 package Net::Google::tool;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 3 $Net::Google::tool::VERSION = '1.1';
5  
6 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 my %_queries = ();
9  
10 3 ▶sub init {
Subroutine init: called CC=4 SCAR=19.7
Pod undocumented
11 3 my $self = shift;
12 3 my $service = shift;
13  
14 # old skool / new skool
15 # arguments.
16  
17 3 my $first_arg = shift;
18 3 my $poss_second = shift;
19  
20 # What everyone will actually
21 # play with.
22  
23 3 my $args = undef;
24  
25 #
26  
27 3 ▶ if (ref($first_arg) eq "GoogleSearchService") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $first_arg eq 'GoogleSearchService') { } 0 3 3
28 0 $self->{'_service'} = $first_arg;
29 0 $args = $poss_second;
30 }
31  
32 else {
33 3 $args = $first_arg;
34  
35 3 require Net::Google::Service;
36  
37 3 $self->{'_service'} = Net::Google::Service->$service($args);
38 0 ▶ if (! $self->{'_service'}) { return 0; }
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_service"}) 0 0 0
39 }
40  
41 #
42  
43 0 ▶ if (! $args->{'key'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args->{"key"}) 0 0 0
44 0 carp "You must define a key";
45 0 return 0;
46 }
47  
48 0 $self->key($args->{'key'});
49  
50 #
51  
52 0 return $args;
53 }
54  
55 0 ▶sub _queries {
Subroutine _queries: not called CC=3 SCAR=24.8
56 0 my $self = shift;
57 0 my $count = shift;
58  
59 0 my $key = $self->key();
60  
61 0 ▶ if (! exists($_queries{$key})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $_queries{$key}) 0 0 0
62 0 $_queries{$key} = 0;
63 }
64  
65 0 ▶ if (int($count)) {
Branch: 1 branch
BranchTrueFalseTotal
if (int $count) 0 0 0
66 0 $_queries{$key} += int($count);
67 }
68  
69 0 return $_queries{$key};
70 }
71  
72 0 ▶sub queries_exhausted {
Subroutine queries_exhausted: not called CC=2 SCAR=17.9
Pod undocumented
73 0 my $self = shift;
74 0 ▶ return ($self->_queries() >= 1000) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->_queries >= 1000 ? : 0 0 0
75 }
76  
77 0 ▶sub key {
Subroutine key: not called CC=2 SCAR=17.9
Pod undocumented
78 0 my $self = shift;
79 0 my $key = shift;
80  
81 0 ▶ if (defined($key)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $key) 0 0 0
82 0 $self->{'_key'} = $key;
83 }
84  
85 0 return $self->{'_key'};
86 }
87  
88 0 ▶sub http_proxy {
Subroutine http_proxy: not called CC=2 SCAR=17.9
Pod undocumented
89 0 my $self = shift;
90 0 my $uri = shift;
91  
92 0 ▶ if ($uri) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uri) 0 0 0
93 # See notes in Net::Google::Service->_soap()
94 0 shift->{'_service'}->transport()->proxy($uri)->proxy(http=>$uri);
95 0 $self->{'_http_proxy'} = $uri;
96 }
97  
98 0 return $self->{'_http_proxy'};
99 }
100  
101 3 return 1;
102  
103 __END__
« Google/Spelling.pm ↑ Summary Google/Response.pm »