| 1 | package WWW::Shorten::generic; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 7 | ▶ | use Carp (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 7 | ▶ | use WWW::Shorten::UserAgent; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 7 | our $VERSION = '3.093'; | |||||||||||||||||||||||||||
| 10 | 7 | $VERSION = eval $VERSION; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 7 | my %name_sets = ( | |||||||||||||||||||||||||||
| 13 | default => [qw( makeashorterlink makealongerlink )], | ||||||||||||||||||||||||||||
| 14 | short => [qw( short_link long_link )], | ||||||||||||||||||||||||||||
| 15 | ); | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | sub import { | ||||||||||||||||||||||||||||
| 18 | 8 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 19 | 8 | my ($package) = caller; | |||||||||||||||||||||||||||
| 20 | 8 | ▶ | ($package) = caller(1) if $package eq 'WWW::Shorten'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 8 | my $set = shift; | |||||||||||||||||||||||||||
| 22 | 8 | ▶ | if (defined $set and $set =~ /^ : (\w+) $/x) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $set and $set =~ /^ : (\w+) $/x
MC/DC50%1/2
defined $set and $set =~ /^ : (\w+) $/x
defined $set
$set =~ /^ : (\w+) $/x
Truth table66%2/3
A and B
A= defined $setB= $set =~ /^ : (\w+) $/x
| |||||||||||||||||||||||||||||
| 23 | 3 | $set = $1; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | else { | ||||||||||||||||||||||||||||
| 26 | 5 | $set = 'default'; | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | 8 | ▶ | if (exists $name_sets{$set}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | 7 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | 7 | *{"${package}::$name_sets{$set}[0]"} | |||||||||||||||||||||||||||
| 31 | 7 | = *{"${class}::$name_sets{default}[0]"}; | |||||||||||||||||||||||||||
| 32 | 7 | *{"${package}::$name_sets{$set}[1]"} | |||||||||||||||||||||||||||
| 33 | 7 | = *{"${class}::$name_sets{default}[1]"}; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | else { | ||||||||||||||||||||||||||||
| 36 | 1 | Carp::croak("Unknown function set - $set."); | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 7 | my $ua; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | sub ua { | ||||||||||||||||||||||||||||
| 43 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
ua: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | return $ua if defined $ua; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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 | 7 | 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 | ||||||||||||||||||||||||||||