SPOJ.pm

filter: Statementstmt 96.4% 27 / 28 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 88.8% 40 / 45 CC 5 SCAR 9.0
CC
5
Cov
86%
ua
4.5
service
2.1
BEGIN
1.0
CRAP 2.5
« SPOJ/User.pm ↑ Summary
1 package WWW::SPOJ;
2  
3 =head1 NAME
4  
5 WWW::SPOJ - Extract data from Sphere Online Judge (SPOJ)
6  
7 =head1 SYNOPSIS
8  
9 use WWW::SPOJ;
10  
11 my $ua = WWW::SPOJ::ua();
12 $ua->timeout(10);
13 $ua->env_proxy;
14
15 my $user = new WWW::SPOJ::User('john_jones');
16  
17  
18 =head1 DESCRIPTION AND MOTIVATION
19  
20 The Sphere Online Judge, better known by its acronym, SPOJ, is an online
21 archive of programming problems complete with a judge program that receives
22 and checks submissions. Common utilities requested by users of this site
23 include a user head-to-head comparer, a programming language preference
24 analyzer, a user activity grapher, etc. This distribution aims to simplify
25 building those and similar tools by providing modules and functions that
26 retrieve and parse data from SPOJ.
27  
28 =cut
29  
30 3 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 3 ▶use WWW::SPOJ::User;
Subroutine BEGIN: called CC=1 SCAR=0.0
37  
38 3 our $VERSION = '0.00_01';
39 3 $VERSION = eval $VERSION;
40  
41 3 my $ua;
42 3 my $service = 'http://www.spoj.pl/';
43  
44 =head1 FUNCTIONS
45  
46 =over 4
47  
48 =item WWW::SPOJ::ua( [ USER_AGENT ] )
49  
50 Returns the user agent object used for all retrievals, first setting
51 it to USER_AGENT if it's specified. Defaults to a C<new> L<LWP::UserAgent>.
52 You can customize this object as in the L</SYNOPSIS>.
53  
54 If you decide to replace the user agent altogether, you don't have to use
55 a L<LWP::UserAgent>: the only requirement is that the object you use can
56 C<get> a URL and return a response object.
57  
58 =cut
59  
60 1 ▶sub ua {
Subroutine ua: called CC=4 SCAR=15.0
Pod documented
61 1 ▶ if(@_) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_) { } 0 1 1
elsif (not defined $ua) { } 1 0 1
62 0 $ua = shift;
63 }
64 elsif(!defined($ua)) {
65 1 eval {
66 1 require LWP::UserAgent;
67 1 $ua = new LWP::UserAgent;
68 };
69 }
70 1 ▶ defined($ua) or carp 'Problem setting user agent';
Branch: 1 branch
BranchTrueFalseTotal
defined $ua or carp("Problem setting user agent") 1 0 1
71 1 return $ua;
72 }
73  
74 =item WWW::SPOJ::service( [ URL ] )
75  
76 Returns the web address of the service used by this module, first setting
77 it to URL if it's specified. Defaults to L<http://www.spoj.pl/>.
78  
79 =back
80  
81 =cut
82  
83 1 ▶sub service {
Subroutine service: called CC=2 SCAR=7.2
Pod documented
84 1 ▶ $service = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 1 1
85 1 return $service;
86 }
87  
88 3 1;
89  
90 __END__
« SPOJ/User.pm ↑ Summary