NAME

OrePAN2::Index - Index

DESCRIPTION

This is a module to manipulate 02packages.details.txt.

METHODS

my $index = OrePAN2::Index->new(%attr)
$index->load($filename)

Load an existing 02.packages.details.txt

my ($version, $path) = $index->lookup($package)

Perform a package lookup on the index.

$index->delete_index($package)

Delete a package from the index.

$index->add_index($package, $version, $path)

Add a new entry to the index.

$index->merge($other_index, protect_author => \@pause_ids)

Merge every package from $other_index into $index, in place. Ordinary merges use add_index's "higher version wins" semantics.

protect_author is an optional list of PAUSE ids. Any package already in $index whose entry's path is authored by one of these ids (i.e. the path looks like X/XX/AUTHORID/...) keeps its $index entry, even if $other_index has a numerically higher version of the same package. Matching is case-insensitive.

Protection is applied per package, not per distribution: if $other_index provides a package that $index's copy of a protected author's distribution doesn't, that package is still taken from $other_index.

If a given protect_author id matches zero packages in $index (a typo, or nothing from that author is in the index yet), a warning is logged -- it doesn't fail the merge, but it means that id currently protects nothing.

$index->as_string()

Returns the content of the index as a string. Some of the index metadata can cause merge conflicts when multiple developers are working on the same project. You can avoid this problem by using a paring down the metadata. "simple" defaults to 0.

$index->as_string( simple => 1 );

Make index as string.

$index->write_gzip( $path, \%options )

Writes the index, gzip-compressed, to the file at $path, replacing any existing file there. The write is atomic: concurrent readers see either the old file or the complete new one, never a partial write. %options is forwarded verbatim to "as_string".

$index->write_gzip( $path, { simple => 1 } );