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