lib/WebService/UINames.pm

filter: Statementstmt 100% 33 / 33 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 100% 1 / 1 totaltotal 100% 45 / 45 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/WebService/example.pl ↑ Summary
1 package WebService::UINames;
2 # ABSTRACT: WebService::UINames - uinames.com API interface for Perl
3  
4 # pragmas
5 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use 5.10.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 #imports
9 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 # version
16 2 our $VERSION = 0.01;
17  
18  
19 # attributes
20 has '_ua' => (
21 1 ▶ is => 'ro', default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
22 1 my $ua = LWP::UserAgent->new;
23 1 $ua->agent('WebService-UINames/0.01 Perl API Client');
24 1 return $ua;
25 }
26 2 );
27  
28  
29 # methods
30 1 ▶sub get_name {
Subroutine get_name: called CC=1 SCAR=0.0
Pod documented
31 1 my ($self, $args) = (shift, {@_});
32  
33 # sending data
34 1 my $res = $self->_ua->get(
35 'http://uinames.com/api/', form => $args
36 );
37  
38 1 my $json = {};
39 1 ▶ try {
Subroutine __ANON__: called CC=1 SCAR=0.0
40 1 $json = JSON::decode_json($res->decoded_content)
41 }
42 1 ▶ catch {
Subroutine __ANON__: called CC=1 SCAR=0.0
43 1 warn "JSON Decode Exception: $_";
44 1 };
45  
46 1 return $json;
47 }
48  
49 2 1;
50 __END__
« blib/lib/WebService/example.pl ↑ Summary