line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Google::tool; |
2
|
3
|
|
|
3
|
|
17
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
164
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
$Net::Google::tool::VERSION = '1.1'; |
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
17
|
use Carp; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
2226
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my %_queries = (); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub init { |
11
|
3
|
|
|
3
|
0
|
6
|
my $self = shift; |
12
|
3
|
|
|
|
|
5
|
my $service = shift; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# old skool / new skool |
15
|
|
|
|
|
|
|
# arguments. |
16
|
|
|
|
|
|
|
|
17
|
3
|
|
|
|
|
4
|
my $first_arg = shift; |
18
|
3
|
|
|
|
|
6
|
my $poss_second = shift; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# What everyone will actually |
21
|
|
|
|
|
|
|
# play with. |
22
|
|
|
|
|
|
|
|
23
|
3
|
|
|
|
|
5
|
my $args = undef; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# |
26
|
|
|
|
|
|
|
|
27
|
3
|
50
|
|
|
|
13
|
if (ref($first_arg) eq "GoogleSearchService") { |
28
|
0
|
|
|
|
|
0
|
$self->{'_service'} = $first_arg; |
29
|
0
|
|
|
|
|
0
|
$args = $poss_second; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
else { |
33
|
3
|
|
|
|
|
7
|
$args = $first_arg; |
34
|
|
|
|
|
|
|
|
35
|
3
|
|
|
|
|
1706
|
require Net::Google::Service; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
$self->{'_service'} = Net::Google::Service->$service($args); |
38
|
0
|
0
|
|
|
|
|
if (! $self->{'_service'}) { return 0; } |
|
0
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# |
42
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
|
if (! $args->{'key'}) { |
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
|
|
|
|
|
|
|
sub _queries { |
56
|
0
|
|
|
0
|
|
|
my $self = shift; |
57
|
0
|
|
|
|
|
|
my $count = shift; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my $key = $self->key(); |
60
|
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
if (! exists($_queries{$key})) { |
62
|
0
|
|
|
|
|
|
$_queries{$key} = 0; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
|
if (int($count)) { |
66
|
0
|
|
|
|
|
|
$_queries{$key} += int($count); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
return $_queries{$key}; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub queries_exhausted { |
73
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
74
|
0
|
0
|
|
|
|
|
return ($self->_queries() >= 1000) ? 1 : 0; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub key { |
78
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
79
|
0
|
|
|
|
|
|
my $key = shift; |
80
|
|
|
|
|
|
|
|
81
|
0
|
0
|
|
|
|
|
if (defined($key)) { |
82
|
0
|
|
|
|
|
|
$self->{'_key'} = $key; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
return $self->{'_key'}; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub http_proxy { |
89
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
90
|
0
|
|
|
|
|
|
my $uri = shift; |
91
|
|
|
|
|
|
|
|
92
|
0
|
0
|
|
|
|
|
if ($uri) { |
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
|
|
|
|
|
|
|
return 1; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
__END__ |