blib/lib/CPAN/WWW/Top100/Retrieve/Utils.pm

filter: Statementstmt 63.3% 19 / 30 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 44.4% 4 / 9 Podpod 100% 5 / 5 totaltotal 58.3% 28 / 48 CC 3 SCAR 11.3
CC
3
Cov
56%
dbid2type
6.0
type2dbid
6.0
default_top100_uri
2.0
CRAP 3.1
« Build ↑ Summary blib/lib/CPAN/WWW/Top100/Retrieve/Dist.pm »
1 # Declare our package
2 package CPAN::WWW::Top100::Retrieve::Utils;
3 1 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 # Initialize our version
6 1 ▶use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 $VERSION = '0.01';
8  
9 # set ourself up for exporting
10 1 ▶use base qw( Exporter );
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 our @EXPORT_OK = qw( default_top100_uri
12 dbid2type type2dbid types dbids
13 );
14  
15 sub default_top100_uri {
16 0 ▶ return 'http://ali.as/top100/data.html';
Subroutine default_top100_uri: not called CC=1 SCAR=6.9
Pod documented
17 }
18  
19 # TODO hardcoded from CPAN::WWW::Top100::Generator v0.08
20 1 my %dbid_type = (
21 1 => 'heavy',
22 2 => 'volatile',
23 3 => 'debian',
24 4 => 'downstream',
25 5 => 'meta1',
26 6 => 'meta2',
27 7 => 'meta3',
28 8 => 'fail',
29 );
30 1 my %type_dbid;
31 1 foreach my $k ( keys %dbid_type ) {
32 8 $type_dbid{ $dbid_type{ $k } } = $k;
33 }
34  
35 sub dbid2type {
36 0 ▶ my $id = shift;
Subroutine dbid2type: not called CC=2 SCAR=17.9
Pod documented
37 0 ▶ if ( exists $dbid_type{ $id } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $dbid_type{$id}) { } 0 0 0
38 0 return $dbid_type{ $id };
39 } else {
40 0 return;
41 }
42 }
43 sub type2dbid {
44 0 ▶ my $type = shift;
Subroutine type2dbid: not called CC=2 SCAR=17.9
Pod documented
45 0 ▶ if ( exists $type_dbid{ $type } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $type_dbid{$type}) { } 0 0 0
46 0 return $type_dbid{ $type };
47 } else {
48 0 return;
49 }
50 }
51  
52 sub types {
53 0 ▶ return [ keys %type_dbid ];
Subroutine types: not called CC=1 SCAR=6.9
Pod documented
54 }
55  
56 sub dbids {
57 0 ▶ return [ keys %dbid_type ];
Subroutine dbids: not called CC=1 SCAR=6.9
Pod documented
58 }
59  
60 1 1;
61 __END__
62  
63 =for stopwords todo Top100 IDs dbid dbids uri
64  
65 =head1 NAME
66  
67 CPAN::WWW::Top100::Retrieve::Utils - Various utilities for Top100 retrieval
68  
69 =head1 SYNOPSIS
70  
71 #!/usr/bin/perl
72 use strict; use warnings;
73 use CPAN::WWW::Top100::Retrieve::Utils qw( default_top100_uri );
74 print "The default Top100 uri is: " . default_top100_uri() . "\n";
75  
76 =head1 DESCRIPTION
77  
78 This module holds the various utility functions used in the Top100 modules. Normally you wouldn't
79 need to use this directly.
80  
81 =head2 Methods
82  
83 =head3 default_top100_uri
84  
85 Returns the Top100 uri we use to retrieve data.
86  
87 The current uri is:
88  
89 return 'http://ali.as/top100/data.html';
90  
91 =head3 types
92  
93 Returns an arrayref of Top100 database types.
94  
95 The current types is:
96  
97 return [ qw( heavy volatile debian downstream meta1 meta2 meta3 fail ) ];
98  
99 =head3 dbids
100  
101 Returns an arrayref of Top100 database type IDs.
102  
103 The current dbids is:
104  
105 return [ qw( 1 2 3 4 5 6 7 8 ) ];
106  
107 =head3 dbid2type
108  
109 Returns the type given a dbid.
110  
111 =head3 type2dbid
112  
113 Returns the dbid given a type.
114  
115 =head1 AUTHOR
116  
117 Apocalypse E<lt>apocal@cpan.orgE<gt>
118  
119 =head1 COPYRIGHT AND LICENSE
120  
121 Copyright 2010 by Apocalypse
122  
123 This library is free software; you can redistribute it and/or modify
124 it under the same terms as Perl itself.
125  
126 The full text of the license can be found in the LICENSE file included with this module.
127  
128 =cut
« Build ↑ Summary blib/lib/CPAN/WWW/Top100/Retrieve/Dist.pm »