line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
187085
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
2
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Webservice::Judobase; |
5
|
|
|
|
|
|
|
$Webservice::Judobase::VERSION = '0.09'; |
6
|
|
|
|
|
|
|
# ABSTRACT: This module wraps the www.judobase.org website API. |
7
|
|
|
|
|
|
|
# VERSION |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
511
|
use Moo; |
|
1
|
|
|
|
|
5846
|
|
|
1
|
|
|
|
|
4
|
|
10
|
|
|
|
|
|
|
require HTTP::Request; |
11
|
|
|
|
|
|
|
require LWP::UserAgent; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
1582
|
use Webservice::Judobase::Competitor; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
14
|
1
|
|
|
1
|
|
361
|
use Webservice::Judobase::Contests; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
15
|
1
|
|
|
1
|
|
349
|
use Webservice::Judobase::Country; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
24
|
|
16
|
1
|
|
|
1
|
|
334
|
use Webservice::Judobase::General; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
25
|
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
6
|
use namespace::clean; |
|
1
|
|
|
|
|
1
|
|
|
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; |