line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
235022
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
59
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Webservice::Judobase; |
5
|
|
|
|
|
|
|
$Webservice::Judobase::VERSION = '0.10'; |
6
|
|
|
|
|
|
|
# ABSTRACT: This module wraps the www.judobase.org website API. |
7
|
|
|
|
|
|
|
# VERSION |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
640
|
use Moo; |
|
1
|
|
|
|
|
7302
|
|
|
1
|
|
|
|
|
5
|
|
10
|
|
|
|
|
|
|
require HTTP::Request; |
11
|
|
|
|
|
|
|
require LWP::UserAgent; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
1928
|
use Webservice::Judobase::Competitor; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
14
|
1
|
|
|
1
|
|
412
|
use Webservice::Judobase::Contests; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
15
|
1
|
|
|
1
|
|
432
|
use Webservice::Judobase::Country; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
16
|
1
|
|
|
1
|
|
408
|
use Webservice::Judobase::General; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
28
|
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
7
|
use namespace::clean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $url = 'http://data.ijf.org/api/get_json'; |
21
|
|
|
|
|
|
|
my $ua = LWP::UserAgent->new; |
22
|
|
|
|
|
|
|
$ua->agent("WebServiceJudobase/0.1 "); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has 'competitor' => ( |
25
|
|
|
|
|
|
|
is => 'ro', |
26
|
|
|
|
|
|
|
default => sub { |
27
|
|
|
|
|
|
|
return Webservice::Judobase::Competitor->new( |
28
|
|
|
|
|
|
|
ua => $ua, |
29
|
|
|
|
|
|
|
url => $url, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
}, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has 'contests' => ( |
35
|
|
|
|
|
|
|
is => 'ro', |
36
|
|
|
|
|
|
|
default => sub { |
37
|
|
|
|
|
|
|
return Webservice::Judobase::Contests->new( |
38
|
|
|
|
|
|
|
ua => $ua, |
39
|
|
|
|
|
|
|
url => $url, |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
}, |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has 'country' => ( |
45
|
|
|
|
|
|
|
is => 'ro', |
46
|
|
|
|
|
|
|
default => sub { |
47
|
|
|
|
|
|
|
return Webservice::Judobase::Country->new( |
48
|
|
|
|
|
|
|
ua => $ua, |
49
|
|
|
|
|
|
|
url => $url, |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
}, |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
has 'general' => ( |
55
|
|
|
|
|
|
|
is => 'ro', |
56
|
|
|
|
|
|
|
default => sub { |
57
|
|
|
|
|
|
|
return Webservice::Judobase::General->new( |
58
|
|
|
|
|
|
|
ua => $ua, |
59
|
|
|
|
|
|
|
url => $url, |
60
|
|
|
|
|
|
|
); |
61
|
|
|
|
|
|
|
}, |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub status { |
65
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
66
|
0
|
|
|
|
|
|
my $ua = LWP::UserAgent->new; |
67
|
0
|
|
|
|
|
|
my $request = HTTP::Request->new( GET => $url ); |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
my $response = $ua->request($request); |
70
|
|
|
|
|
|
|
|
71
|
0
|
0
|
|
|
|
|
return $response->code == 200 ? 1 : 0; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |