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.015"; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
32763
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
72
|
|
8
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
9
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
442
|
use Moo; |
|
1
|
|
|
|
|
11873
|
|
|
1
|
|
|
|
|
5
|
|
12
|
1
|
|
|
1
|
|
1825
|
use JSON; |
|
1
|
|
|
|
|
12772
|
|
|
1
|
|
|
|
|
5
|
|
13
|
1
|
|
|
1
|
|
852
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
30433
|
|
|
1
|
|
|
|
|
29
|
|
14
|
1
|
|
|
1
|
|
391
|
use WebService::UrbanDictionary::Term; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
168
|
|
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
|
1947
|
my $self = shift; |
21
|
1
|
50
|
|
|
|
17
|
my $term = shift or carp "No term provided."; |
22
|
1
|
|
|
|
|
5
|
my $url = $self->_end_point_url . $term; |
23
|
1
|
50
|
|
|
|
5
|
my $res = decode_json $self->_ua->get( $url )->decoded_content or carp "Error during fetch/decode."; |
24
|
1
|
|
|
|
|
376644
|
$res->{term} = $term; |
25
|
1
|
|
|
|
|
13
|
return WebService::UrbanDictionary::Term->new( $res ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
1; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
__END__ |