line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Shorten::generic; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
51
|
use strict; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
178
|
|
4
|
7
|
|
|
7
|
|
33
|
use warnings; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
136
|
|
5
|
|
|
|
|
|
|
|
6
|
7
|
|
|
7
|
|
29
|
use Carp (); |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
119
|
|
7
|
7
|
|
|
7
|
|
2709
|
use WWW::Shorten::UserAgent; |
|
7
|
|
|
|
|
23
|
|
|
7
|
|
|
|
|
841
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '3.094'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my %name_sets = ( |
12
|
|
|
|
|
|
|
default => [qw( makeashorterlink makealongerlink )], |
13
|
|
|
|
|
|
|
short => [qw( short_link long_link )], |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub import { |
17
|
8
|
|
|
8
|
|
199
|
my $class = shift; |
18
|
8
|
|
|
|
|
25
|
my ($package) = caller; |
19
|
8
|
100
|
|
|
|
52
|
($package) = caller(1) if $package eq 'WWW::Shorten'; |
20
|
8
|
|
|
|
|
18
|
my $set = shift; |
21
|
8
|
100
|
66
|
|
|
58
|
if (defined $set and $set =~ /^ : (\w+) $/x) { |
22
|
3
|
|
|
|
|
10
|
$set = $1; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
else { |
25
|
5
|
|
|
|
|
11
|
$set = 'default'; |
26
|
|
|
|
|
|
|
} |
27
|
8
|
100
|
|
|
|
25
|
if (exists $name_sets{$set}) { |
28
|
7
|
|
|
7
|
|
77
|
no strict 'refs'; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
1227
|
|
29
|
7
|
|
|
|
|
46
|
*{"${package}::$name_sets{$set}[0]"} |
30
|
7
|
|
|
|
|
13
|
= *{"${class}::$name_sets{default}[0]"}; |
|
7
|
|
|
|
|
34
|
|
31
|
7
|
|
|
|
|
1675
|
*{"${package}::$name_sets{$set}[1]"} |
32
|
7
|
|
|
|
|
16
|
= *{"${class}::$name_sets{default}[1]"}; |
|
7
|
|
|
|
|
21
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
else { |
35
|
1
|
|
|
|
|
187
|
Carp::croak("Unknown function set - $set."); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $ua; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub ua { |
42
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
43
|
0
|
0
|
|
|
|
|
return $ua if defined $ua; |
44
|
0
|
|
|
|
|
|
my $v = $self->VERSION(); |
45
|
0
|
|
|
|
|
|
$ua = WWW::Shorten::UserAgent->new( |
46
|
|
|
|
|
|
|
env_proxy => 1, |
47
|
|
|
|
|
|
|
timeout => 30, |
48
|
|
|
|
|
|
|
agent => "$self/$v", |
49
|
|
|
|
|
|
|
requests_redirectable => [], |
50
|
|
|
|
|
|
|
); |
51
|
0
|
|
|
|
|
|
return $ua; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 NAME |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
WWW::Shorten::generic - Methods shared across all WWW::Shorten modules |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 SYNOPSIS |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
use WWW::Shorten 'SomeSubclass'; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 DESCRIPTION |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Contains methods that are shared across all WWW::Shorten implementation |
67
|
|
|
|
|
|
|
modules. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 FUNCTIONS |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 ua |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Returns the object's LWP::Useragent attribute. Creates a new one if one |
74
|
|
|
|
|
|
|
doesn't already exist. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |