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