File Coverage

blib/lib/Duadua/Parser/Bot/Googlebot.pm
Criterion Covered Total %
statement 22 22 100.0
branch 11 12 91.6
condition 3 3 100.0
subroutine 4 4 100.0
pod 1 1 100.0
total 41 42 97.6


line stmt bran cond sub pod time code
1             package Duadua::Parser::Bot::Googlebot;
2 6     6   773 use strict;
  6         10  
  6         250  
3 6     6   30 use warnings;
  6         10  
  6         136  
4 6     6   26 use Duadua::Util;
  6         12  
  6         1541  
5              
6             sub try {
7 367     367 1 749 my ($class, $d) = @_;
8              
9 367 100       743 return unless index($d->ua, 'Google') > -1;
10              
11 49 100 100     134 if ( index($d->ua, 'Googlebot') > -1 && index($d->ua, 'Googlebot-') == -1 ) {
12 18         55 my $h = {
13             name => 'Googlebot',
14             is_bot => 1,
15             };
16              
17 18 100       42 if ($d->opt_version) {
18 11         31 my ($version) = ($d->ua =~ m!Googlebot/([\d.]+)!);
19 11 50       38 $h->{version} = $version if $version;
20             }
21              
22 18         66 return Duadua::Util->set_os($d, $h);
23             }
24              
25 31 100       67 if ( index($d->ua, 'Google Favicon') > -1 ) {
26 1         30 my $h = {
27             name => 'Google Favicon',
28             is_bot => 1,
29             };
30              
31 1         8 return Duadua::Util->set_os($d, $h);
32             }
33              
34 30 100       71 if ( index($d->ua, 'APIs-Google') > -1 ) {
35             return {
36 1         6 name => 'APIs-Google',
37             is_bot => 1,
38             };
39             }
40             }
41              
42             1;
43              
44             __END__