File Coverage

blib/lib/Woothee/MobilePhone.pm
Criterion Covered Total %
statement 64 73 87.6
branch 24 30 80.0
condition 18 18 100.0
subroutine 10 10 100.0
pod 0 5 0.0
total 116 136 85.2


line stmt bran cond sub pod time code
1             package Woothee::MobilePhone;
2              
3 6     6   36 use strict;
  6         11  
  6         145  
4 6     6   37 use warnings;
  6         12  
  6         118  
5 6     6   24 use Carp;
  6         10  
  6         286  
6              
7 6     6   27 use Woothee::Util qw/update_map update_category update_version update_os/;
  6         10  
  6         277  
8 6     6   28 use Woothee::DataSet qw/dataset/;
  6         11  
  6         4954  
9              
10             our $VERSION = "1.8.0";
11              
12             sub challenge_docomo {
13 333     333 0 508 my ($ua, $result) = @_;
14              
15 333 100 100     1548 return 0 if (index($ua, "DoCoMo") < 0 and index($ua, ";FOMA;") < 0);
16              
17 18         26 my $version;
18 18 100       110 if ($ua =~ m{DoCoMo/[.0-9]+[ /]([^- /;()"']+)}o) {
    50          
19 12         31 $version = $1;
20             }
21             elsif ($ua =~ m{\(([^;)]+);FOMA;}o) {
22 6         18 $version = $1;
23             }
24             else {
25 0         0 $version = Woothee::DataSet->const('VALUE_UNKNOWN');
26             }
27 18         39 update_map($result, dataset("docomo"));
28 18         52 update_version($result, $version);
29 18         49 return 1;
30             }
31              
32             sub challenge_au {
33 315     315 0 471 my ($ua, $result) = @_;
34              
35 315 100       897 return 0 if index($ua, "KDDI-") < 0;
36              
37 6         12 my $version;
38             # fix Woothee::OS::challenge_mobile if you want to fix here
39 6 50       36 if ($ua =~ m{KDDI-([^- /;()"']+)}o) {
40 6         15 $version = $1;
41             }
42             else {
43 0         0 $version = Woothee::DataSet->const('VALUE_UNKNOWN');
44             }
45 6         18 update_map($result, dataset("au"));
46 6         20 update_version($result, $version);
47 6         14 return 1;
48             }
49              
50             sub challenge_softbank {
51 309     309 0 421 my ($ua, $result) = @_;
52              
53 309 100 100     1831 return 0 if index($ua, "SoftBank") < 0 and index($ua, "Vodafone") < 0 and index($ua, "J-PHONE") < 0;
      100        
54              
55 21         30 my $version;
56 21 50       147 if ($ua =~ m{(?:SoftBank|Vodafone|J-PHONE)/[.0-9]+/([^ /;()]+)}o) {
57 21         50 $version = $1;
58             }
59             else {
60 0         0 $version = Woothee::DataSet->const('VALUE_UNKNOWN');
61             }
62 21         47 update_map($result, dataset("SoftBank"));
63 21         58 update_version($result, $version);
64 21         49 return 1;
65             }
66              
67             sub challenge_willcom {
68 288     288 0 436 my ($ua, $result) = @_;
69              
70 288 100 100     1232 return 0 if index($ua, "WILLCOM") < 0 and index($ua, "DDIPOCKET") < 0;
71              
72 9         14 my $version;
73             # fix Woothee::OS::challenge_mobile if you want to fix here
74 9 50       67 if ($ua =~ m{(?:WILLCOM|DDIPOCKET);[^/]+/([^ /;()]+)}o) {
75 9         26 $version = $1;
76             }
77             else {
78 0         0 $version = Woothee::DataSet->const('VALUE_UNKNOWN');
79             }
80 9         25 update_map($result, dataset("willcom"));
81 9         29 update_version($result, $version);
82 9         27 return 1;
83             }
84              
85             sub challenge_misc {
86 279     279 0 441 my ($ua, $result) = @_;
87              
88 279 100       631 if (index($ua, "jig browser") > -1) {
89 9         29 update_map($result, dataset("jig"));
90 9 100       60 if ($ua =~ m{jig browser[^;]+; ([^);]+)}o) {
91 6         19 update_version($result, $1);
92             }
93 9         30 return 1;
94             }
95 270 100 100     1326 if (index($ua, "emobile/") > -1 || index($ua, "OpenBrowser") > -1 || index($ua, "Browser/Obigo-Browser") > -1) {
      100        
96 12         28 update_map($result, dataset("emobile"));
97 12         50 return 1;
98             }
99 258 50       533 if (index($ua, "SymbianOS") > -1) {
100 0         0 update_map($result, dataset("SymbianOS"));
101 0         0 return 1;
102             }
103 258 50       510 if (index($ua, "Hatena-Mobile-Gateway/") > -1) {
104 0         0 update_map($result, dataset("MobileTranscoder"));
105 0         0 update_version($result, "Hatena");
106 0         0 return 1;
107             }
108 258 100       556 if (index($ua, "livedoor-Mobile-Gateway/") > -1) {
109 3         77 update_map($result, dataset("MobileTranscoder"));
110 3         41 update_version($result, "livedoor");
111 3         12 return 1;
112             }
113              
114 255         518 return 0;
115             }
116              
117             1;
118              
119             __END__