Simple/UserAgent.pm

filter: Statementstmt 77.7% 7 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 83.3% 10 / 12 CC 1 SCAR 0.9
CC
1
Cov
78%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« Simple/Async/Irssi.pm ↑ Summary Simple.pm »
1 package Net::Curl::Simple::UserAgent;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 0 ▶use Net::Curl::Share qw(CURLSHOPT_SHARE /^CURL_LOCK_DATA_/);
Subroutine BEGIN: called CC=1 SCAR=2.6
6 use base qw(Net::Curl::Share);
7  
8 our $VERSION = '0.13';
9  
10 my %common_options = (
11 useragent => __PACKAGE__ . ' v' . $VERSION,
12 );
13  
14 sub setopts
15 {
16 my $share = shift;
17 my %opts = @_;
18  
19 $share = \%common_options
20 unless ref $share;
21  
22 @$share{ keys %opts } = values %opts;
23 }
24 *setopt = \&setopts;
25  
26 sub new
27 {
28 my $class = shift;
29  
30 my $share = $class->SUPER::new();
31  
32 $share->SUPER::setopt( CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE );
33 $share->SUPER::setopt( CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS );
34 $share->setopts( %common_options, @_ );
35  
36 return $share;
37 }
38  
39 sub curl
40 {
41 my $share = shift;
42 require Net::Curl::Simple;
43 return Net::Curl::Simple->new( %$share, @_, share => $share );
44 }
45  
46 1;
47  
48 __END__
« Simple/Async/Irssi.pm ↑ Summary Simple.pm »