File Coverage

blib/lib/Data/CPAN/DSLIP/Explain.pm
Criterion Covered Total %
statement 36 36 100.0
branch 3 4 75.0
condition n/a
subroutine 8 8 100.0
pod 3 3 100.0
total 50 51 98.0


line stmt bran cond sub pod time code
1             package Data::CPAN::DSLIP::Explain;
2              
3 1     1   26965 use warnings;
  1         2  
  1         35  
4 1     1   7 use strict;
  1         2  
  1         58  
5              
6             our $VERSION = '0.04';
7              
8 1     1   5 use Carp;
  1         6  
  1         628  
9              
10             sub new {
11 1     1 1 15 my $class = shift;
12 1 50       4 croak "Must have even number of arguments to ->new()"
13             if @_ & 1;
14 1         4 my %args = @_;
15 1         5 $args{ lc $_ } = delete $args{ $_ } for keys %args;
16 1         6 return bless \%args, $class;
17             }
18              
19             sub dslip {
20 2     2 1 1386 my $self = shift;
21 2         7 my $dslip = $self->_convert_dslip( @_ );
22 2 100       7 if ( wantarray ) {
23 1         5 return @$dslip;
24             }
25             else {
26 1         4 return $dslip->[0];
27             }
28             }
29              
30             sub _convert_dslip {
31 2     2   3 my $self = shift;
32 2         5 my @dslips = @_;
33              
34 2         8 my $explanation_of = $self->_get_dslip_explanations;
35 2         5 my @result;
36 2         4 foreach my $dslip ( @dslips ) {
37 3         3 my %codes;
38 3         12 @codes{ qw(D S L I P) } = map { lc } split //, $dslip;
  15         52  
39              
40             $codes{ $_ } = $explanation_of->{ $_ }{ $codes{$_} }
41 3         29 for keys %codes;
42              
43 3         9 push @result, \%codes;
44             }
45              
46 2         17 return \@result;
47             }
48              
49             sub explain_dslip_letter {
50 5     5 1 8671 my $self = shift;
51 5         10 my $dslip_letter = uc shift;
52 5         12 my $explanation_of = $self->_get_dslip_explanations;
53 5         48 return $explanation_of->{ $dslip_letter }{info};
54             }
55              
56             sub _get_dslip_explanations {
57 7     7   9 my $self = shift;
58             return {
59 7         164 D => {
60             info => 'Development Stage (Note: *NO IMPLIED TIMESCALES*)',
61             i => 'Idea, listed to gain consensus or as a placeholder',
62             c => 'under construction but pre-alpha (not yet released)',
63             a => 'Alpha testing',
64             b => 'Beta testing',
65             r => 'Released',
66             'm' => 'Mature (no rigorous definition)',
67             's' => 'Standard, supplied with Perl',
68             },
69              
70             S => {
71             info => 'Support Level',
72             'm' => 'Mailing-list',
73             d => 'Developer',
74             u => 'Usenet newsgroup comp.lang.perl.modules',
75             n => 'None known, try comp.lang.perl.modules',
76             },
77              
78             L => {
79             info => 'Language Used',
80             p => 'Perl-only, no compiler needed, '
81             . 'should be platform independent',
82             c => 'C and perl, a C compiler will be needed',
83             h => 'written in perl with optional C code, '
84             . 'no compiler needed',
85             '+' => 'C++ and perl, a C++ compiler will be needed',
86             o => 'perl and another language other than C or C++',
87             },
88              
89             I => {
90             info => 'Interface Style',
91             f => 'plain Functions, no references used',
92             h => 'hybrid, object and function interfaces available',
93             n => 'no interface at all (huh?)',
94             r => 'some use of unblessed References or ties',
95             o => 'Object oriented using blessed references '
96             . 'and/or inheritance',
97             },
98              
99             P => {
100             info => 'Public License',
101             p => 'Standard-Perl: user may choose between GPL '
102             . 'and Artistic',
103             g => 'GPL: GNU General Public License',
104             l => 'LGPL: "GNU Lesser General Public License"'
105             . '(previously known as "GNU Library '
106             . 'General Public License")',
107             b => 'BSD: The BSD License',
108             a => 'Artistic license alone',
109             o => 'other (but distribution allowed '
110             . 'without restrictions)',
111             }
112             }
113             }
114              
115             1;
116             __END__