File Coverage

blib/lib/Duadua/Parser/Bot/Bingbot.pm
Criterion Covered Total %
statement 19 19 100.0
branch 8 10 80.0
condition 4 6 66.6
subroutine 4 4 100.0
pod 1 1 100.0
total 36 40 90.0


line stmt bran cond sub pod time code
1             package Duadua::Parser::Bot::Bingbot;
2 6     6   40 use strict;
  6         13  
  6         170  
3 6     6   27 use warnings;
  6         12  
  6         1836  
4              
5             sub try {
6 334     334 1 658 my ($class, $d) = @_;
7              
8 334 50 66     611 if ( index($d->ua, 'bingbot/') > -1
      66        
9             && index($d->ua, '+http://www.bing.com/bingbot.htm') > -1
10             && index($d->ua, 'Mozilla/') > -1 ) {
11 6         15 my $h = _set_property($d, 'Bingbot');
12              
13 6 100       19 if ($d->opt_version) {
14 3         17 my ($version) = ($d->ua =~ m!bingbot/([\d.]+)!);
15 3 50       11 $h->{version} = $version if $version;
16             }
17              
18 6         25 return $h;
19             }
20             }
21              
22             sub _set_property {
23 6     6   15 my ($d, $name) = @_;
24              
25 6         20 my $h = {
26             name => $name,
27             is_bot => 1,
28             };
29              
30 6 100       15 if ( index($d->ua, 'Windows') > -1 ) {
    100          
31 2         7 $h->{is_windows} = 1;
32             }
33             elsif ( index($d->ua, 'iPhone') > -1 ) {
34 2         6 $h->{is_ios} = 1;
35             }
36              
37 6         14 return $h;
38             }
39              
40             1;
41              
42             __END__