line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::UINames; |
2
|
|
|
|
|
|
|
# ABSTRACT: WebService::UINames - uinames.com API interface for Perl |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# pragmas |
5
|
2
|
|
|
2
|
|
32131
|
use utf8; |
|
2
|
|
|
|
|
15
|
|
|
2
|
|
|
|
|
8
|
|
6
|
2
|
|
|
2
|
|
51
|
use 5.10.0; |
|
2
|
|
|
|
|
4
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#imports |
9
|
2
|
|
|
2
|
|
897
|
use Moo; |
|
2
|
|
|
|
|
19038
|
|
|
2
|
|
|
|
|
9
|
|
10
|
2
|
|
|
2
|
|
2016
|
use Carp; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
88
|
|
11
|
2
|
|
|
2
|
|
1110
|
use JSON; |
|
2
|
|
|
|
|
20798
|
|
|
2
|
|
|
|
|
6
|
|
12
|
2
|
|
|
2
|
|
965
|
use Try::Tiny; |
|
2
|
|
|
|
|
1665
|
|
|
2
|
|
|
|
|
84
|
|
13
|
2
|
|
|
2
|
|
1032
|
use LWP::UserAgent; |
|
2
|
|
|
|
|
56484
|
|
|
2
|
|
|
|
|
287
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# version |
16
|
|
|
|
|
|
|
our $VERSION = 0.01; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# attributes |
20
|
|
|
|
|
|
|
has '_ua' => ( |
21
|
|
|
|
|
|
|
is => 'ro', default => sub { |
22
|
|
|
|
|
|
|
my $ua = LWP::UserAgent->new; |
23
|
|
|
|
|
|
|
$ua->agent('WebService-UINames/0.01 Perl API Client'); |
24
|
|
|
|
|
|
|
return $ua; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# methods |
30
|
|
|
|
|
|
|
sub get_name { |
31
|
1
|
|
|
1
|
1
|
1055
|
my ($self, $args) = (shift, {@_}); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# sending data |
34
|
1
|
|
|
|
|
5
|
my $res = $self->_ua->get( |
35
|
|
|
|
|
|
|
'http://uinames.com/api/', form => $args |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
490794
|
my $json = {}; |
39
|
|
|
|
|
|
|
try { |
40
|
1
|
|
|
1
|
|
49
|
$json = JSON::decode_json($res->decoded_content) |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
catch { |
43
|
0
|
|
|
0
|
|
0
|
warn "JSON Decode Exception: $_"; |
44
|
1
|
|
|
|
|
13
|
}; |
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
149
|
return $json; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
__END__ |