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 11     11   1206 use strict;
  11         19  
  11         2404  
3 11     11   54 use warnings;
  11         24  
  11         3789  
4              
5             sub try {
6 349     349 1 866 my ($class, $d) = @_;
7              
8 349 100 66     889 if ( $d->_contain('BingPreview/')
9             && $d->_contain_mozilla ) {
10 4         15 my $h = _set_property($d, 'BingPreview');
11              
12 4 100       17 if ($d->opt_version) {
13 2         8 my ($version) = ($d->ua =~ m!BingPreview/([\d.a-z]+)!);
14 2 50       11 $h->{version} = $version if $version;
15             }
16              
17 4         17 return $h;
18             }
19             }
20              
21             sub _set_property {
22 4     4   14 my ($d, $name) = @_;
23              
24 4         18 my $h = {
25             name => $name,
26             is_bot => 1,
27             };
28              
29 4 50       14 if ( $d->_contain('Windows') ) {
30 4         16 $h->{is_windows} = 1;
31             }
32              
33 4         10 return $h;
34             }
35              
36             1;
37              
38             __END__