| 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
| |||||||||||
| 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
| |||||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | # | ||||||||||
| 42 | |||||||||||
| 43 | 0 | ▶ | if (! $args->{'key'}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 62 | 0 | $_queries{$key} = 0; | |||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | 0 | ▶ | if (int($count)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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__ | ||||||||||