PackageDetails/Entry.pm

filter: Statementstmt 88.0% 22 / 25 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 72.7% 8 / 11 Podpod 100% 6 / 6 totaltotal 86.3% 38 / 44 CC 2 SCAR 3.5
CC
2
Cov
89%
author
2.0
version
2.0
package_name
2.0
CRAP 1.4
« PackageDetails/Header.pm ↑ Summary
1 14 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package CPAN::PackageDetails::Entry;
4 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 14 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 14 our $VERSION = '0.263';
8  
9 14 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 =encoding utf8
12  
13 =head1 NAME
14  
15 CPAN::PackageDetails::Entry - Handle a single record of 02packages.details.txt.gz
16  
17 =head1 SYNOPSIS
18  
19 Used internally by CPAN::PackageDetails
20  
21 =head1 DESCRIPTION
22  
23 An entry is a single line from F<02packages.details.txt> that maps a
24 package name to a source. It's a whitespace-separated list that
25 has the values for the column identified in the "columns" field
26 in the header.
27  
28 By default, there are three columns: package name, version, and path.
29  
30 Inside a CPAN::PackageDetails object, the actual work and
31 manipulation of the entries are handled by delegate classes specified
32 in C<entries_class> and C<entry_class>). At the moment these are
33 immutable, so you'd have to subclass this module to change them.
34  
35 =head2 Methods
36  
37 =over 4
38  
39 =item new( FIELD1 => VALUE1 [, FIELD2 => VALUE2] )
40  
41 Create a new entry
42  
43 =cut
44  
45 1477 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
46 1477 my( $class, %args ) = @_;
47  
48 1477 bless { %args }, $class
49 }
50  
51 =item path
52  
53 =item author
54  
55 =item version
56  
57 =item package_name
58  
59 Access values of the entry.
60  
61 =cut
62  
63 14 ▶sub path { $_[0]->{path} }
Subroutine path: called CC=1 SCAR=0.0
Pod documented
64 0 ▶sub author { ( split m|/|, $_[0]->{path} )[2] }
Subroutine author: not called CC=1 SCAR=6.9
Pod documented
65 0 ▶sub version { $_[0]->{version} }
Subroutine version: not called CC=1 SCAR=6.9
Pod documented
66 0 ▶sub package_name { $_[0]->{'package name'} }
Subroutine package_name: not called CC=1 SCAR=6.9
Pod documented
67  
68 =item as_string( @column_names )
69  
70 Formats the Entry as text. It joins with whitespace the values for the
71 column names you pass it. You get the newline automatically.
72  
73 Any values that are not defined (or the empty string) turn into the
74 literal string 'undef' to preserve the columns in the output.
75  
76 =cut
77  
78 9 ▶sub as_string {
Subroutine as_string: called CC=2 SCAR=6.9
Pod documented
79 9 my( $self, @columns ) = @_;
80  
81 14 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
82 # can't check defined() because that let's the empty string through
83  
84 return sprintf "%-34s %5s %s\n",
85 9 ▶ map { length $self->{$_} ? $self->{$_} : 'undef' } @columns;
Branch: 1 branch
BranchTrueFalseTotal
length $self->{$_} ? : 24 3 27
86 }
87  
88 =back
89  
90 =head1 TO DO
91  
92 =head1 SEE ALSO
93  
94  
95 =head1 SOURCE AVAILABILITY
96  
97 This source is in Github:
98  
99 https://github.com/briandfoy/cpan-packagedetails
100  
101 =head1 AUTHOR
102  
103 brian d foy, C<< <briandfoy@pobox.com> >>
104  
105 =head1 COPYRIGHT AND LICENSE
106  
107 Copyright © 2009-2025, brian d foy <briandfoy@pobox.com>. All rights reserved.
108  
109 You may redistribute this under the terms of the Artistic License 2.0.
110  
111 =cut
112  
113 14 1;
114  
115  
« PackageDetails/Header.pm ↑ Summary