File Coverage

blib/lib/Duadua/Parser/Bot/GooglebotMisc.pm
Criterion Covered Total %
statement 35 35 100.0
branch 25 28 89.2
condition 3 3 100.0
subroutine 3 3 100.0
pod 1 1 100.0
total 67 70 95.7


line stmt bran cond sub pod time code
1             package Duadua::Parser::Bot::GooglebotMisc;
2 6     6   39 use strict;
  6         13  
  6         176  
3 6     6   49 use warnings;
  6         12  
  6         3005  
4              
5             sub try {
6 194     194 1 445 my ($class, $d) = @_;
7              
8 194 100       432 return unless index($d->ua, 'Google') > -1;
9              
10 17 100       43 if ( index($d->ua, 'Googlebot-Image') > -1 ) {
11 2         9 my $h = {
12             name => 'Googlebot-Image',
13             is_bot => 1,
14             };
15              
16 2 100       6 if ($d->opt_version) {
17 1         5 my ($version) = ($d->ua =~ m!^Googlebot-Image/([\d.]+)!);
18 1 50       6 $h->{version} = $version if $version;
19             }
20              
21 2         10 return $h;
22             }
23              
24 15 100       137 if ( index($d->ua, 'Googlebot-News') > -1 ) {
25             return {
26 1         7 name => 'Googlebot-News',
27             is_bot => 1,
28             };
29             }
30              
31 14 100       31 if ( index($d->ua, 'Googlebot-Video') > -1 ) {
32 2         8 my $h = {
33             name => 'Googlebot-Video',
34             is_bot => 1,
35             };
36              
37 2 100       5 if ($d->opt_version) {
38 1         7 my ($version) = ($d->ua =~ m!^Googlebot-Video/([\d.]+)!);
39 1 50       6 $h->{version} = $version if $version;
40             }
41              
42 2         9 return $h;
43             }
44              
45 12 100       30 if ( index($d->ua, 'FeedFetcher-Google') == 0 ) {
46             return {
47 1         8 name => 'FeedFetcher-Google',
48             is_bot => 1,
49             };
50             }
51              
52 11 100 100     88 if ( index($d->ua, ' AppEngine-Google;') > -1 || index($d->ua, 'AppEngine-Google; ') > -1 ) {
53             return {
54 2         12 name => 'AppEngine-Google',
55             is_bot => 1,
56             };
57             }
58              
59 9 100       27 if ( index($d->ua, ' Google-Site-Verification') > -1 ) {
60 2         8 my $h = {
61             name => 'Google-Site-Verification',
62             is_bot => 1,
63             };
64              
65 2 100       7 if ($d->opt_version) {
66 1         4 my ($version) = ($d->ua =~ m! Google-Site-Verification/([\d.]+)!);
67 1 50       7 $h->{version} = $version if $version;
68             }
69              
70 2         9 return $h;
71             }
72              
73 7 100       17 if ( index($d->ua, ' Google Page Speed Insights') > -1 ) {
74 1         5 my $h = {
75             name => 'Google Page Speed Insights',
76             is_bot => 1,
77             };
78              
79 1         4 return Duadua::Util->set_os($d, $h);
80             }
81             }
82              
83             1;
84              
85             __END__