• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

lib/Parse/CPAN/H06-Feb-2015-651259

t/H03-May-2022-11584

xt/H06-Feb-2015-2115

CHANGESH A D06-Feb-20153.3 KiB9268

MANIFESTH A D06-Feb-2015516 1716

META.jsonH A D06-Feb-20151.4 KiB6059

META.ymlH A D06-Feb-2015794 3635

Makefile.PLH A D06-Feb-20151,004 4038

READMEH A D26-Dec-20106.2 KiB177134

README

1NAME
2    Parse::CPAN::Packages - Parse 02packages.details.txt.gz
3
4SYNOPSIS
5      use Parse::CPAN::Packages;
6
7      # must have downloaded
8      my $p = Parse::CPAN::Packages->new("02packages.details.txt.gz");
9      # either a filename as above or pass in the contents of the file
10      # (uncompressed)
11      my $p = Parse::CPAN::Packages->new($packages_details_contents);
12
13      my $m = $p->package("Acme::Colour");
14      # $m is a Parse::CPAN::Packages::Package object
15      print $m->package, "\n";   # Acme::Colour
16      print $m->version, "\n";   # 1.00
17
18      my $d = $m->distribution();
19      # $d is a Parse::CPAN::Packages::Distribution object
20      print $d->prefix, "\n";    # L/LB/LBROCARD/Acme-Colour-1.00.tar.gz
21      print $d->dist, "\n";      # Acme-Colour
22      print $d->version, "\n";   # 1.00
23      print $d->maturity, "\n";  # released
24      print $d->filename, "\n";  # Acme-Colour-1.00.tar.gz
25      print $d->cpanid, "\n";    # LBROCARD
26      print $d->distvname, "\n"; # Acme-Colour-1.00
27
28      # all the package objects
29      my @packages = $p->packages;
30
31      # all the distribution objects
32      my @distributions = $p->distributions;
33
34      # the latest distribution
35      $d = $p->latest_distribution("Acme-Colour");
36      is($d->prefix, "L/LB/LBROCARD/Acme-Colour-1.00.tar.gz");
37      is($d->version, "1.00");
38
39      # all the latest distributions
40      my @distributions = $p->latest_distributions;
41
42DESCRIPTION
43    The Comprehensive Perl Archive Network (CPAN) is a very useful
44    collection of Perl code. It has several indices of the files that it
45    hosts, including a file named "02packages.details.txt.gz" in the
46    "modules" directory. This file contains lots of useful information and
47    this module provides a simple interface to the data contained within.
48
49    In a future release Parse::CPAN::Packages::Package and
50    Parse::CPAN::Packages::Distribution might have more information.
51
52  Methods
53    new Creates a new instance from a details file.
54
55        The constructor can be passed either the path to the
56        "02packages.details.txt.gz" file, a path to an ungzipped version of
57        this file, or a scalar containing the entire uncompressed contents
58        of the file.
59
60        Note that this module does not concern itself with downloading this
61        file. You should do this yourself. For example:
62
63           use LWP::Simple qw(get);
64           my $data = get("http://www.cpan.org/modules/02packages.details.txt.gz");
65           my $p = Parse::CPAN::Packages->new($data);
66
67    package($packagename)
68        Returns a "Parse::CPAN::Packages::Package" that represents the named
69        package.
70
71          my $p = Parse::CPAN::Distribution->new($gzfilename);
72          my $package = $p->package("Acme::Colour");
73
74    packages()
75        Returns a list of Parse::CPAN::Packages::Package objects
76        representing all the packages that were extracted from the file.
77
78    package_count()
79        Returns the numebr of packages stored.
80
81    distribution($filename)
82        Returns a Parse::CPAN::Distribution that represents the filename
83        passed:
84
85          my $p = Parse::CPAN::Distribution->new($gzfilename);
86          my $dist = $p->distribution('L/LB/LBROCARD/Acme-Colour-1.00.tar.gz');
87
88    distributions()
89        Returns a list of Parse::CPAN::Distribution objects representing all
90        the known distributions.
91
92    distribution_count()
93        Returns the number of distributions stored.
94
95    latest_distribution($distname)
96        Returns the "Parse::CPAN::Distribution" that represents the latest
97        distribution for the named disribution passed, that is to say it
98        returns the distribution that has the highest version number (as
99        determined by version.pm or number comparison if that fails):
100
101          my $p = Parse::CPAN::Distribution->new($gzfilename);
102          my $dist = $p->distribution('Acme-Color');
103
104    latest_distrbutions()
105        Returns a list of Parse::CPAN::Distribution objects representing all
106        the latest distributions.
107
108    latest_distribution_count()
109        Returns the number of distributions stored.
110
111  Preamble Methods
112    These methods return the information from the preamble at the start of
113    the file. They return undef if for any reason no matching preamble line
114    was found.
115
116    file()
117    url()
118    description()
119    columns()
120    intended_for()
121    written_by()
122    line_count()
123    last_updated()
124
125  Addtional Methods
126    These are additional methods that you may find useful.
127
128    parse($filename)
129        Parses the filename. Works in a similar fashion to the the
130        constructor (i.e. you can pass it a filename for a
131        compressed/1uncompressed file, a uncompressed scalar containing the
132        file. You can also pass nothing to indicate to load the compressed
133        file from the current working directory.)
134
135        Note that each time this function is run the packages and
136        distribtions found will be "added" to the current list of packages.
137
138    add_quick($package_name, $package_version, $prefix)
139        Quick way of adding a new package and distribution.
140
141    add_package($package_obj)
142        Adds a package. Note that you'll probably want to add the
143        corrisponding distribution for that package too (it's not done
144        automatically.)
145
146    add_distribution($distribution_obj)
147        Adds a distribution. Note that you'll probably want to add the
148        corrisponding packages for that distribution too (it's not done
149        automatically.)
150
151AUTHOR
152    Leon Brocard <acme@astray.com>
153
154COPYRIGHT
155    Copyright (C) 2004-9, Leon Brocard
156
157LICENSE
158    This module is free software; you can redistribute it or modify it under
159    the same terms as Perl itself.
160
161BUGS
162    This module leaks memory as packages hold distributions and
163    distributions hold packages. No attempt has been made to fix this as
164    it's not anticpated that this will be used in long running programs that
165    will dispose of the objects once created.
166
167    The old interface for "new" where if you passed no arguments it would
168    look for a "02packages.details.txt.gz" in your current directory is no
169    longer supported.
170
171TODO
172    delete_* methods. merge_into method. Documentation for other modules.
173
174SEE ALSO
175    CPAN::DistInfoname, Parse::CPAN::Packages::Writer.
176
177