| 1 | package Cikl::Smrt::Fetchers; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use URI; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use Data::Dumper; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | #use Cikl::Smrt::Fetcher; | ||||||||||
| 8 | |||||||||||
| 9 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use Module::Pluggable search_path => "Cikl::Smrt::Fetchers", | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | inner => 0, require => 1, sub_name => '_fetchers', | ||||||||||
| 12 | on_require_error => \&croak | ||||||||||
| 13 | 1 | ; | |||||||||
| 14 | |||||||||||
| 15 | 4 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 16 | 4 | my $class = shift; | |||||||||
| 17 | |||||||||||
| 18 | 4 | my $self = {}; | |||||||||
| 19 | |||||||||||
| 20 | 4 | bless $self, $class; | |||||||||
| 21 | |||||||||||
| 22 | 4 | $self->{fetchers} = $self->_init_fetchers(); | |||||||||
| 23 | |||||||||||
| 24 | 4 | return $self; | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 4 | ▶ | sub _init_fetchers { | ||||||||
|
Subroutine
_init_fetchers: called CC=6 SCAR=19.9
| |||||||||||
| 28 | 4 | my $self = shift; | |||||||||
| 29 | 4 | my $ret = {}; | |||||||||
| 30 | 4 | my @fetchers; | |||||||||
| 31 | 4 | foreach my $fetcher (__PACKAGE__->_fetchers()) { | |||||||||
| 32 | 8 | foreach my $scheme ($fetcher->schemes()) { | |||||||||
| 33 | 16 | ▶ | my $scheme = lc($scheme) if (defined($scheme)); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 16 | ▶ | if (my $existing = $ret->{$scheme}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 0 | ▶ | $scheme = 'undef' if (!defined($scheme)); # just make it printable | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 0 | die("Cannot associate parser '$fetcher' with the scheme '$scheme'. Already registered with $existing."); | |||||||||
| 37 | } | ||||||||||
| 38 | 16 | $ret->{$scheme} = $fetcher; | |||||||||
| 39 | } | ||||||||||
| 40 | 8 | push(@fetchers, $fetcher); | |||||||||
| 41 | } | ||||||||||
| 42 | 4 | return $ret; | |||||||||
| 43 | #return \@fetchers; | ||||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 0 | ▶ | sub fetchers { | ||||||||
|
Subroutine
fetchers: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 47 | 0 | my $self = shift; | |||||||||
| 48 | 0 | return @{$self->{fetchers}}; | |||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | 6 | ▶ | sub lookup { | ||||||||
|
Subroutine
lookup: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 52 | 6 | my $self = shift; | |||||||||
| 53 | 6 | my $feedurl = shift; | |||||||||
| 54 | 6 | my $scheme = $feedurl->scheme; | |||||||||
| 55 | 6 | ▶ | if (!defined($scheme)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | 2 | $scheme = '__undef__'; | |||||||||
| 57 | } | ||||||||||
| 58 | 6 | $scheme = lc($scheme); | |||||||||
| 59 | 6 | return $self->{fetchers}->{$scheme}; | |||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | 1 | 1; | |||||||||