line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::UrbanDictionary; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: An OO interface to UrbanDictionary.com's JSON API. |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = "2.013"; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
15582
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
70
|
|
8
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
9
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
19
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
481
|
use Moo; |
|
1
|
|
|
|
|
11131
|
|
|
1
|
|
|
|
|
4
|
|
12
|
1
|
|
|
1
|
|
2035
|
use JSON; |
|
1
|
|
|
|
|
10669
|
|
|
1
|
|
|
|
|
5
|
|
13
|
1
|
|
|
1
|
|
772
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
33299
|
|
|
1
|
|
|
|
|
33
|
|
14
|
1
|
|
|
1
|
|
430
|
use WebService::UrbanDictionary::Term; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
259
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has _ua => ( is => 'ro', default => sub { LWP::UserAgent->new() } ); |
17
|
|
|
|
|
|
|
has _end_point_url => ( is => 'ro', default => sub { 'http://api.urbandictionary.com/v0/define?term=' } ); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub request { |
20
|
1
|
|
|
1
|
1
|
3062
|
my $self = shift; |
21
|
1
|
50
|
|
|
|
25
|
my $term = shift or carp "No term provided."; |
22
|
1
|
|
|
|
|
6
|
my $url = $self->_end_point_url . $term; |
23
|
1
|
50
|
|
|
|
6
|
my $res = decode_json $self->_ua->get( $url )->decoded_content or carp "Error during fetch/decode."; |
24
|
1
|
|
|
|
|
351409
|
$res->{term} = $term; |
25
|
1
|
|
|
|
|
13
|
return WebService::UrbanDictionary::Term->new( $res ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
1; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
__END__ |