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