File Coverage

blib/lib/Duadua/Parser/Bot/GooglebotMisc.pm
Criterion Covered Total %
statement 59 61 96.7
branch 44 52 84.6
condition 4 5 80.0
subroutine 3 3 100.0
pod 1 1 100.0
total 111 122 90.9


line stmt bran cond sub pod time code
1             package Duadua::Parser::Bot::GooglebotMisc;
2 11     11   69 use strict;
  11         23  
  11         377  
3 11     11   49 use warnings;
  11         21  
  11         11933  
4              
5             sub try {
6 218     218 1 449 my ($class, $d) = @_;
7              
8 218 100       486 return unless $d->_contain('Google');
9              
10 31 100       86 if ( $d->_contain('Googlebot-Image') ) {
11 2         11 my $h = {
12             name => 'Googlebot-Image',
13             is_bot => 1,
14             };
15              
16 2 100       9 if ($d->opt_version) {
17 1         4 my ($version) = ($d->ua =~ m!^Googlebot-Image/([\d.]+)!);
18 1 50       6 $h->{version} = $version if $version;
19             }
20              
21 2         9 return $h;
22             }
23              
24 29 100       73 if ( $d->_contain('Googlebot-News') ) {
25             return {
26 1         6 name => 'Googlebot-News',
27             is_bot => 1,
28             };
29             }
30              
31 28 100       71 if ( $d->_contain('Googlebot-Video') ) {
32 2         12 my $h = {
33             name => 'Googlebot-Video',
34             is_bot => 1,
35             };
36              
37 2 100       8 if ($d->opt_version) {
38 1         6 my ($version) = ($d->ua =~ m!^Googlebot-Video/([\d.]+)!);
39 1 50       8 $h->{version} = $version if $version;
40             }
41              
42 2         9 return $h;
43             }
44              
45 26 100       103 if ( $d->_contain('Storebot-Google') ) {
46 4         23 my $h = {
47             name => 'Storebot-Google',
48             is_bot => 1,
49             };
50              
51 4 100       15 if ($d->opt_version) {
52 2         14 my ($version) = ($d->ua =~ m!Storebot-Google/([\d.]+)!);
53 2 50       12 $h->{version} = $version if $version;
54             }
55              
56 4         19 return Duadua::Util->set_os($d, $h)
57             }
58              
59 22 100       58 if ( $d->_contain('Google-InspectionTool') ) {
60 4         20 my $h = {
61             name => 'Google-InspectionTool',
62             is_bot => 1,
63             };
64              
65 4 100       16 if ($d->opt_version) {
66 2         6 my ($version) = ($d->ua =~ m!Google-InspectionTool/([\d.]+)!);
67 2 50       10 $h->{version} = $version if $version;
68             }
69              
70 4         16 return Duadua::Util->set_os($d, $h)
71             }
72              
73 18 100       73 if ( $d->_prefix('GoogleOther-') ) {
    100          
74 2         9 my ($type) = ($d->ua =~ m!^GoogleOther-(Image|Video)/!);
75 2   50     9 $type ||= 'UNKNOWN';
76 2         12 my $h = {
77             name => "GoogleOther-$type",
78             is_bot => 1,
79             };
80              
81 2 50       9 if ($d->opt_version) {
82 0         0 my ($version) = ($d->ua =~ m!^Google-.+/([\d.]+)!);
83 0 0       0 $h->{version} = $version if $version;
84             }
85              
86 2         10 return $h;
87             }
88             elsif ( $d->_contain('GoogleOther') ) {
89 3         18 my $h = {
90             name => 'GoogleOther',
91             is_bot => 1,
92             };
93              
94 3 100       12 if ($d->ua eq 'GoogleOther') {
95 1         5 return $h;
96             }
97              
98 2         11 return Duadua::Util->set_os($d, $h);
99             }
100              
101 13 100       61 if ( $d->_prefix('FeedFetcher-Google') ) {
102             return {
103 1         7 name => 'FeedFetcher-Google',
104             is_bot => 1,
105             };
106             }
107              
108 12 100 100     39 if ( $d->_contain(' AppEngine-Google;') || $d->_contain('AppEngine-Google; ') ) {
109             return {
110 2         10 name => 'AppEngine-Google',
111             is_bot => 1,
112             };
113             }
114              
115 10 100       49 if ( $d->_contain(' Google-Site-Verification') ) {
116 2         10 my $h = {
117             name => 'Google-Site-Verification',
118             is_bot => 1,
119             };
120              
121 2 100       9 if ($d->opt_version) {
122 1         6 my ($version) = ($d->ua =~ m! Google-Site-Verification/([\d.]+)!);
123 1 50       7 $h->{version} = $version if $version;
124             }
125              
126 2         8 return $h;
127             }
128              
129 8 100       26 if ( $d->_contain(' Google Page Speed Insights') ) {
130 1         6 my $h = {
131             name => 'Google Page Speed Insights',
132             is_bot => 1,
133             };
134              
135 1         6 return Duadua::Util->set_os($d, $h);
136             }
137              
138 7 100       28 if ( $d->_prefix('GoogleProducer;') ) {
139             return {
140 1         8 name => 'GoogleProducer',
141             is_bot => 1,
142             };
143             }
144             }
145              
146             1;
147              
148             __END__