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 11     11   169 use strict;
  11         54  
  11         446  
3 11     11   59 use warnings;
  11         21  
  11         4119  
4              
5             sub try {
6 372     372 1 849 my ($class, $d) = @_;
7              
8 372 50 66     1232 if ( $d->_contain('bingbot/')
      66        
9             && $d->_contain('+http://www.bing.com/bingbot.htm')
10             && $d->_contain_mozilla ) {
11 6         19 my $h = _set_property($d, 'Bingbot');
12              
13 6 100       22 if ($d->opt_version) {
14 3         10 my ($version) = ($d->ua =~ m!bingbot/([\d.]+)!);
15 3 50       18 $h->{version} = $version if $version;
16             }
17              
18 6         26 return $h;
19             }
20             }
21              
22             sub _set_property {
23 6     6   15 my ($d, $name) = @_;
24              
25 6         28 my $h = {
26             name => $name,
27             is_bot => 1,
28             };
29              
30 6 100       19 if ( $d->_contain('Windows') ) {
    100          
31 2         9 $h->{is_windows} = 1;
32             }
33             elsif ( $d->_contain('iPhone') ) {
34 2         7 $h->{is_ios} = 1;
35             }
36              
37 6         17 return $h;
38             }
39              
40             1;
41              
42             __END__