File Coverage

blib/lib/Regru/API/Role/UserAgent.pm
Criterion Covered Total %
statement 18 18 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 24 24 100.0


line stmt bran cond sub pod time code
1              
2             # ABSTRACT: something that can act as user-agent
3              
4             use strict;
5 13     13   13682 use warnings;
  13         81  
  13         367  
6 13     13   63 use Moo::Role;
  13         30  
  13         259  
7 13     13   55 use LWP::UserAgent;
  13         34  
  13         72  
8 13     13   11025 use Carp;
  13         477895  
  13         377  
9 13     13   97 use namespace::autoclean;
  13         28  
  13         663  
10 13     13   464  
  13         9499  
  13         106  
11             our $VERSION = '0.052'; # VERSION
12             our $AUTHORITY = 'cpan:CHIM'; # AUTHORITY
13              
14             has useragent => (
15             is => 'rw',
16             isa => sub { croak "$_[0] is not a LWP::UserAgent instance" unless ref $_[0] eq 'LWP::UserAgent' },
17             lazy => 1,
18             default => sub { LWP::UserAgent->new },
19             );
20              
21             1; # End of Regru::API::Role::UserAgent
22              
23              
24             =pod
25              
26             =encoding UTF-8
27              
28             =head1 NAME
29              
30             Regru::API::Role::UserAgent - something that can act as user-agent
31              
32             =head1 VERSION
33              
34             version 0.052
35              
36             =head1 SYNOPSIS
37              
38             package Regru::API::Client;
39             ...
40             with 'Regru::API::Role::UserAgent';
41             ...
42             $resp = $self->useragent->get('http://example.com/');
43              
44             if ($resp->is_success) {
45             print $resp->decoded_content;
46             }
47             else {
48             die $resp->status_line;
49             }
50              
51             =head1 DESCRIPTION
52              
53             Any class or role that consumes this one will able to dispatch HTTP requests.
54              
55             =head1 ATTRIBUTES
56              
57             =head2 useragent
58              
59             Returns an L<LWP::UserAgent> instance.
60              
61             =head1 SEE ALSO
62              
63             L<Regru::API>
64              
65             L<Regru::API::Role::Client>
66              
67             L<LWP::UserAgent>
68              
69             =head1 BUGS
70              
71             Please report any bugs or feature requests on the bugtracker website
72             L<https://github.com/regru/regru-api-perl/issues>
73              
74             When submitting a bug or request, please include a test-file or a
75             patch to an existing test-file that illustrates the bug or desired
76             feature.
77              
78             =head1 AUTHORS
79              
80             =over 4
81              
82             =item *
83              
84             Polina Shubina <shubina@reg.ru>
85              
86             =item *
87              
88             Anton Gerasimov <a.gerasimov@reg.ru>
89              
90             =back
91              
92             =head1 COPYRIGHT AND LICENSE
93              
94             This software is copyright (c) 2013 by REG.RU LLC.
95              
96             This is free software; you can redistribute it and/or modify it under
97             the same terms as the Perl 5 programming language system itself.
98              
99             =cut