File Coverage

blib/lib/Duadua/Parser/Bot/BingPreview.pm
Criterion Covered Total %
statement 18 18 100.0
branch 6 8 75.0
condition 2 3 66.6
subroutine 4 4 100.0
pod 1 1 100.0
total 31 34 91.1


line stmt bran cond sub pod time code
1             package Duadua::Parser::Bot::BingPreview;
2 6     6   44 use strict;
  6         11  
  6         172  
3 6     6   34 use warnings;
  6         10  
  6         1586  
4              
5             sub try {
6 322     322 1 541 my ($class, $d) = @_;
7              
8 322 100 66     598 if ( index($d->ua, 'BingPreview/') > -1
9             && index($d->ua, 'Mozilla/') > -1 ) {
10 4         13 my $h = _set_property($d, 'BingPreview');
11              
12 4 100       8 if ($d->opt_version) {
13 2         6 my ($version) = ($d->ua =~ m!BingPreview/([\d.a-z]+)!);
14 2 50       9 $h->{version} = $version if $version;
15             }
16              
17 4         18 return $h;
18             }
19             }
20              
21             sub _set_property {
22 4     4   10 my ($d, $name) = @_;
23              
24 4         13 my $h = {
25             name => $name,
26             is_bot => 1,
27             };
28              
29 4 50       10 if ( index($d->ua, 'Windows') > -1 ) {
30 4         10 $h->{is_windows} = 1;
31             }
32              
33 4         10 return $h;
34             }
35              
36             1;
37              
38             __END__