| 1 | # | ||||||||||
| 2 | # This file is part of CPAN-WWW-Top100-Retrieve | ||||||||||
| 3 | # | ||||||||||
| 4 | # This software is copyright (c) 2014 by Apocalypse. | ||||||||||
| 5 | # | ||||||||||
| 6 | # This is free software; you can redistribute it and/or modify it under | ||||||||||
| 7 | # the same terms as the Perl 5 programming language system itself. | ||||||||||
| 8 | # | ||||||||||
| 9 | 2 | ▶ | use strict; use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | # Declare our package | ||||||||||
| 11 | package CPAN::WWW::Top100::Retrieve::Utils; | ||||||||||
| 12 | 2 | $CPAN::WWW::Top100::Retrieve::Utils::VERSION = '1.001'; | |||||||||
| 13 | 2 | our $AUTHORITY = 'cpan:APOCAL'; | |||||||||
| 14 | |||||||||||
| 15 | # ABSTRACT: Provides util functions | ||||||||||
| 16 | |||||||||||
| 17 | # set ourself up for exporting | ||||||||||
| 18 | 2 | ▶ | use parent qw( Exporter ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 2 | our @EXPORT_OK = qw( default_top100_uri | |||||||||
| 20 | dbid2type type2dbid types dbids | ||||||||||
| 21 | ); | ||||||||||
| 22 | |||||||||||
| 23 | 0 | ▶ | sub default_top100_uri { | ||||||||
|
Subroutine
default_top100_uri: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 24 | 0 | return 'http://ali.as/top100/data.html'; | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | # hardcoded from CPAN::WWW::Top100::Generator v0.08 | ||||||||||
| 28 | 2 | my %dbid_type = ( | |||||||||
| 29 | 1 => 'heavy', | ||||||||||
| 30 | 2 => 'volatile', | ||||||||||
| 31 | 3 => 'debian', | ||||||||||
| 32 | 4 => 'downstream', | ||||||||||
| 33 | 5 => 'meta1', | ||||||||||
| 34 | 6 => 'meta2', | ||||||||||
| 35 | 7 => 'meta3', | ||||||||||
| 36 | 8 => 'fail', | ||||||||||
| 37 | ); | ||||||||||
| 38 | 2 | my %type_dbid; | |||||||||
| 39 | 2 | foreach my $k ( keys %dbid_type ) { | |||||||||
| 40 | 16 | $type_dbid{ $dbid_type{ $k } } = $k; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 0 | ▶ | sub dbid2type { | ||||||||
|
Subroutine
dbid2type: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 44 | 0 | my $id = shift; | |||||||||
| 45 | 0 | ▶ | if ( exists $dbid_type{ $id } ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | 0 | return $dbid_type{ $id }; | |||||||||
| 47 | } else { | ||||||||||
| 48 | 0 | return; | |||||||||
| 49 | } | ||||||||||
| 50 | } | ||||||||||
| 51 | 0 | ▶ | sub type2dbid { | ||||||||
|
Subroutine
type2dbid: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 52 | 0 | my $type = shift; | |||||||||
| 53 | 0 | ▶ | if ( exists $type_dbid{ $type } ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | 0 | return $type_dbid{ $type }; | |||||||||
| 55 | } else { | ||||||||||
| 56 | 0 | return; | |||||||||
| 57 | } | ||||||||||
| 58 | } | ||||||||||
| 59 | |||||||||||
| 60 | 0 | ▶ | sub types { | ||||||||
|
Subroutine
types: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 61 | 0 | return [ keys %type_dbid ]; | |||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | 0 | ▶ | sub dbids { | ||||||||
|
Subroutine
dbids: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 65 | 0 | return [ keys %dbid_type ]; | |||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | 2 | 1; | |||||||||
| 69 | |||||||||||
| 70 | __END__ | ||||||||||