File Coverage

blib/lib/Duadua/Util.pm
Criterion Covered Total %
statement 25 25 100.0
branch 16 16 100.0
condition 12 18 66.6
subroutine 4 4 100.0
pod 2 2 100.0
total 59 65 90.7


line stmt bran cond sub pod time code
1             package Duadua::Util;
2 11     11   69 use strict;
  11         20  
  11         390  
3 11     11   52 use warnings;
  11         30  
  11         4210  
4              
5             sub set_os {
6 168     168 1 480 my ($class, $d, $h) = @_;
7              
8 168 100 66     380 if ( $d->_contain('Win') && ($d->_contain('Win32') || $d->_contain('Windows')) ) {
    100 66        
    100 66        
    100 66        
    100 66        
    100 66        
    100          
9 33         86 $h->{is_windows} = 1;
10             }
11             elsif ( $d->_contain('Android') ) {
12 36         107 $h->{is_android} = 1;
13 36         107 $h->{is_linux} = 1; # Android is Linux also.
14             }
15             elsif ( $d->_contain('iPhone') ) {
16 20         75 $h->{is_ios} = 1;
17             }
18             elsif ( $d->_contain('iP') && ($d->_contain('iPad') || $d->_contain('iPod')) ) {
19 2         7 $h->{is_ios} = 1;
20             }
21             elsif ( $d->_contain('Mac') && ($d->_contain('Macintosh') || $d->_contain('Mac OS')) ) {
22 2         5 $h->{is_ios} = 1;
23             }
24             elsif ( $d->_contain(' CrOS ') ) {
25 2         8 $h->{is_chromeos} = 1;
26             }
27             elsif ( $d->_contain('Linux') ) {
28 16         49 $h->{is_linux} = 1;
29             }
30              
31 168         733 return $h;
32             }
33              
34             sub ordering_match {
35 62     62 1 188 my ($class, $d, $list) = @_;
36              
37 62         123 my $pre = 0;
38 62         105 for my $word (@{$list}) {
  62         130  
39 104         218 my $position = index($d->ua, $word);
40 104 100       602 return 0 if $position < $pre;
41 49         97 $pre = $position;
42             }
43              
44 7         54 return 1; # Match!
45             }
46              
47             1;
48              
49             __END__