Robot.pm

filter: Statementstmt 36.3% 8 / 22 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 22.2% 2 / 9 Podpod 42.8% 3 / 7 totaltotal 27.6% 13 / 47 CC 4 SCAR 20.6
CC
4
Cov
28%
new
20.0
uastring
2.0
family
2.0
CRAP 7.8
« Browser.pm ↑ Summary OS.pm »
1 package HTTP::UserAgentString::Robot;
2  
3 =head1 NAME
4  
5 HTTP::UserAgentString::Robot - Web robot
6  
7 =head1 SYNOPSIS
8  
9 $robot = $p->parse($string)
10  
11 print "This is a ", ($robot->isRobot()) ? "robot" : "browser", "\n";
12 print "Family: ", $robot->family(), "\n";
13 print "Name: ", $robot->name(), "\n";
14 print "URL: ", $robot->url(), "\n";
15 print "Company: ", $robot->company(), "\n";
16 print "Company URL: ", $robot->company_url(), "\n";
17 print "Info URL: ", $robot->info_url(), "\n";
18
19 $os = $robot->os();
20  
21 =head1 DESCRIPTION
22  
23 Used to represent web robots returned by L<HTTP::UserAgentString::Parser>. Object is read
24 only. Accesors are provided for all capabilities defined by
25 user-agent-string.info
26  
27 =head1 METHODS
28  
29 =over 4
30  
31 =item $robot->family()
32  
33 Robot family. I.e, name without version.
34  
35 =item $robot->name()
36  
37 Robot name including version
38  
39 =item $robot->url()
40  
41 Web page for the robot
42  
43 =item $robot->company()
44  
45 Name of the company that develops the robot
46  
47 =item $robot->company_url()
48  
49 URL of the company that develops the robot
50  
51 =item $robot->ico()
52  
53 PNG icon for the robot that can be obtained from http://user-agent-string.info/pub/img/ua/
54  
55 =item $robot->info_url()
56  
57 Web page in http://user-agent-string.info/ that provides information on the robot
58  
59 =item $robot->os
60  
61 If defined, L<HTTP::UserAgentString::OS> object representing the operating system where the robot is
62 running.
63  
64 =back
65  
66 =head1 SEE ALSO
67  
68 L<HTTP::UserAgentString::OS> for the class representing operating systems, and L<UAS::Browser>
69 for browsers.
70  
71 =head1 COPYRIGHT
72  
73 Copyright (c) 2011 Nicolas Moldavsky (http://www.e-planning.net/)
74 This library is released under LGPL V3
75  
76 =cut
77  
78 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
79 4 ▶use base qw(HTTP::UserAgentString::Sys);
Subroutine BEGIN: called CC=1 SCAR=0.0
80  
81 4 my @KEYS = qw(uastring family name url company company_url ico os_id info_url);
82  
83 0 ▶sub new($$;$) {
Subroutine new: not called CC=4 SCAR=30.0
Pod undocumented
84 0 my ($pkg, $data, $os) = @_;
85
86 0 my $h = {};
87 0 ▶ for (my $i = 0; $i < scalar(@KEYS); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @KEYS) 0 0 0
88 0 my $val = $data->[$i];
89 0 ▶ if (defined($val) and (length($val) > 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $val and length $val > 0) 0 0 0
Condition0%0/3
defined $val and length $val > 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $val and length $val > 0
defined $val length $val > 0
Truth table0%0/3
A and B
A= defined $valB= length $val > 0
ABresult
0X0
100
111
90 0 $h->{$KEYS[$i]} = $val;
91 }
92 }
93 0 $h->{os} = $os;
94 0 return bless($h, $pkg);
95 }
96  
97  
98 0 ▶sub uastring($) { $_[0]->{uastring} }
Subroutine uastring: not called CC=1 SCAR=6.9
Pod undocumented
99 0 ▶sub family($) { $_[0]->{family} }
Subroutine family: not called CC=1 SCAR=6.9
Pod documented
100 0 ▶sub info_url($) { $_[0]->{info_url} }
Subroutine info_url: not called CC=1 SCAR=6.9
Pod documented
101 0 ▶sub os($) { $_[0]->{os} }
Subroutine os: not called CC=1 SCAR=6.9
Pod documented
102 0 ▶sub os_id($) { $_[0]->{os_id} }
Subroutine os_id: not called CC=1 SCAR=6.9
Pod undocumented
103  
104 0 ▶sub isRobot($) { 1 }
Subroutine isRobot: not called CC=1 SCAR=6.9
Pod undocumented
105  
106 4 1;
« Browser.pm ↑ Summary OS.pm »